![](/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.