擅长:python、mysql、java
<p>经过一番研究,并没有找到一个“本地”的Seaborn解决方案,我提出了下面的代码,部分基于@Pablo Reyes和@CT Zhu的建议,并使用matplotlib函数:</p>
<pre><code>from matplotlib.ticker import *
figure(num=None, figsize=(20, 10))
plt.title('Cumulative Distribution Function for ALABAMA population')
plt.xlabel('City')
plt.ylabel('Percentage')
plt.plot(al_df.pop_cum_perc)
#set the tick size of y axis
ax = plt.gca()
ax.yaxis.set_major_locator(MultipleLocator(0.1))
#set the labels of y axis and text orientation
ax.xaxis.set_major_locator(MultipleLocator(10))
ax.set_xticklabels(labels, rotation =90)
</code></pre>
<p>该解决方案引入了一个新元素“labels”,我必须在绘图之前指定它,它是从我的Pandas数据框创建的一个新的Python列表:</p>
<pre><code>labels = al_df.NAME.values[:]
</code></pre>
<p>制作下表:
<img src="https://i.stack.imgur.com/1s5XK.png" alt="enter image description here"/></p>
<p>这需要进行一些调整,因为在pandas数据框中指定每个城市的显示,如下所示:</p>
<pre><code>ax.xaxis.set_major_locator(MultipleLocator(1))
</code></pre>
<p>生成无法读取的图表(仅显示x轴):
<img src="https://i.stack.imgur.com/ZQrtg.png" alt="enter image description here"/></p>