python - matplotlib:子图重叠的 y 标签

标签 python matplotlib

我有三个共享 x 轴的子图。我需要子图之间的 hspace 为 0.0,但子图的 y 标签会重叠。

ylabels of subplots overlap

有没有办法将每个子图的极端 y 标签向下或向上移动一点(就像我在右侧的 mspaint 中手动所做的那样)?

皮奥特尔

最佳答案

有一个专用的股票代码格式化程序类正是用于此目的。
http://matplotlib.org/api/ticker_api.html#matplotlib.ticker.MaxNLocator

from matplotlib.ticker import MaxNLocator
ax2.yaxis.set_major_locator(MaxNLocator(prune='upper'))  #remove highest label so it wont overlapp with stacked plot.

编辑: 实际上这不会移动它们,只需删除重叠的刻度即可。

关于python - matplotlib:子图重叠的 y 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20972033/

相关文章:

python - 将稀疏矩阵行转换为密集泄漏内存

python - 我可以找到mysql中查询返回的字段的数据类型吗

Python如何在数据框中应用.replace以更改大量值

python - 使用 scipy python 中的 curve_fit 函数

python - 循环通过一个函数来绘制几个子图,Python

python - 我怎样才能绘制ca。 2000 万个点作为散点图?

python - 如何在 PyMongo 的 GridFS 中打开文件的 GridOut 实例?

python - 根据另一列中的值复制 PySpark Dataframe 中的行并获得顺序

python - 如何使用 matplotlib 从 numpy 列表中绘制多个数据集

python - 将 pandas 表(填充有字符串)保存为 png