Black Lives Matter. Please consider donating to Black Girls Code today.

Display y-axis origin lines [Python]

Hello,

I’m currently using Plotly library on Python and I’m trying to display the y-axis origin line. I see examples online that have both origin lines, however when I use my custom layout they don’t appear and I can’t figure out the style to get them back.

Y-Axis Line Showing:

What mine looks like:

Code:

    layout = dict(
            width = 900,
            heigth = 900,
            xaxis = dict(
                showgrid = False,
                autogrid = True,
                zeroline=True,
                title = "Date",
                titlefont = dict(
                        size = 20,
                        color = "#000"
                ),
                tickfont = dict(
                        size = 14,
                        color = "#000"
                ),
                dtick=30,
                        
            ),
            yaxis = dict(
                showgrid = False,
                zeroline = True,
                autogrid = True,
                title = "Tweets per Second",
                titlefont = dict(
                        size = 20,
                        color = "#000"
                ),
                tickfont = dict(
                        size = 14,
                        color = "#000"
                ),
            ),
        )

@JStuve First of all comment the lines with autogrid=True.
They lead to the error:

'autogrid' is not allowed in 'yaxis'
 Path To Error: ['layout']['yaxis']['autogrid']

What you call yaxis origin is from mathematical point of view the line of equation x=0. But on xaxis you have date, and so no x=0 exists.

To plot the yaxis insert in layout[‘yaxis’] the key-value:

  showline=True
1 Like

Thank you! Just what I was looking for! Also +1 for the additional information!