[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Legend question
From: |
Andreas Weber |
Subject: |
Re: Legend question |
Date: |
Wed, 12 Nov 2014 22:06:01 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.2.0 |
Am 12.11.2014 um 21:28 schrieb Nir Krakauer:
> I want to have markers of different sizes in a plot. So far my script
> looks like this:
>
> n = 5;
> x = 1:n;
> y = sin(x);
> p = plot(x, y, "d-"); #plot the line
> l = legend('line');
> set(p(1), "markersize", 0)
> hold on
> for i = 1:n
> plot(x(i), y(i), "marker", "d", "markersize", i^2) #plot each point
> with a different marker size
> endfor
> hold off
>
> The only problem is that once I set the original marker size to zero,
> the legend no longer displays the marker. How can I get a legend entry
> with the line and diamond marker?
I would use plot and afterwards scatter but it looks very quick&dirty
and I'm sure there is a better way :-)
n = 5;
x = 1:n;
y = sin(x);
p = plot(x, y, "d-", "markersize", 0);
l = legend('line');
set(get(l, "children")(1), "markersize", 8)
hold on
s = (1:n).**2;
scatter(x, y, s, "red", "d")
hold off
-- Andy
- Legend question, Nir Krakauer, 2014/11/12
- Re: Legend question,
Andreas Weber <=