how to rotate xticks on one axis of figure in matplotlib without "getting" the labels as a list
<p>suppose i have the following code which creates one matplotlib figure with two axes, the second of which has x-axis labels as dates:</p>

<pre><code>import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
import datetime as dt    

x1 = np.arange(0,30)
x2 = pd.date_range('1/1/2016', periods=30, freq='D')
y1 = np.random.randn(30)
y2 = np.random.randn(30)

%matplotlib inline
fig, ax = plt.subplots(1,2, figsize=(18,5))
ax[0].scatter(x1,y1)
ax[1].scatter(x2,y2)
</code></pre>

<p>displaying this in an ipython notebook will show the x axis labels of the graph on the right as running into one another. i would like to rotate the labels to improve visibility. all of the documentation and online searching seems to suggest one of the following 2 options (both after the last line above): </p>

<p><strong>#1</strong></p>

<pre><code>plt.setp(ax[1].xaxis.get_majorticklabels(),rotation=90,horizontalalignment='right')
</code></pre>

<p><strong>or #2</strong></p>

<pre><code>plt.xticks(rotation=90)
</code></pre>

<p>either of these will work but will also print a list of labels (which for some reason is different in the first example than in the second)</p>

<p>how do i accomplish the rotation/display without also outputting some array? </p>

<p>i was able to use this approach. not sure if it is the most elegant way, but it works without outputting an array</p>

<pre><code>for tick in ax[1].get_xticklabels():
    tick.set_rotation(90)
</code></pre>

python matplotlib