【发布时间】:2018-03-20 10:03:20
【问题描述】:
我想用函数格式化直方图的 y 轴:
def convertCountToKm2(x):
return x * 25.0 * 1e-6
因为这会将直方图的 y 轴从细胞计数转换为以 km2 为单位的面积。直方图由以下人员创建:
bins = numpy.array(list(range(0,7000,1000)))
plt.hist(Anonzero,bins)
下图中的结果:
我尝试使用以下代码调用该函数:
yFormat = tkr.FuncFormatter(convertCountToKm2)
plt.yaxis.set_major_formatter(yFormat)
返回错误:模块'matplotlib.pyplot' has no attribute 'yaxis'
How do I format axis number format to thousands with a comma in matplotlib? 似乎也有一些关于格式化轴的提示,但这并不是针对这种情况的。我无法用它来回答我的问题。
【问题讨论】:
标签: python matplotlib histogram