MATLAB Answers

How to set a default marker size in the legend?

147 views (last 30 days)
Martim Zurita
Martim Zurita on 4 Jun 2019
Commented: Martim Zurita on 7 Jun 2019
Hello,
Every time I open a saved figure, it appears not as I had saved it, but with the default configurations of MatLab. To get around this, I use the command
set(0,'defaultAxesFontSize',25, ...
'defaultAxesTitleFontSizeMultiplier', 24/25)
This command makes de default axes font size to be 25 and the title font, to be 24. Nevertheless, I could not use the same command for the marker size in the legend. In other words, I couldn't find a command of the type
set(0,'defaultMarkerSize',10)
Is there a command that does this? (Another welcome solution would be a way to open the saved figures with the original configurations I choosed to them.)
As an example, I've made the following simple program:
x = randn(1,1000);
y = randn(1,1000);
figure, plot(x,y, '.')
legend('randn')
[h,icons] = legend('randn');
icons(3).MarkerSize = 15; % This line makes the marker size of the legend bigger
The result is as follows from the figure (a). When I save and then reopen this figure, however, the marker size of the legend comes back to be the smaller size (equal to the size of the points in the graphic). Figure (b) shows this event. Is there a way to set a default marker size in the legend so this wouldn't happen?
Thanks
ps: I am using MatLab 2018a
Screen Shot 2019-06-04 at 18.07.19.png,
  1 Comment
Martim Zurita
Martim Zurita on 6 Jun 2019
I asked this question because, on the figures I'm currently working with, the default size of the markers in the legend is very small. An example is shown below.
ode113_phi2_2p2_I0_0p578e579_psi0_0_i_1e4_Tol_13_14_alfa_pi.png

Sign in to comment.

Answers (1)

pankhuri kasliwal
pankhuri kasliwal on 7 Jun 2019
To change the marker size of the legend you can simply do
set(icons(3), 'Markersize', 12); %set marker size as desired
  1 Comment
Martim Zurita
Martim Zurita on 7 Jun 2019
Pankhuri,
Thanks for your answer. I know how to change the size of the marker in the legend. I did this in this line shown above:
icons(3).MarkerSize = 15;
The thing is that I want to change the default value of the legend marker size. Because everytime I open a saved figure, it appears with the MatLab default configurations, not the ones I've saved the figure with.
It is very annoying to change by hand the legend marker size every time I open a figure. This is why I want a default configuration of the legend marker size or a way to open the figure with the configurations I've saved to it.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!