some plotting bugs

John W. Eaton jwe at octave.org
Thu Jul 9 11:51:31 CDT 2009


On  9-Jul-2009, Jonathan Stickel wrote:

| Ben Abbott wrote:
| > On Thursday, July 09, 2009, at 10:23AM, "Jonathan Stickel"
| > <jjstickel at vcn.com> wrote:
| >> I am noticing some bugs in while trying to make a simple plot in 
| >> Octave-3.2.0:
| >> 
| >> 1. 'legend ("location","outside")' does not put the legend outside
| >> 
| >> 2. 'set (findall (gcf, "-property", "fontsize"), "fontsize", 20)'
| >> does not change the font of the legend
| >> 
| >> 3. 'print -deps -tight file.eps' does not make the bounding box
| >> tight
| >> 
| >> The following code demonstrates these bugs:
| >> 
| >> plot(1:10,1:10) xlabel("x") ylabel("y") legend("test") legend
| >> ("location","outside") set (findall (gcf, "-property", "fontsize"),
| >> "fontsize", 20) print -deps -tight test32.eps
| >> 
| >> Thanks, Jonathan
| >> 
| > 
| > Regarding the legend bugs ... when using the gnuplot backend the
| > legend is actually a gnuplot key box, and does not presently have its
| > own handle or properties. To fix these bugs, the legend needs to be
| > reimplemented as an axis object.
| > 
| 
| Yes, I am using gnuplot; should have mentioned that.  As a workaround 
| for the legend font size, I found that it still works to set it while 
| printing with 'F:SIZE'.  I'm not sure why setting the location outside 
| no longer works, but all the other location strings are fine; I recall 
| it working in 3.0.x.

Run the following commands:

  plot(1:10, 1:10);
  legend({"hello world"}, "location", "northeastoutside")
  drawnow ("x11", "/dev/null", 0, "debug.gp")

Look at the resulting debug.gp file.  You will see that it includes
the line

  set key outside right top nobox noreverse ;

But we also use

  set multiplot;
  set origin 0, 0
  set size 1, 1
  set tmargin 0;
  set bmargin 0;
  set lmargin 0;
  set rmargin 0;
  set origin 0.13, 0.11;
  set size 0.775, 0.815;

so I think gnuplot is not properly accounting for these sizes when it
places the key.

If there is a simple solution that will cause gnuplot to do the right
thing, then great.  But instead of working too hard on a fix like
that, I think it would be better to make the legend a separate axes
object and place the elements in the legend individually, as separate
graphics objects (text and line).  Then we will have complete control
over the location and appearance of the legend and also gain Matlab
compatibility.  Getting the placement right may require some
adjustments to the "set size" and "set origin" commands as well, so it
may be tricky to get it right.  It would be great if someone would
take on this task and submit a patch.

jwe


More information about the Bug-octave mailing list