Changing marker size in legends (gramm)

조회 수: 14 (최근 30일)
z8080
z8080 2022년 4월 1일
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
z8080
z8080 2022년 6월 8일
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.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Legend에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by