简体   繁体   English

如何从绘图图中消失 X 和 Y 轴线

[英]How to vanish X and Y axis line from plotly graph

I'm trying to build a Dashboard using Plotly in Python.我正在尝试在 Python 中使用 Plotly 构建一个仪表板。 I've initialized a dashboard, and divided it into portions/containers using 'dash_html_components.Div()'.我已经初始化了一个仪表板,并使用“dash_html_components.Div()”将其划分为多个部分/容器。 Later, I've used 'dash_core_components.Graph()' to plot graph inside a div.后来,我使用 'dash_core_components.Graph()' 在 div 内绘制图形。 I want to vanish X and Y axis line from graph.我想从图形中消失 X 和 Y 轴线。

Here is graph with X and Y axis line:这是带有 X 和 Y 轴线的图形: 图片1

Here is graph without X and Y axis line:这是没有 X 和 Y 轴线的图形: 图像2

Code for graph layout:图形布局代码:

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
)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么这个 Plotly 图形在 Y 轴和 X 轴上悬停? - Why is this Plotly graph is hovering Y and X axis? 如何绘制带有x和y分类轴的线图? - How to plot line graph with x and y categorical axis? Plotly 如何创建一行 animation,x 轴为列名称,y 轴为列数据? - Plotly How to create a line animation with column name in x axis and column data in y axis? Plotly:如何在悬停三个 y 布局和一个 x 轴共享图形时显示所有堆叠的 y 轴数据值? - Plotly: How to show all the stacked y axis data values while hovering for three y layout and one x axis shared graph? 如何使用 plotly 对 dataframe(y 轴)与按时间范围(x 轴)分组的不同列进行箱线图 - How to boxplot different columns from a dataframe (y axis) vs groupby a range of hours (x axis) using plotly 如何更改 plotly 中的 x 轴和 y 轴标签? - How to change the x-axis and y-axis labels in plotly? python pandas:如何为折线图切换x轴和y轴 - python pandas: how to switch x-axis with y-axis for a line graph 绘制折线图以遵循 X 轴上的有序时间序列 - Plotly line graph to follow ordered time series on X-axis 如何显示x和y轴图 - How to show the x and y axis graph 如何 plot Plotly 图在 Y 轴上具有十六进制值 - How to plot a Plotly graph with hexadecimal value in the Y axis
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM