Changing marker size in legends (gramm)
조회 수: 7 (최근 30일)
이전 댓글 표시
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
Constantino Carlos Reyes-Aldasoro
2022년 6월 8일
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 Center 및 File Exchange에서 Legend에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!