如何在Plot中削减子图底部的较大空间?

时间:2018-08-24 12:24:27

标签: python python-2.7 matplotlib plot plotly

我正在使用plotly生成交互式图。就我而言,我将有一张桌子和一张图。 https://docs.oracle.com/javaee/7/api/javax/persistence/SecondaryTable.html

import matplotlib
matplotlib.use('Agg')
import plotly.offline as offline
from plotly import tools
import plotly.graph_objs as go

trace1=go.Scatter(x=[1, 2, 3], y=[1, 3, 5], name='abc', mode = 'lines+markers', xaxis='x1', yaxis='y1', showlegend=True)
trace2=go.Scatter(x=[1, 2, 3], y=[1, 2, 3], name='cba', mode = 'lines+markers', xaxis='x1', yaxis='y1', showlegend=True)
trace3=go.Table(
        domain=dict(x=[0, 1], y=[0, 0.5]),
        header=dict(values=['', 'fields1', 'fields2', 'fields3']),
        cells=dict(values=[[['row1'], ['row2'], ['row3']], [['11'], ['12'], ['13']], [['21'], ['22'], ['23']], [['31'], ['32'], ['33']]], font = dict(color = '#506784', size = 11))
        )
axis=dict(
    showline=True,
    zeroline=False,
    showgrid=True,
    mirror=True,
    ticklen=4,
    gridcolor='#ffffff',
    tickfont=dict(size=10)
)

param1 = dict(
    xaxis1=dict(axis, **dict(domain=[0, 1], anchor='y1', showticklabels=False)),
    yaxis1=dict(axis, **dict(domain=[0.55, 1], anchor='x1', tickprefix='$', hoverformat='.2f')),
        )
layout1 = dict(
    title='Bitcoin mining stats for 180 days',
    margin = dict(t=100),
    showlegend=False,
    plot_bgcolor='rgba(228, 222, 249, 0.65)'
)
layout1.update(param1)
fig1=dict(data=[trace1, trace2, trace3], layout=layout1)
offline.plot(fig1, auto_open=False, output_type='file', filename='abc.html')

如何删除表格下方的空间?粪便的大小可以根据元素的实际大小自动更改吗?

1 个答案:

答案 0 :(得分:1)

查看您的val i = new ImportTest() 参数,尤其是在设置yaxis的位置:

domain

domain=dict(x=[0, 1], y=[0, 0.5]),

通过代码,您说表格将在y轴上绘制0%到50%之间。和图形-55%至100%之间。但看!您的表格太小,无法填补该空白(50%)。

所以您必须选择解决问题的方法:

  1. 增加表中的数据量。然后表的大小增加,间隙将减小,然后消失;

  2. 或将表格转至底部并增加图形大小(例如,按yaxis将表格增加0-15%,将图形增加15-100%),结果应类似于以下内容(以下完整代码): 100% your graph

代码:

yaxis1=dict(axis, **dict(domain=[0.55, 1],

还可以设置xaxis参数以获得更漂亮的图(将图的空间从25%设置为75%): enter image description here

相关问题