1

I am new to python so I apologize if this if this will sound like a silly question. I am trying to change a the title of the x axis in a plot ,from what I read if you use subplots the you need to use set_xlabel('X Axis') command but for some reason this is not working for me.

plot=plt.subplots();
dftemp=dftemp.set_index('Date2');
plot=dftemp['yield_bruto_percent'].plot(kind='bar',color="lightgray",title=dftemp['paper_name'][1][::-1]+'    ינוציח-ימינפ גוריד ',figsize=(8,4),legend=True)
plot=dftemp['dirug_mnpik_psagot'].plot(secondary_y=True,legend=True);
plot=dftemp['final_score'].plot(secondary_y=True,legend=True);
plot=dftemp['dirug_manpik_hitzoni'].plot(secondary_y=True,legend=True,rot=45);
plot.set_xlabel('X Axis')

when I run this code the label does not change and the label appears as the name of variable which is the index in my data set. This is the message i get

<matplotlib.text.Text at 0x23735e70390>

any suggestions would be highly appreciated.

1 Answer 1

3

The https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.set_xlabel.html function is a member of Axes class.

You can get an object of axes class from subplots as following

plot, ax = plt.subplots()

Then set the xlabel as following

ax.set_xlabel('X Axis')
Sign up to request clarification or add additional context in comments.

Comments

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.