【发布时间】:2020-04-02 22:25:52
【问题描述】:
我的 Python Web 应用程序有一个 Plotly Dash “Graph”,其图例涵盖了 x 轴标签。我尝试调整以下元素,但没有成功,也没有明显的变化:
- 图例样式'margin-top'
- 边距'b'
- 填充'b'
代码如下:
import dash
import dash_core_components as dcc
import dash_html_components as html
graph = dcc.Graph(
figure = {
'data': data,
'layout': dict(
hovermode = "closest",
height = 400, # 500 is a bit too big on a smartphone
legend = dict(
font=dict(color='#7f7f7f'),
orientation="h", # Looks much better horizontal than vertical
style={'margin-top': 100},
),
font = {
'family': 'Segoe UI',
'color': "#7f7f7f"
},
# Added more margin on the left side to fix the cutoff True/False labels on the booleans
margin = dict(l=40, r=25, b=10, t=10),
padding = dict(l=0, r=0, b=10, t=0),
)
}
)
这是它的样子,显示与 x 轴标签重叠的图例:
【问题讨论】:
标签: python plotly-dash plotly-python