0

in the following post (number 23) : Moving x-axis to the top of a plot in matplotlib, the answer to move the x-axis on top is given. But it does not say anything about the title.

I have a plot with a x-axis on top and a title, but the x label interfers with my title. How can I separate the xlabel from the title ?

Thank you

2
  • 1
    Hello and welcome to Stackoverflow. Please post a minimal working example of your code and describe the error as abundant as possible. And also, post your outcome and desired outcome as well. Without that, no one could be able to help you with your problem... Commented Aug 6, 2015 at 9:25
  • Hi, ok sorry ! next time I ll have an question about the code, I ll write down the code and the outcomes. Thanks ! Commented Aug 6, 2015 at 10:11

1 Answer 1

1

You can use the y kwarg for ax.set_title. Experiment with the value of y to suit your needs.

import matplotlib.pyplot as plt

fig, (ax1,ax2) = plt.subplots(1,2)

ax1.xaxis.tick_top()
ax2.xaxis.tick_top()

ax1.set_title('Title1')
ax2.set_title('Title2',y=1.05)

fig.savefig('title.png')

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

Hi Tom, thank you very much for your quick answer. It is working perfectly :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.