bugGNU Octave - Bugs: bug #67302, Alignment of YTick labels with...

 
 

bug #67302: Alignment of YTick labels with set()

Submitter:  José Luis García Pallero <jgpallero>
Submitted:  Thu 10 Jul 2025 12:01:30 PM UTC
   
 
Category:  Plotting Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Feature Request
Status:  Fixed Assigned to:  None
Originator Name:  jgpallero Open/Closed:  * Closed
Release:  * 10.2.0 Operating System:  * Any
Fixed Release:  11.1.0 (current default) Planned Release:  11.1.0 (current default)
* Mandatory Fields

Post a Comment

Add a New Comment Rich Markup
   

Discussion

Sun 24 Aug 2025 09:04:54 PM UTC, comment #5: 

Thanks, Matlab is doing just what I expected which is not altering the user's values in any way.

I changed Octave not to strip leading and trailing spaces from ticklabels before rendering.  See https://hg.savann ... /rev/ac0e94eb951a.

Marking as Ready for Test.

Rik <rik5>
Group administrator
Fri 22 Aug 2025 09:10:03 PM UTC, comment #4: 

Rik, attached you can see the result in Matlab

(file #57565)

José Luis García Pallero <jgpallero>
Fri 22 Aug 2025 08:29:37 PM UTC, comment #3: 

This is a one-line fix.  Currently Octave is stripping both leading and trailing spaces before rendering the text of labels.

Could you try this code in Matlab to see if they also leave in place trailing spaces?


close all;
set (gca, 'yticklabel', {'1', '2 ', '3  ', '4   ', '5    ', '6     '})


If they are not stripping spaces then each of the numbers will be progressively farther from the Y-axis.

Rik <rik5>
Group administrator
Sat 12 Jul 2025 08:06:39 PM UTC, comment #2: 

It might be enough to have Matlab compatibility here.

I've verified that the axes property 'YTickLabel' contains the text with the spaces.  This means it is not the Octave interpreter that is removing the space character, although this still be the case in the code that handles OpenGl.

Rik <rik5>
Group administrator
Thu 10 Jul 2025 01:29:54 PM UTC, comment #1: 

I don't know if it is possible to change the tick direction for a single axis. But you can change it for all axes with

set(gca,'TickDir','out');


When it comes to indentation, you could probably play around with Unicode whitespace characters. E.g., you could do the following that doesn't depend on the .m file encoding:

enquad = native2unicode (typecast(uint16(8192), 'uint8'), 'UTF-16LE');
plot([-2 2],[-2 2]);
set(gca,'FontSize',20);
set(gca,'YAxisLocation','right');
set(gca,'YTick',[-2 -1 0 1 2],'YTickLabel',[{'-2','-1'}, strcat(enquad, {'0', '1', '2'})]);
set(gca,'FontName','Courier');


Anyway, it might be better to ask on the Octave forum when you have questions about using Octave:
https://octave ... scourse.group/

I don't know if there is anything actionable that I missed in this report.

Markus Mützel <mmuetzel>
Group administrator
Thu 10 Jul 2025 12:01:30 PM UTC, original submission:  

See this piece of code:

plot([-2 2],[-2 2]);
set(gca,'FontSize',20);
set(gca,'YAxisLocation','right');

It changes the Y tick labels to the right side of the figure, but the ticks are left aligned. I want to have them right aligned for aesthetics. I can do that as

plot([-2 2],[-2 2]);
set(gca,'FontSize',20);
set(gca,'YAxisLocation','right');
set(gca,'YTick',[-2 -1 0 1 2],'YTickLabel',{'-2','-1',' 0',' 1',' 2'});
set(gca,'FontName','Courier');

Note that all non-negative ticks have a space before in order to match their counterparts '-' sign. Well, this trick works in Matlab, but not in Octave (actually it depends on the font used --see that in the example I used Courier as it is monospaced--, but in any case Octave does not take into account the preceeding blanks and Matlab takes, so although the font not be monospaced the result is not left aligned).

It would be nice the same behavior in Octave

José Luis García Pallero <jgpallero>

 

Attached Files

Attached Files
file #57565:  figure.pdf added by jgpallero (1.7KiB - application/pdf)

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

Attach Files:
   
   
Comment:
   

 

Dependencies

This item does not depend on any other items.

No items depend on this one.

 

Mail Notification Carbon-Copy List

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

    Votes

    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.

     

    History

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2025-08-28 rik5 StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2025-08-24 rik5 StatusNeed Info Ready For Test
        Fixed ReleaseNone 11.1.0 (current default)
        Planned ReleaseNone 11.1.0 (current default)
    2025-08-22 jgpallero Attached File- Added figure.pdf, #57565
    2025-08-22 rik5 StatusNone Need Info

    Back to the top

    Powered by Savane 3.16-ed84.
    Corresponding source code