[Matplotlib-users] double tick labels (bottom and top, but with different labels)

vincent.adrien at gmail.com vincent.adrien at gmail.com
Thu Apr 26 13:46:21 EDT 2018

Hi Pierre,

Related to your last idea, maybe you'll find useful the following formatter:
FuncFormatter(lambda x, pos: f"{x:g}\n{a*x + b:g}")
as one can multiline strings as tick labels, to get something as shown 
in the attached PDF (the whole script is provided as well). I guess that 
one can even do fancier stuff by leveraging the [string formatting 

If you find a better way to achieve what you want, please note that 
there would be at least one person glad to read about ;).


On 04/26/2018 08:03 AM, Pierre Haessig wrote:
> Thanks for all your feedback. Interesting to see that there are indeed
> issues and PR on this topic.
> Looking at issue https://github.com/matplotlib/matplotlib/issues/10976,
> it's makes no relation to the label2
> https://github.com/matplotlib/matplotlib/issues/8181. Seems more like a
> "smart twinx", because the ENH propose that the ticks are not
> necessarily at the same position.
> In my case, since I can use the same xtick positions, I think in the end
> I can get away with just using one FuncFormatter which shows the two
> numbers. Using Adrien's suggestion, I need to try something like
> FuncFormatter(lambda x, pos: f"{x} -- {a*x+b}")).
> Best,
> Pierre
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users at python.org
> https://mail.python.org/mailman/listinfo/matplotlib-users

-------------- next part --------------
A non-text attachment was scrubbed...
Name: example_bis_pierre.py
Type: text/x-python
Size: 548 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20180426/dcdb2d4e/attachment-0001.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: example_bis_pierre.pdf
Type: application/pdf
Size: 151419 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20180426/dcdb2d4e/attachment-0001.pdf>

More information about the Matplotlib-users mailing list