bugGNU Octave - Bugs: bug #39393, set (ax, 'xscale', 'log') doesn't...

 
 

bug #39393: set (ax, 'xscale', 'log') doesn't result in full logarithmic axis

Submitted by:  Ronald <revdmeer>
Submitted on:  Tue 02 Jul 2013 07:02:41 AM UTC  
 
Category:  Plotting Severity:  3 - Normal
Priority:  3 - Low Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  Closed
Release:  dev Operating System:  Any

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

( Jump to the original submission)

Sun 20 Dec 2020 06:02:11 PM UTC, comment #9: 

Seems to work now.

Closing as fixed.

Markus Mützel <mmuetzel>
Project Member
Wed 09 Dec 2020 06:27:24 PM UTC, comment #8: 

The update chain was triggered. But updating the axis was skipped when it shouldn't have been.
I pushed a change here that should fix the issue:
https://hg.savannah.gnu.org/hgweb/octave/rev/fbf6d132dec7

Marking as ready for test.

Markus Mützel <mmuetzel>
Project Member
Tue 08 Dec 2020 07:10:33 PM UTC, comment #7: 

@Markus: That's a good idea.  There is often a routine update_XXX in the C++ that can be called or not after a property is updated.  Check graphics.in.h and the set of letter codes that are defined in genprops.awk.  For the axes "Xscale" property the definition is

      radio_property xscale alu , "{linear}|log"

The 'l' would seem to suggest that "update_axis_limits ("NAME");" is called after the property is modified.  But, maybe something is going wrong.

Rik <rik5>
Project Administrator
Tue 08 Dec 2020 05:51:29 PM UTC, comment #6: 

The ticks update with the last line of the following code:

[ax, h1, h2] = plotyy(1:100, 1:100, 1:100, (1:100)/2);
set(ax, 'XScale', 'log')
set(ax, 'XLimMode', 'auto')

Many other property changes also lead to updated axes ticks.
Maybe an update function needs to be called when the axis scale changes.
I'll try to have a look at it.

Markus Mützel <mmuetzel>
Project Member
Tue 08 Dec 2020 02:55:28 AM UTC, comment #5: 

examples in comment #2 still produce different output to matlab in Octave 6.1.0 (compared with Matlab 2020b)

Nicholas Jankowski <nrjank>
Wed 16 Nov 2016 09:03:03 PM UTC, comment #4: 

Updating release, bug is still present in the development version of Octave (4.3.0+).

Mike Miller <mtmiller>
Project Administrator
Wed 03 Jul 2013 02:39:12 PM UTC, comment #3: 

With your extra information I re-opened the bug report.  I'm lowering the priority because there is a workaround.  I also changed the type to "Matlab Compatibility" rather than "Incorrect Result".  Finally, I re-titled the report since this isn't about plotyy, per se, but rather the behavior of Octave when 'xscale' is changed.

Rik <rik5>
Project Administrator
Wed 03 Jul 2013 08:21:55 AM UTC, comment #2: 

Hello Rik,

Thank you for pointing out the "@semilogx" option for me. This does indeed do what i need. However the original bug is still valid.

Octave should threat XScale like both Matlab and gnuplot threat it. Which is that XTick, XTickLabel and Xminortick values should be updated when XScale changes value.

In Matlab there seems to be no change in behavior between

[ax, h1, h2]=plotyy(1:100,1:100,1:100,(1:100)/2)
set(ax(1),'XScale','log');
set(ax(2),'XScale','log');

and

 [ax, h1, h2]=plotyy(1:100,1:100,1:100,(1:100)/2, @semilogx, @semilogx)

In Matlab (2012b version):

[ax, h1, h2]=plotyy(1:100,1:100,1:100,(1:100)/2);
get(ax(1),'XTick')
ans =

     0    10    20    30    40    50    60    70    80    90   100
get(ax(1),'XTickLabel')
ans =
0
10
20
30
40
50
60
70
80
90
100
get(ax(1),'Xminortick')
ans =
off
set(ax,'XScale','log')
get(ax(1),'XTick')
ans =
     1    10   100
get(ax(1),'XTickLabel')
ans =
0
1
2
get(ax(1),'Xminortick')
ans =
on

In Matlab when XTickmode=manual, only the Xminortick changes when XScale changes. XTick values and XTickLabel remain unchanged.

Ronald <revdmeer>
Tue 02 Jul 2013 11:19:14 PM UTC, comment #1: 

I think there may be some confusion about the difference between logarithmic scaling and a logarithmic axis.  Setting the 'Xscale' to log results in logarithmic spacing for the existing 'Xtick' values.

A logarithmic axis is really a collection of options which together produce what one thinks of as a log axis.  These include:

Xscale = log
Xtick = logarithmic values such as [1 10 100]
Xminortick = on
Xtickmode = auto

'help plotyy' gives an example of using a linear y-axis and a logarithmic y-axis together in plotyy.  You can get a logarithmic x-axis with

[ax, h1, h2]=plotyy(1:100,1:100,1:100,(1:100)/2, @semilogx, @semilogx)

Or you can set all of the properties I mentioned on each of the axes.

This, anyways, is how Octave treats Xscale.  If you have access to Matlab you might verify that setting Xscale to 'log' only scales the axis but does not produce the other changes such as the Xminorticks that are associated with a logarithmic axis.

Rik <rik5>
Project Administrator
Tue 02 Jul 2013 07:02:41 AM UTC, original submission:  

By default a plotyy results in linear axes. This can be changed to logarithmic e.g. with:

set(ax,'XScale','log');

In the fltk backend the ticks will remain linear instead of logarithmic. In the gnuplot backend the visual result is correct. However when getting the XTick values from the axis with e.g.:

get(ax(1),'XTick')

... still gives the linear values, instead of the logarithmic values.

To reproduce with the fltk backend:

graphics_toolkit fltk
figure
[ax, h1, h2]=plotyy(1:100,1:100,1:100,(1:100)/2)
set(ax(1),'XScale','log');
set(ax(2),'XScale','log');

The XTick position are now linear, but they should be logarithmic.

To reproduce with the gnuplot backend:

graphics_toolkit gnuplot
figure
[ax, h1, h2]=plotyy(1:100,1:100,1:100,(1:100)/2)
set(ax(1),'XScale','log');
set(ax(2),'XScale','log');
get(ax(1),'XTick')
ans =

     0    20    40    60    80   100
get(ax(1),'XTickLabel')
ans =
{
  [1,1] = 0
  [1,2] = 20
  [1,3] = 40
  [1,4] = 60
  [1,5] = 80
  [1,6] = 100
}

Now the plot is visually correct, with XTick labels at 1, 10 and 100. However answer from the above get commands still incorrect.

Ronald <revdmeer>

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by nrjank (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by revdmeer (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

     

     

    Follow 12 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-12-20 mmuetzel StatusReady For Test => Fixed
        Open/ClosedOpen => Closed
    2020-12-09 mmuetzel StatusConfirmed => Ready For Test
    2020-12-08 mtmiller Carbon-CopyRemoved 80942 => -
    2016-11-16 mtmiller Release3.6.4 => dev
    2013-07-03 rik5 Priority5 - Normal => 3 - Low
        Item GroupIncorrect Result => Matlab Compatibility
        StatusInvalid => Confirmed
        Open/ClosedClosed => Open
        Summaryplotyy log scale results in linear ticks => set (ax, 'xscale', 'log') doesn't result in full logarithmic axis
    2013-07-02 rik5 StatusNone => Invalid
        Open/ClosedOpen => Closed

    Back to the top


    Powered by Savane 3.6