0

I'm trying to make one plot with multiple y-axis with this example: https://matplotlib.org/faq/howto_faq-1.pdf

Here is the link with the source code https://matplotlib.org/faq/howto_faq.html

I'm a little dissatisfied about the alignment of the right y-axis.

1.00
0.50
0.00
-0.50
-1.00

Is it possible to change the alignment and get the numbers in line, like:

 1.00
 0.50
 0.00
-0.50
-1.00

Is there any way to add leading spaces to tick marks?

Mohammad Athar
  • 1,825
  • 1
  • 14
  • 30
Moulli
  • 1

1 Answers1

0

Use the following three lines to set horizontal alignment and move labels outside the plot:

for label in ax2.get_yticklabels():
    label.set_horizontalalignment('right')
ax2.get_yaxis().set_tick_params(pad=40)
Y. Luo
  • 5,347
  • 1
  • 17
  • 25