octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #43705] wrong position of ticks on colormap


From: Rik
Subject: [Octave-bug-tracker] [bug #43705] wrong position of ticks on colormap
Date: Tue, 02 Jun 2015 23:01:21 +0000
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0

Update of bug #43705 (project octave):

                  Status:               Need Info => Wont Fix               
             Open/Closed:                    Open => Closed                 

    _______________________________________________________

Follow-up Comment #5:

This is tricky, but ultimately correct as each function, contourf and
colorbar, is doing what it is documented to do.  I also don't see that we can
change it without introducing an incompatibility with Matlab which will
generate further bug reports.

Using the file #32554 that you attached in the following discussion. 
contourf() colors the entire patch object used to represent a contour based on
the Z-level of the lowest point of the contour.  In this case the call,


c=contourf(mX, mY, mF, [0:3]);


will draw 4 contours and the color will be chosen at Z = 0, 1, 2, 3.  When you
call contourf() the 'clim' property for the axis gets set to [0, 3].  Any
values outside that range are clamped to either the minimum or maximum.

The colorbar() function indicates how data values are mapped to color in the
corresponding axis.  The colormap you set happens to have entries and is
equivalent to "gray(4)".  The color axis (caxis() or 'clim' property) runs
from 0 to 3 and there are 4 color levels so each break occurs at (3-0)/4 or
0.75.  This is indeed what the the colorbar from Matlab and Octave show. 
Further, the data values do match.  The first contour is black, which is the
color in the colorbar shown for 0.  The second contour is dark grey (z=1),
which is the color for any value between 0.75 and 1.5.  The third contour is
light grey (z=2), which is the color for any value between 1.5 and 2.25.  The
final contour is white which is the color for any value from 2.25 to Infinity
since any value greater than 3 is clamped to 3.

It's perhaps easier to see with this set of commands


c=contourf(mX, mY, mF, [0:0.5:3]);
clabel (c)
colorbar


which draws contours every 0.5 and shows that each contour is picking up the
correct color mapping.

If you are after a particular presentation effect then I would use the longer
form of colorbar, 'hc = colorbar', to get a handle to the axes object used to
implement the colorbar.  Then you can manipulate the properties however you
like.

For example,


close all
colormap (gray (4));
[X,Y] = meshgrid (0:0.1:4);
Z = Y;
c = contourf (X, Y, Z, [0:3]);
clabel (c)
hc = colorbar;
set (hc, "ytick", [0:0.75:3], "yticklabel", {"0", "1", "2", "3"})


will produce the picture I think you were hoping for.


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?43705>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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