octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Legend compatibility help


From: Ben Abbott
Subject: Re: Legend compatibility help
Date: Wed, 02 Oct 2013 13:47:21 -0400

On Oct 2, 2013, at 12:24 PM, Rik wrote:

> 10/2/13
> 
> Could someone with access to Matlab run the following?
> 
> ## Test if there is a listener on DisplayName property
> h = plot (rand (3,3));
> hl = legend ();

The plot handles need to be passed to the legend command.

        hl = legend (h);

> ## At this point, legend is data1, data2, data3

Correct.

> set (h(1), 'DisplayName', 'This is a Long String')
> ## Is legend updated?

Yes

> ## What about doing?
> legend hide
> legend show
> ## Is legend updated now?

Yes

> ## What does Matlab display for surface objects?
> z = peaks ();
> surf (z);
> hl = legend ("surf1");
> print -dpng surfleg.png

The legend icon is a patch whose color corresponds to the caxis mid-point
> 
> ## Similarly, what does Matlab display for contour objects?
> contourc (z);
> hl = legend ("contour1");
> print -dpng contourleg.png

A simple contour icon ... maybe interp ([0 1], caxis(), [0 0.5 0; 0.5 1 0.5; 0 
0.5 0]) ?

> Thanks in advance,
> Rik

Rik,

It is necessary to pass the handles (implicitly or explicitly) to the legend 
command.  I modified your script to generate plots for each case.

%% Test if there is a listener on DisplayName property
h = plot (rand (3,3));
hl = legend (h);
print_pdf plot1.pdf
%% At this point, legend is data1, data2, data3
set (h(1), 'DisplayName', 'This is a Long String')
%% Is legend updated?
print_pdf plot2.pdf

%% What about doing?
legend hide
legend show
%% Is legend updated now?
print_pdf plot3.pdf

%% What does Matlab display for surface objects?
z = peaks ();
surf (z);
hl = legend ('surf1');
print_pdf plot4.pdf

%% Similarly, what does Matlab display for contour objects?
contour (z);
hl = legend ('contour1');
print_pdf plot5.pdf

Attachment: plot5.pdf
Description: Adobe PDF document

Attachment: plot4.pdf
Description: Adobe PDF document

Attachment: plot3.pdf
Description: Adobe PDF document

Attachment: plot1.pdf
Description: Adobe PDF document

Attachment: plot2.pdf
Description: Adobe PDF document



reply via email to

[Prev in Thread] Current Thread [Next in Thread]