bugGNU Octave - Bugs: bug #55640, Feature Request: Adjust tick...


bug #55640: Feature Request: Adjust tick locations and labels based on text extents and size of axes

Submitter:  Muhali <muhali>
Submitted:  Mon 04 Feb 2019 10:24:34 AM UTC
Category:  Plotting Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Feature Request
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup

Sun 10 Mar 2019 11:19:11 PM UTC, comment #3: 

@Pantxo: I haven't looke at the code, but your approach sounds right.

Rik <rik5>
Group administrator
Sun 10 Mar 2019 09:18:59 PM UTC, comment #2: 

@Rik: The code for computing the axes "tighinset" property already partly extracts the extent of labels. Couldn't we refactor this peace of code and optimize the number of ticks by the way (and eventually fix bug #53235)?

Pantxo Diribarne <pantxo>
Group Member
Mon 04 Feb 2019 05:58:09 PM UTC, comment #1: 

This is a feature request.  I've changed the title to reflect the true issue.  I agree, this is a bothersome thing.  The issue is that Octave chooses limits for the plot based on the data, and then tries to divide the axes into five divisions which will result in 6 ticks and ticklabels.

If the axes is particularly small, such as in a subplot, or the labels are particularly long, such as with a large fontsize, then they will overlap.  What the code needs to do is interact with the OpenGL renderer and determine the size ("extent" property) of the ticklabels.  If it determines that they overlap then it has to go back and select fewer ticks.  The issues is that these two pieces of code are in very different parts of Octave so connecting them will not be straightforward.

The current workaround is to manually set ticks and ticklabels.  This isn't all that bad, but is annoying.

This isn't about subplots, it applies to any axes object.  Here is sample code which reveals the problem by shrinking the width of the axes object.

plot (1e3:1e3:1e4, 1:10);
get (gca, 'xtick')
pos = get (gca, 'position');
pos(3) = pos(3) / 4;
set (gca, 'position', pos)
get (gca, 'xtick')

When run in Octave, the ticks are at

ans =

       0    2000    4000    6000    8000   10000

When run in Matlab, the ticks are initially at [1000, 2000, 3000, ..., 10000].  After the axes is shrunk, there are only three ticks at [0, 5000, 10000].

Rik <rik5>
Group administrator
Mon 04 Feb 2019 10:24:34 AM UTC, original submission:  

I'm not sure if this is a bug, but it's at least a compatibility issue to ML, and moreover a thing that has bothered me for a long time.

octave does not adjust axis properties (limits, ticks, labels) when doing a subplot instead of a normal plot. If one chooses e.g. subplot(4,4,1) and a case with long numbers, such as


the plot becomes unreadable.

Muhali <muhali>


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

Attach Files:

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 pantxo (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by muhali (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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-02-04 rik5 Item GroupNone Feature Request
        StatusNone Confirmed
        Release5.0.90 dev
        Summaryadjusting axis properties for subplots Feature Request: Adjust tick locations and labels based on text extents and size of axes

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code