Info

This question is closed. Reopen it to edit or answer.

Why does the size of my legend change randomly from one plot to the next?

1 view (last 30 days)
I am writing code that reads through several years of daily temperature data, computes means, and then plots them as a time series.
I use the code to parse through one set of data from one station, and then the resulting plot looks fine - with several lines on a plot and a legend on the bottom that defines what each line is.
I used the same code above - making NO CHANGES - but instead used a different weather station. In the resulting image, the legend in the second plot is HUGE. I cannot for the life of me understand why my legend is blowing up in one image, and then regular sized in the other, when I'm not doing anything differently other than using a different .txt file of air temperature data.
I have tried googling this issue for a long time and cannot find help. is there anyone else experiencing what appears to be spontaneous changing of the size of your legend when you use the exact same code? This only started happening when I updated to R2015....
Image with the legend that doubled in size:
Image with the normal sized legend:
  4 Comments
Jon
Jon on 22 Sep 2015
When you are plotting the new figure, are you closing the previous plot? It could be an artifact of plotting over already-generated axes?
Megan
Megan on 30 Sep 2015
Hi Jon - good question. Yes - my code is closing all plots and clearing all variables before going on to the next set of data.

Answers (1)

Star Strider
Star Strider on 30 Sep 2015
It’s a bit inconvenient, but you can get and set the Position property of the legend. One option is to let MATLAB place them, then get, modify, and set the values to your specification.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!