简体   繁体   中英

How to vanish X and Y axis line from plotly graph

I'm trying to build a Dashboard using Plotly in Python. I've initialized a dashboard, and divided it into portions/containers using 'dash_html_components.Div()'. Later, I've used 'dash_core_components.Graph()' to plot graph inside a div. I want to vanish X and Y axis line from graph.

Here is graph with X and Y axis line: 图片1

Here is graph without X and Y axis line: 图像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
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM