python - 图中垂直子图的最大数量

标签 python bar-chart plotly figure

我似乎无法在绘图中获得正确的垂直子图间距。目前,我的身材是这样的:

enter image description here

我想解决一些问题:

1)增加子图之间的间距,使图形变大

2) 增加每个 y 轴的大小,使刻度标签不重叠。

我在 plotly.tools.make_subplots 函数中没有看到任何控制图形大小的参数。如果有某种方法可以使图形更大,以便每个图都有更多空间,那就太好了。

最佳答案

一个最小的可重现示例

import plotly
plotly.offline.init_notebook_mode()
import random
rows = 10
traces = [[random.random() for j in range(100)] for i in range(rows)]

fig = plotly.tools.make_subplots(rows=rows, cols=1)
for i in range(1, rows + 1):
    p = plotly.graph_objs.Bar(y=traces[i - 1], showlegend=False)
    fig.append_trace(p, i, 1)
plotly.offline.iplot(fig)

产生

enter image description here

1) Increase the amount of space between subplots, and just make the figure larger

2) Increase the size of each y-axis so that the tick labels aren't overlapping.

您可以将vertical_spacinglayout['height']结合使用来同时解决这两个问题。

fig = plotly.tools.make_subplots(rows=rows, cols=1, vertical_spacing=0.5/rows)
fig['layout'].update(height=1000)

enter image description here

关于python - 图中垂直子图的最大数量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43145478/

相关文章:

android - 条形图 Achartengine 在条形图上方有文字

python - Plotly 中的 3D 曲面流

r - geom_bar 和 coord_flip 上的 ggplotly 似乎失败

python-3.x - 如何修复 "AttributeError: module ' Chart_studio.tools' 没有属性 'make_subplots' "

python - 如何阻止 pygame Sprite 离开 'tail'

python - 用Python编写温度传感器

python - 在 matplotlib 中使用 PolyCollection 进行绘图

java - 如何使用每个条形的 Achartengine 在条形图中的条形之间留出空间是包含不同值的不同颜色

Python Pandas : Merge Equivalent of "<=" SQL Join

ios - CorePlot - 调用 barTouchUpAtRecordIndex 后更改 x 轴标签 :