Hi, I am converting a Matlab-script to Octave. It uses plotyy, but I
can't get the legend to work, or different linestyles. I always try to
have understandable plots without colors, by using different linestyles.
In this case I want one solid curve, and one dashed curve.
Here is the result of my efforts this far (this is the contents of a
file "air_resistance.m". The problem is that both curves are solid, and
there is no legend. Note that it is only the failure of the legend
command that is the reason for the blue and green colours. By commenting
out legend, the colours are fine.
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.
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.
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