python - Matplotlib 轴标签不显示

标签 python python-3.x matplotlib

图表的轴标签不显示的可能原因有哪些?图表本身工作正常,但标签不行。

f= open("test1T.txt")
t1T = f.read()
x= [min_crib_dist("squeamish ossifrage",sub_cipher(t1T,rand_dict())) for i in range(10000)]
plt.xlabel = ('Minimum Hamming Distance')
plt.ylabel = "Number of Simulations"
plt.hist(x, bins=10)
plt.show()

最佳答案

xlabelylabel 是函数 - 您无法直接设置值。您的代码应如下所示:

f= open("test1T.txt")
t1T = f.read()
x= [min_crib_dist("squeamish ossifrage",sub_cipher(t1T,rand_dict())) for i in range(10000)]
plt.xlabel('Minimum Hamming Distance')
plt.ylabel("Number of Simulations")
plt.hist(x, bins=10)
plt.show()

参见引用here .

关于python - Matplotlib 轴标签不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43268281/

相关文章:

python - 使用插值重新网格化纬度和经度

python - 如何在 cartopy/matplotlib 图上显示公里标尺?

matplotlib - Jupyter 输出单元格在多个图形上折叠

许多文件中的 python GTK+ 操作

python - 更改 pandastable 中显示的数据框(tkinter 小部件)

python - 如何舍入 matplotlib 饼图中显示的值?

python - 如何返回匹配某些文本的正则表达式?

pandas - 在Python中的同一个图上绘制多个位置的年度数据

python - 使用 Pandas 的正则表达式

python - 无法在 Python 中打开 html5lib