Filter löschen
Filter löschen

How to change the legend colored linewidth, not the width of box outline

35 Ansichten (letzte 30 Tage)
Liwei Dai
Liwei Dai am 8 Dez. 2015
Kommentiert: dpb am 10 Dez. 2015
Like I just described, I want to change this:
I saw that 'legend' has a property linewidth, but it's the width of the box, that's not what I wanted. By the way, why in Macbook, my default FontSize when plotting is smaller than what it looks like in Windows OS? Anyway to change this? Thanks.

Antworten (1)

dpb
dpb am 8 Dez. 2015
Bearbeitet: dpb am 8 Dez. 2015
Save the optional object_h handle for the line and text objects in the legend axes and set their properties. You'll have to query the array of handles returned via to ensure you're dealing with the lines.
[~,hObj]=legend(....); % return the handles array
hL=findobj(hObj,'type','line'); % get the lines, not text
set(hL,'linewidth',N) % set their width property
  3 Kommentare
Liwei Dai
Liwei Dai am 10 Dez. 2015
Bearbeitet: Liwei Dai am 10 Dez. 2015
Oh, I get it.. By looking into the properties of hObj(2), I saw it's a point in the middle of the line of legend. But why in this manner even if I didn't specify any point type when plotting?
dpb
dpb am 10 Dez. 2015
I'm guessing because there is a marker; it's just empty. IOW legend doesn't special-case the code depending on the choice, it draws the same objects either way; just their content is different. You could test/verify this relatively quickly if it bugs you...as for the actual question raised, it's simplest to just also apply the size change to all objects of the given type rather than worry about which are/aren't of concern.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by