help-octave
[Top][All Lists]
Advanced

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

Re: Legend and LineStyle with Plotyy


From: David Bateman
Subject: Re: Legend and LineStyle with Plotyy
Date: Mon, 08 Sep 2008 14:01:51 +0200
User-agent: Thunderbird 2.0.0.16 (X11/20080725)

Sorry for the delay in responding. Issues with plotyy were one of the things I wanted to address, before a 3.2.0 release of Octave, and so I just stuck your mail on my todo pile. However, I now suspect that your problems are harder to address than I'd thought.

Firstly, I propose the simpler example code

x = 0:0.1:2*pi;
y1 = sin (x);
y2 = exp (x - 1);
[ax, h1, h2] = plotyy (x, y1, x - 1, y2, @plot, @semilogy);
set(h1,'LineStyle','-') set(h2,'LineStyle','--')
legend([h1, h2], 'y1', 'y2')

to demonstrate the issues. The linestyle issue is in fact a limitation of gnuplot and there is not much we can do about it at this point. See the comment in __go_draw_axes__.m that states

   ## FIXME -- linetype is currently broken, since it disables the
   ## gnuplot default dashed and solid linestyles with the only
   ## benefit of being able to specify '--' and get a single sized
   ## dashed line of identical dash pattern for all called this way.
   ## All dash patterns are a subset of "with lines" and none of the
   ## lt specifications will correctly propagate into the x11 terminal
   ## or the print command.   Therefore, it is currently disabled in
   ## order to allow print (..., "-dashed") etc. to work correctly.

   ##    if (! isempty (lt))
   ##      fprintf (plot_stream, " linetype %s", lt);
   ##      found_style = true;
   ##    endif

so as the comment states the gnuplot terminal does not respect the dashed linestyles, and the code to do it (ie 4 lines) is commented out. You can still be dashed lines in the printed plots for your publications with the "-dashed" option to the print command.

As for the legend, there is an incompatibility in how Octave and Matlab treat legends.. In Octave a legend is assoicated with an axis, whereas in Matlab a legend is a new axis object with the keys printed. The Octave way of doing it allows easy interfacing with the gnuplot legend code. The downside of Octave's choice is that you'd need a legend that is different for each of the axes of the plotyy command. In Octave 3.0.2 you might try something like

x = 0:0.1:2*pi;
y1 = sin (x);
y2 = exp (x - 1);
[ax, h1, h2] = plotyy (x, y1, x - 1, y2, @plot, @semilogy);
axes(ax(1))
legend ('y1')
axes(ax(2))
legend('y2','location','southeast')

Regards
David

--
David Bateman                                address@hidden
Motorola Labs - Paris +33 1 69 35 48 04 (Ph) Parc Les Algorithmes, Commune de St Aubin +33 6 72 01 06 33 (Mob) 91193 Gif-Sur-Yvette FRANCE +33 1 69 35 77 01 (Fax) The information contained in this communication has been classified as: [x] General Business Information [ ] Motorola Internal Use Only [ ] Motorola Confidential Proprietary



reply via email to

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