Plotly - yaxis min and max value not showing

Viewed 1488

I'm using plotly to create some plots. I haven't modified the yaxis range, but I don't like how the chart is displaying the y axis. In the image attached the chart y axis numbers go from 25 to 40, but I have data that is slightly above 40 and below 25. Is there an option to force the y axis to always be higher than the min and max value that I have? Also, is it possible to have the y axis starting at the edges? (Highlighted in purple)

Thank you for your time!

enter image description here

Edit: As asked in the comments, I've added my code below:

fig= go.Figure()

fig.update_layout(
        template="simple_white",
        font=_a_font,
        height=400,
        legend=dict(
            orientation="h",
            yanchor="bottom",
            y=1.02,
            xanchor="left",
            x=0,
            font=dict(size=16),
            itemclick=False,
            itemdoubleclick=False,
        ),
    )

fig.update_layout(xaxis=dict(range=x_range, mirror=True, tickmode='linear', tick0=0,dtick=1))
        
fig.update_yaxes(showgrid=True,mirror=True)
   
            
fig.add_trace(go.Scatter(x=sub_x_data,
                         y=y, 
                         mode="lines+markers", 
                         name=legend_name,
                         line=dict(color=get_driver_color(legend_name)),
                                         textposition="bottom center",
                                         text = h_data,
                                         hoverinfo="text"))
1 Answers

It would be helpful to see your code, as this chart doesn't look like a default style chart in Plotly.

That being said, you should be able to set the range manually, and specify the location of the first tick: fig.update_yaxes(range=[20, 45], tick0=0)

Related