簡體   English   中英

如何從繪圖圖中消失 X 和 Y 軸線

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

我正在嘗試在 Python 中使用 Plotly 構建一個儀表板。 我已經初始化了一個儀表板,並使用“dash_html_components.Div()”將其划分為多個部分/容器。 后來,我使用 'dash_core_components.Graph()' 在 div 內繪制圖形。 我想從圖形中消失 X 和 Y 軸線。

這是帶有 X 和 Y 軸線的圖形: 圖片1

這是沒有 X 和 Y 軸線的圖形: 圖像2

圖形布局代碼:

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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM