[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Compatible plotyy and colorbar (or Confusion about Position, OuterPo
From: |
Ben Abbott |
Subject: |
Re: Compatible plotyy and colorbar (or Confusion about Position, OuterPosition and ActivePositionProperty) |
Date: |
Sun, 12 Oct 2008 16:14:54 -0400 |
On Oct 12, 2008, at 3:35 PM, David Bateman wrote:
My colorbar/plotyy changes were recently added, and when
implementing it I had some issues with the treatment of the
position, outerposition and activepositionproperty properties of
axes objects.
The behavior in matlab is described on the page
http://www.mathworks.com/access/helpdesk/help/techdoc/creating_plots/f1-32495.html
The actual size of the plot window is always determined by Position,
whereas the space allocated for the plot window and text is always
determined by OuterPosition. The ActivePositionProperty property is
only used to determine how the difference between Position and
OuterPosition are changed if the window is resized, so as gnuplot at
the moment gives no means to feedback this information (or rather
octave's interface to gnuplot), ActivePositionProperty is of no use.
Now how Octave treated these values before my change is that
* Octave's gnuplot interface uses OuterPosition in almost all cases
to define the position as gnuplot's origin/size paradigm bests fits
with use of OuterPosition. The exception is the plotyy function
where currently ActivePositionProperty is abused to force gnuplot to
have overlaying plots.
* The graphics.cc (void axes::properties::sync_positions (void))
function maintains a constant relationship between Position and
OuterPosition. This is incorrect as adding a colorbar maintains the
OuterPosition and adjusts position.
* The subplot function uses the OuterPosition property to recognize
subplots that are to an existing axis.
So the correct implementation of the colorbar/plotyy function means
that we'll have to fix this to be more Matlab like. Basically what
this means is that
* Octave should base its decision on the window placement in the
backends solely on the position property of the axis. This means
that the intelligence for the axis size needs to be placed in Octave
and not gnuplot.
* The synchronization code between the position and outerposition
properties should be disabled till it is more intelligent and
capable of handling colorbars. For now this means that space for the
title, axis labels, legend, etc need to be hard coded into the
default position of the axes.
I did that in the applied patch and fixed a couple of other issues
and now have a fully working plotyy and colorbar command. In
particular the mathworks example
surf(peaks(30))
colorbar('YTickLabel',
{'Freezing','Cold','Cool','Neutral','Warm','Hot','Burning','Nuclear'})
works as expected when it didn't previously. However, the confusion
about the Position, OuterPosition and ActivePositionProperty remains
in the sense that the intelligence to calculate the size of the plot
to allow for the axis labels, etc isn't in Octave and so its
possible to make the plots label either fall outside the boundaries
of the plot. At some point, we'll need to add this intelligence to
Octave.
Regards
David
David,
I see a problem that appears to might be related to jwe's swtich to
column vectors for handles.
For plotyy please try the demo below. It is the same as the one in
plotyy with "subplot(221)" added as the first line.
%!demo
%! subplot(211)
%! x = 0:0.1:2*pi;
%! y1 = sin (x);
%! y2 = exp (x - 1);
%! ax = plotyy (x, y1, x - 1, y2, @plot, @semilogy);
%! xlabel ("X");
%! ylabel (ax(1), "Axis 1");
%! ylabel (ax(2), "Axis 2");
Using jwe's archive I get
error: get: invalid handle (= 3.42134e+180)
error: called from:
error: /Users/bpabbott/Development/mercurial/octave-3.1.51/scripts/
plot/__go_draw_axes__.m at line 1314, column 9
error: /Users/bpabbott/Development/mercurial/octave-3.1.51/scripts/
plot/__go_draw_axes__.m at line 271, column 8
error: /Users/bpabbott/Development/mercurial/octave-3.1.51/scripts/
plot/__go_draw_figure__.m at line 59, column 8
error: /Users/bpabbott/Development/mercurial/octave-3.1.51/scripts/
plot/gnuplot_drawnow.m at line 68, column 5
The problems do not end there
octave:6> clf
error: delete: invalid graphics object (= -16.9272)
error: called from:
error: /Users/bpabbott/Development/mercurial/octave-3.1.51/scripts/
miscellaneous/delete.m at line 40, column 1
error: /Users/bpabbott/Development/mercurial/octave-3.1.51/scripts/
plot/clf.m at line 37, column 9
Notice this second error references a different handle.
I also notice that the xlabe("X") command changes the orientation of
the children for the axis from a column vector to a row vector. For
the row vector the second element is invalid.
btw, my response to this is rather quick because I was coincidentally
working on plotyy as well. My effort was to get it to work with subplot.
Ben