 # How to use plt.xticks() in this case?

My Code:

``````import matplotlib.pyplot as plt
%matplotlib inline
fig=plt.figure()
ax1.plot(unrate.loc[0:11,"DATE"],unrate.loc[0:11,"VALUE"])
ax2.plot(unrate.loc[12:23,"DATE"],unrate.loc[12:23,"VALUE"])
plt.xticks(rotation=90)
``````

What I expected to happen:
I expected that both the plots will get the rotation of their x-axis labels with 90 degrees.

What actually happened:
Only the second plot ax2 got it’s x labels rotated with 90 degrees.

Can we actually use sticks in the case when we are building multiple blocks? If yes, how can we change the rotation of the x-label using sticks for all the plots in the figure (Container)?

1 Like

Try using:

``````ax1.set_xticklabels(unrate.loc[0:11,"DATE"], rotation=90)
ax2.set_xticklabels(unrate.loc[12:23,"DATE"], rotation=90)

``````
1 Like

Goodmorning,
yes I used it thank you for help. But after this figsize parameter is required too.

You can also add in figure size as an argument when you create the figure:

import matplotlib.pyplot as plt
%matplotlib inline
fig=plt.figure(`figsize=(width, height)`)
ax1.plot(unrate.loc[0:11,“DATE”],unrate.loc[0:11,“VALUE”])
ax2.plot(unrate.loc[12:23,“DATE”],unrate.loc[12:23,“VALUE”])
plt.xticks(rotation=90)

2 Likes

So use the `figsize` parameter. Just like @cam.mcbroom showed you.

1 Like

One way of rotating axes ticks is using ax.set_xticklabels(rotation = 90).