bugGNU Octave - Bugs: bug #42311, colorbar incorrect after setting...

 
 

bug #42311: colorbar incorrect after setting log scale

Submitter:  Thomas Weber <tweber>
Submitted:  Wed 07 May 2014 09:18:10 AM UTC
   
 
Category:  Plotting Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  Wont Fix Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 3.8.1 Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Fri 18 May 2018 11:22:39 PM UTC, comment #8: 

separate bug #53939 filed, about matlab compatibility.

ederag <ederag>
Fri 18 May 2018 11:16:52 PM UTC, comment #7: 

This is a regression in octave-4.4.0.
At least with octave-4.2.1 it was possible to
create a fake axis to attach a standalone colormap
with log scale ticks:


graphics_toolkit("gnuplot")
figure
x = -3:3;
y = x.';
S = exp(-(x.^2 + y.^2));
pcolor(x, y, log10(S))

log_clims = get(gca, "clim");

ax_cb = axes;
set(ax_cb, "visible", "off")
caxis(ax_cb, 10.^(log_clims))
cb = colorbar(ax_cb)
set(cb, "yscale", "log")
set(cb, "yminortick", "on")


But the correct fix is probably to implement the "ColorScale" property:
https://fr.mathworks.com/help/matlab/ref/matlab.graphics.axis.axes-properties.html#budumk7-ColorScale

ederag <ederag>
Fri 16 Dec 2016 09:14:58 PM UTC, comment #6: 

I don't think we need to be anything more than Matlab compatible here.  I checked in a change (http://hg.savannah.gnu.org/hgweb/octave/rev/c9ef5571e11a) which prevents changing to a log scale for the colorbar and issues an error if it is attempted.

Rik <rik5>
Group administrator
Fri 16 Dec 2016 04:11:23 PM UTC, comment #5: 

I have run Rik's test from comment #3 in Matlab. It turned out that newer Matlab releases also do NOT support log-scale colorbars any more!

Therefore I suggest to lower the severity of this bug report to a WISH (for an Octave-only feature) or only do a slight code change to make Octave's behavior Matlab compatible and then CLOSE it.

Here are the details on the Matlab behavior (R2014b):

>> imagesc(eye(100)+1);
h=colorbar()
set (h, 'YScale', 'log')

h =

  ColorBar with properties:

    Location: 'eastoutside'
      Limits: [1 2]
    FontSize: 9
    Position: [0.8194 0.1091 0.0496 0.8155]
       Units: 'normalized'

  Show all properties

Error using matlab.graphics.illustration.ColorBar/set
There is no YScale property on the ColorBar class.

>> get (h)
            AxisLocation: 'out'
        AxisLocationMode: 'auto'
            BeingDeleted: 'off'
                     Box: 'on'
              BusyAction: 'queue'
           ButtonDownFcn: ''
                Children: []
                   Color: [0.1500 0.1500 0.1500]
               CreateFcn: ''
               DeleteFcn: ''
               Direction: 'normal'
               FontAngle: 'normal'
                FontName: 'Helvetica'
                FontSize: 9
              FontWeight: 'normal'
        HandleVisibility: 'on'
                 HitTest: 'on'
           Interruptible: 'off'
                   Label: [1x1 Text]
                  Limits: [1 2]
              LimitsMode: 'auto'
               LineWidth: 0.5000
                Location: 'eastoutside'
                  Parent: [1x1 Figure]
           PickableParts: 'visible'
                Position: [0.8194 0.1091 0.0496 0.8155]
                Selected: 'off'
      SelectionHighlight: 'on'
                     Tag: 'Colorbar'
           TickDirection: 'in'
    TickLabelInterpreter: 'tex'
              TickLabels: {11x1 cell}
          TickLabelsMode: 'auto'
              TickLength: 0.0100
                   Ticks: [1 1.1000 1.2000 1.3000 1.4000 1.5000 1.6000 1.7000 1.8000 1.9000 2]
               TicksMode: 'auto'
                    Type: 'colorbar'
           UIContextMenu: [1x1 ContextMenu]
                   Units: 'normalized'
                UserData: []
                 Visible: 'on'

>>


I will also attach the resulting Matlab figure.

There are also Matlab users complaining about the removal of this feature:


There is still a slight descrepancy between Octave and Matlab in this respect:

  • Matlab throws an error when you try to create a log-scale colorbar. The colorbar stays colored (with a lin-scale).
  • Octave just displays the "log-scale" colorbar but silently takes all the colors out.

Maybe we should also just throw an error and keep the colors lin-scale?


Hartmut <hardy>
Thu 26 Nov 2015 01:16:14 PM UTC, comment #4: 

Sorry, but I don't have access to Matlab anymore.

Thomas Weber <tweber>
Wed 25 Nov 2015 09:45:41 PM UTC, comment #3: 

@Thomas: Can you run the test code in Matlab and upload what the log-scale colorbar image should look like?

The test code was:


imagesc(eye(100)+1);
h=colorbar()
set (h, 'YScale', 'log')



Rik <rik5>
Group administrator
Mon 12 May 2014 10:04:38 PM UTC, comment #2: 

Thanks Pantxo for the workaround, but I don't need it. It is not my own code that is causing the problem, but rather the testsuite of matlab2tikz[1]. The following function can be found among their tests[2]:

function [description, extraOpts] = colorbarLogplot()
switch getEnvironment()
      case 'MATLAB'
          imagesc([1 10 100]);
      case 'Octave'
          % TODO find out what to do for octave here
          description = 'Logscaled colorbar -- unavailable in Octave.';
          extraOpts = {};
          return;
      otherwise
          error( 'Unknown environment. Need MATLAB(R) or Octave.' )
  end
  set(colorbar(), 'YScale', 'log');

  description = 'Logscaled colorbar.';
  extraOpts = {};
end

So, it seems that Matlab can handle a logscaled colorbar. I don't know if the values are correct, but right now I care more about getting the testsuite to run fully on Octave - that's why I am reporting issues I find during these tests.

[1] https://github.com/nschloe/matlab2tikz
[2] https://github.com/nschloe/matlab2tikz/blob/master/test/testfunctions.m

Thomas Weber <tweber>
Wed 07 May 2014 10:53:48 AM UTC, comment #1: 

AFAIK colorbars are built with an image. Non linearly spaced image pixels are not supported neither in octave nor in matlab.
 
A workaround may be to use a flat surface as proposed here [1], to build a custom colorbar. E.g:


imagesc (eye (100) + 1)
h = colorbar ();
hi = get (h, "children");
dat = get (hi, {"xdata", "ydata", "cdata"});
z = [dat{3} dat{3}];
x = dat{1};
y = linspace (dat{2}(1), dat{2}(2), rows (z));
delete (hi)
surface (h, x, y, z, "edgecolor", "none");
axis (h, 'tight')
set (h, 'yscale', 'log')


[1] http://www.mathworks.com/matlabcentral/newsreader/view_thread/321116

Pantxo Diribarne <pantxo>
Group Member
Wed 07 May 2014 09:18:10 AM UTC, original submission:  

Hi,
I am running the 3.8.1 version packaged on Debian (I tried the develoment source, but both default and stable branch didn't build).

Consider the following code:
imagesc(eye(100)+1);
h=colorbar()
set (h, 'YScale', 'log')

After the call to colorbar(), the colorbar() is correct. Resizing it as logarithmic results in a white colorbary (at least with the fltk backend).
I am attaching two saved images, the correct one after the call to colorbar and the incorrect one after the rescaling. Please note that the scaling is adapted to what seems to be correct, but the colorbar is losing all colors.

Thomas Weber <tweber>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #39253:  Matlab(R2014b)_Figure.jpg added by hardy (123KiB - image/jpeg)
file #31327:  colorbar-correct.png added by tweber (14KiB - image/png)
file #31328:  colorbar-incorrect.png added by tweber (14KiB - image/png)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by ederag (Posted a comment)
  • -email is unavailable- added by hardy (Updated the item)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by tweber (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-12-16 rik5 StatusNone Wont Fix
        Open/ClosedOpen Closed
    2016-12-16 hardy Attached File- Added Matlab(R2014b)_Figure.jpg, #39253
    2014-05-07 tweber Attached File- Added colorbar-correct.png, #31327
        Attached File- Added colorbar-incorrect.png, #31328

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code