Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Drawing a Legend in a graph

Subject: Drawing a Legend in a graph

From: Yannos M

Date: 3 Nov, 2012 16:04:08

Message: 1 of 2

Hi,

I have made a code drawing grids with lines of different LineWidths. However, I am not able to make a legend showing the lines with a number next to them corresponding to the LineWidth.
Can anybody help me out with this?

Thanks a lot.

Yannos

Subject: Drawing a Legend in a graph

From: Pekka Kumpulainen

Date: 4 Nov, 2012 13:49:09

Message: 2 of 2

"Yannos M" wrote in message <k73f9o$gg7$1@newscl01ah.mathworks.com>...
> Hi,
>
> I have made a code drawing grids with lines of different LineWidths. However, I am not able to make a legend showing the lines with a number next to them corresponding to the LineWidth.
> Can anybody help me out with this?
>
> Thanks a lot.
>
> Yannos

Without knowing what exactly is the problem, here is an example that might help
for ii = 1:5
    hl(ii) = line([0 1],[0 ii], ...
        'LineWidth',ii, ...
        'DisplayName',num2str(ii));
end
legend(hl)

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us