[Python] Python Plotly displaying data upside down in Y-axis

Discussão em 'Python' iniciado por Stack, Maio 22, 2025.

  1. Stack

    Stack Membro Participativo

    I have a large data set of binary data from a sensor that I'm trying to plot. I want to see the bit stream but for some of the columns of data, the output is visually shown flipped where 0 is placed at the top of the y axis and 1 is at the bottom. Im plotting each column and only some of the columns have this behavior (4 out of 18), most of them are plotted with 1 at the top of the y-axis and 0 at the bottom. I have taken the first 25 rows and used them below. Here is the code I'm using to plot.

    # Plot Image

    # Create figure
    fig = go.Figure()

    for col in df_test.columns:
    fig.add_trace(
    go.Scatter(
    x=df_test.index,
    y=df_test[col],
    name=col,
    visible="legendonly",
    line_shape='hv'))


    fig.update_layout(
    autosize=False,
    width=1550,
    height=800,
    xaxis_title=df_test.index.name,
    yaxis_title="State",
    yaxis=dict(range=[0, 1])
    )

    fig.show()


    Dataframe data

    showing column 1, data shown upside down

    showing column 2, y axis is displayed correctly

    showing columns 1 and 2 with the data displayed upside down

    Just updated to plotly version 6.1.1

    Any ideas why some of the columns are shown upside down and how to fix it?

    Continue reading...

Compartilhe esta Página