bugGNU Octave - Bugs: bug #48562, "(xy)axislocation"...


bug #48562: "(xy)axislocation" should support "origin"

Submitter:  Markus Mützel <mmuetzel>
Submitted:  Tue 19 Jul 2016 03:55:31 PM UTC
Category:  Plotting with OpenGL Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment (Rich Markup)

Comment Type & Canned Response:


( Jump to the original submission )

Sun 29 Jan 2017 07:07:36 PM UTC, comment #11: 

I committed your final patch dealing with axislocation here (http://hg.savannah.gnu.org/hgweb/octave/rev/868daa374c49).

The only important thing I had to do was shorten lines > 80 characters by breaking them at appropriate points in the code.

Rik <rik5>
Project Administrator
Tue 15 Nov 2016 10:26:02 PM UTC, comment #10: 

The attached patch should now be compatible to Matlab.

(file #38982)

Markus Mützel <mmuetzel>
Project Member
Mon 14 Nov 2016 06:59:49 PM UTC, comment #9: 

I checked in Matlab. It moves the axes to the border which is closer to 0 for logarithmic axes. Will update the logic when I find some time.

Markus Mützel <mmuetzel>
Project Member
Sat 05 Nov 2016 01:27:02 PM UTC, comment #8: 

Faster than expected. Attached is a patch that should cover the issues.

I am not sure what should happen for a logarithmic plot with the other axislocation set to origin.
Without doing anything specifically, the axis landed at 1 (10^0) or -1. So I went with this. I hope this is OK. I'll test in Matlab when I have time next week.

(file #38894)

Markus Mützel <mmuetzel>
Project Member
Fri 04 Nov 2016 07:34:20 PM UTC, comment #7: 

That sounds good, thanks for investigating so thoroughly.

Rik <rik5>
Project Administrator
Fri 04 Nov 2016 07:01:33 PM UTC, comment #6: 

Rik, thank you for reviewing and pushing the patch.

The values of "ytick" does not change in your example from comment #5 in Matlab. However, some "yticklabel" are empty. It looks like the first and the last ytick are not plotted (independent of whether 'xaxislocation' is 'top', 'bottom' or 'origin' or whether the box is on or off). This is probably so that the labels do not overlap with the (potential) box. I think we can do better than Matlab in this respect and only omit those labels that really coincide with the box or the other axis.

I also noticed that the labels and ticks switch sides once the origin is higher than half the axis height.

Furthermore, the axis is drawn at the border if the origin is outside the axis limits.

I think I can post a patch for these issues within a week or so...

Markus Mützel <mmuetzel>
Project Member
Tue 01 Nov 2016 11:07:25 PM UTC, comment #5: 

This is certainly a big improvement.  I applied the patch here (http://hg.savannah.gnu.org/hgweb/octave/rev/074765d5c83b).

One thing to note is that the labels at the origin overlap the axes line now.  A simple workaround is to manually set the ticks to exclude the origin.  But it might be nice to have this done automatically.  This could be done either in graphics.cc where the ticks are calculated, or in gl-render.cc where the ticks are displayed.  In either case, there is a bit of mixing between the X and Y axes.  For example, if the X axes is "top", then it is the maximum ytick which needs to be removed.

Example from 'demo axis 13'

 x = -10:0.1:10;
 y = sin (x)./(1+abs (x)) + 0.1*x - 0.4;
 plot (x, y);
 set (gca, "xaxislocation", "top");
 set (gca, "yaxislocation", "origin");
 box off;
 title ({"no plot box", "xaxislocation = top, yaxislocation = origin"});

Corrected by

set (gca, "ytick", get (gca, "ytick")(1:end-1));

What does Matlab return for

 x = -10:0.1:10;
 y = sin (x)./(1+abs (x)) + 0.1*x - 0.4;
 plot (x, y);
 get (gca, 'ytick')
 set (gca, 'xaxislocation', 'top');
 set (gca, 'yaxislocation', 'origin');
 get (gca, 'ytick')

That might tell us whether the ticks are being chosen differently, or whether it is only the display of the ticks which is suppressed.

Rik <rik5>
Project Administrator
Thu 15 Sep 2016 05:08:28 AM UTC, comment #4: 

@Markus: Thanks for the patch.  Since this is more of a feature addition, rather than a bug fix, I think it will be committed after the 4.2 release.

Rik <rik5>
Project Administrator
Mon 12 Sep 2016 04:56:02 PM UTC, comment #3: 

Attached please find a patch that adds support for "(xy)axislocation" being set to "origin" for the OpenGL renderer.

The results still differ slightly from Matlab. But at least it can compare to the "gnuplot" toolkit. Please, see demo axis 9-13 for the results.

I am not sure whether I should also add support for "zero" which is already marked as deprecated anyway.

(file #38482)

Markus Mützel <mmuetzel>
Project Member
Tue 16 Aug 2016 09:34:51 PM UTC, comment #2: 

Thank you for your patch.
I've mentioned the changes to NEWS and pushed this cset:

The changes to axis.m were already been done in http://hg.savannah.gnu.org/hgweb/octave/rev/283d8dfcad37

Now please go ahead and also change the opengl renderer to support it :-)

Andreas Weber <andy1978>
Project Member
Tue 19 Jul 2016 05:28:15 PM UTC, comment #1: 

Attached is a changeset for the easy part of this bug.

(file #37952)

Markus Mützel <mmuetzel>
Project Member
Tue 19 Jul 2016 03:55:31 PM UTC, original submission:  

In recent Matlab versions, it is possible to set "xaxislocation" (and/or "yaxislocation") to "origin" [1] which does essentially the same what gnuplot does currently when these properties are set to "zero".

I think I can upload the easy part shortly. That would probably be:

  • Add "origin" to the list of accepted values for "(xy)axislocation".
  • Deprecate "zero" (for Octave 4.6?).
  • Add the synonym to "__gnuplot_draw_axes__.m".

I'll keep the hard part - implementing it for the opengl renderer - probably for a later part if no one else wants to give it a go earlier.

[1] http://de.mathworks.com/help/matlab/examples/controlling-axis-location.html

Markus Mützel <mmuetzel>
Project Member


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

Attach Files:


Depends on the following items: None found

   bug dependencies.


Carbon-Copy List
  • -email is unavailable- added by rik5 (Updated the item)
  • -email is unavailable- added by andy1978 (Posted a comment)
  • -email is unavailable- added by mtmiller (Updated the item)
  • -email is unavailable- added by mmuetzel (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 project members can vote.





    Follow 11 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-01-29 rik5 StatusPatch Submitted Fixed
        Open/ClosedOpen Closed
    2017-01-11 mmuetzel CategoryPlotting Plotting with OpenGL
        StatusIn Progress Patch Submitted
    2016-11-15 mmuetzel Attached File- Added bug48562_axislocation_origin_v2.patch, #38982
    2016-11-14 rik5 Dependencies- bugs #47966 is dependent
    2016-11-05 mmuetzel Attached File- Added bug48562_axislocation_origin_ticks.patch, #38894
    2016-09-12 mmuetzel Attached File- Added bug48562_axislocation_origin_opengl.patch, #38482
    2016-08-17 rik5 StatusPatch Submitted In Progress
    2016-07-19 mtmiller StatusNone Patch Submitted
    2016-07-19 mmuetzel Attached File- Added axislocation_origin_part1.patch, #37952

    Back to the top

    Powered by Savane 3.9