![](/img/trans.png)
[英]How to display the y_axis name of a xlsxwriter column chart horizontally, at the top of the axis?
[英]How to create labels, y_axis in percentage, and grid lines
我正在嘗試繪制數據集的累積分布,我堅持創建或將y軸更改為百分比並添加軸標簽。
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
st_cum = st_new[['sys_mod_count']]
#sort values per column
sorted_values = st_cum.apply(lambda x: x.sort_values())
#plot with matplotlib
#dimensions per variable.
for col in sorted_values.columns:
y = np.linspace(0.0,100.0, len(sorted_values[col].dropna()))
plt.plot(sorted_values[col].dropna(), y)
您只需添加以下行:
plt.xlabel("X")
plt.ylabel("Y")
plt.grid(True) #Grid plotting
plt.axis('equal') #Space is equal in both axis
plt.show()
您可以在這里找到更多信息: matplotlib
為了顯示百分比,只需在ylabel中寫入百分比符號即可
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.