python - 如何从绘图图中消失 X 和 Y 轴线
问题描述
我正在尝试在 Python 中使用 Plotly 构建仪表板。我已经初始化了一个仪表板,并使用 'dash_html_components.Div()' 将其划分为多个部分/容器。后来,我使用 'dash_core_components.Graph()' 在 div 中绘制图形。我想从图中消失 X 和 Y 轴线。
图形布局代码:
layout_my_graph = go.Layout(
autosize = True,
margin={'t': 35,'r': 20,'b': 30,'l': 40},
legend=dict(
x=.9,y=1,
traceorder='normal',
font=dict(size=12)
),
#'t' in margin refer to top of the graph.
#Similarly you can set margin={'l': ?, 'r': ?, 't': ?, 'b':
title = "Commodity Price",
xaxis = dict(
title = "Dates",
linecolor = "#BCCCDC", # Sets color of X-axis line
showgrid = False, # Removes X-axis grid lines
zeroline = False, # thick line at x=0
visible = True, # numbers below
showspikes = True, #shows vertical line on hover
spikemode = 'toaxis+across', #shows vertical line on hover
spikesnap = 'cursor',
spikedash = 'solid', #shows vertical line on hover
spikecolor = "#000000",
spikethickness = 1
),
yaxis = dict(
title="Price",
linecolor="#BCCCDC", # Sets color of Y-axis line
showgrid=True, # Removes Y-axis grid lines
zeroline = False, # thick line at x=0
visible = True, # numbers below
),
showlegend = True, #shows vertical line on hover
hovermode = 'x', #shows vertical line on hover
spikedistance = -1 #shows vertical line on hover
)
fig = {
'data': traces,
'layout': layout_my_graph
}
解决方案
xaxis = dict(
# title = "Dates",
linecolor = "#BCCCDC", # Sets color of X-axis line
showgrid = False, # Removes X-axis grid lines
zeroline = False, # thick line at x=0
showline = False, #removes X-axis line
showticklabels=True, # axis ticklabels
visible = True, # numbers below
showspikes = True, #shows vertical line on hover
spikemode = 'toaxis+across', #shows vertical line on hover
spikesnap = 'cursor',
spikedash = 'solid', #shows vertical line on hover
spikecolor = "#000000",
spikethickness = 1
),
yaxis = dict(
# title="Price",
linecolor="#BCCCDC", # Sets color of Y-axis line
showgrid=True, # Removes Y-axis grid lines
zeroline = False, # thick line at x=0
showline = False, #removes Y-axis line
showticklabels=True, # axis ticklabels
visible = True, # numbers below
)
推荐阅读
- reactjs - 反应原生承诺
- fragment - org.apache.coyote.http11.HeadersTooLargeException
- python - 有人可以从 return e.index 部分解释吗?
- c# - 在 .NET C# 项目中,¿ 可能在调用 request.GetRequestStream() 时启动进度条?
- reactjs - 在路由中传递参数
- sql - 雪花中的制表符缩进是否有特殊字符?
- c++ - 给定数组中的重复元素
- .net - 带 LineChart 的 Syncfusion Blazor 条形图
- visual-studio-code - VSCode 和 VSCodeVim 扩展:跨多个 VSCode 实例复制和粘贴
- r - 数据框结构防止条形图显示在 ggplotly() 图表中