xtick label offsets

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

xtick label offsets

Matthew Bradley
All:

I'm working on offsetting xticks and xtick labels that are calculated and set by a function. In some cases the positions of the calculated xticks overlap (such as in the attached png) and I want to space them apart instead of making them visible by rotating the label text. I've tried adding an additional tick mark and setting the label of the additional tick mark to be the value I want, and set the labels of the overlapping tick marks to be blank text. This gets the labels where I want them but then I can't get rid of the extra tickmarks introduced. I've looked through the online documentation for Tick and XTick instances and can't find a command that affects only the tickmark, and doesn't make both the tickmark and the label disappear. 

Is there a way to make a single tickmark go away and keep its label visible?

Alternatively is there a way to adjust the x position of xtick labels by a certain amount using something like texts set_x() function?

If anyone more familiar with text and tick properties knows a way to do this then please let me know! Otherwise I will look into using figure annotations to brute force it to look the way I want it to.


​Thanks!​
Matthew Bradley

_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users

figure_8_reproduced.png (416K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: xtick label offsets

Jody Klymak
Hi Matthew,

I’d just use `ax.text` for this.  If you are fussy about the y-position of the labels then you can fetch the y-coordinate of one of the x-ticks.

Cheers,  Jody

On 16 Jul 2018, at 09:16, Matthew Bradley <[hidden email]> wrote:

All:

I'm working on offsetting xticks and xtick labels that are calculated and set by a function. In some cases the positions of the calculated xticks overlap (such as in the attached png) and I want to space them apart instead of making them visible by rotating the label text. I've tried adding an additional tick mark and setting the label of the additional tick mark to be the value I want, and set the labels of the overlapping tick marks to be blank text. This gets the labels where I want them but then I can't get rid of the extra tickmarks introduced. I've looked through the online documentation for Tick and XTick instances and can't find a command that affects only the tickmark, and doesn't make both the tickmark and the label disappear. 

Is there a way to make a single tickmark go away and keep its label visible?

Alternatively is there a way to adjust the x position of xtick labels by a certain amount using something like texts set_x() function?

If anyone more familiar with text and tick properties knows a way to do this then please let me know! Otherwise I will look into using figure annotations to brute force it to look the way I want it to.







_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users