Changing marker size in legends (gramm)

10 views (last 30 days)
I am using the gramm toolbox to do plots of all sorts in Matlab. One thing I'm having to always edit post-hoc in most plots (i.e. using the Property Inspector, instead of programatically adjusting gramm calls) is the marker size in legends, which by default are tiny. This amounts to increasing lineWidth:
Gramm does have a function dedicated to changing marker sizes, set_point_options, but that only refers to markers in the main plot, and does not affect those in the legend. Similarly, the set_text_options function has scaling parameters for the title & text of the legend, but not for the markers. Sadly, the toolbox's author is no longer available for support.
My usual way of changing legend marker sizes (for Matlab-native plot functions) is given below, but does not work with gramm plots:
x = 1:10;
plot(x, 1*x, 'o');
hold on;
plot(x, 2*x, 's');
[~, objh] = legend({'one','two'});
objhl = findobj(objh, 'type', 'line');
set(objhl, 'Markersize', 18);
% or, for Patch plots:
objhl = findobj(objh, 'type', 'patch');
set(objhl, 'Markersize', markerSize_legend);
  3 Comments
z8080
z8080 on 8 Jun 2022
Sadly no. I reverted to normal plotting in Matlab, as gramm simply imposes too many restrictions that I don't know / don't have time to get around, and is also sadly not really supported, neither by the author nor by any real community of users.
Constantino Carlos Reyes-Aldasoro
Why don't you define your properties directly from the plots:
x = 1:10;
plot(x, 1*x, 'o','markersize',9);
hold on;
plot(x, 2*x, 's','markersize',6);
You can also use handles to sort this without having to use any property inspector, but try this to see if it works. If not, let me know.

Sign in to comment.

Answers (0)

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!