[Python] Plotly express line plots number of datapoint insted of actual data

Discussão em 'Python' iniciado por Stack, Junho 17, 2025.

  1. Stack

    Stack Membro Participativo

    Plotly express line plots number of data points instead of actual data on the y axis.

    Now whats confusing me is that it only does this on one machine, its works perfectly fine on 3 others. I made sure python and the packages i use are of the same version.

    I tried changing the data type to int and float, which only does what i described above. However if i changed the data type to string it no longer showed the number of data point, but it scaled all the values that aren't 0 to 1(other devices did the same on datatype str).

    df['Machine_Status'] = df['Machine_Status'].astype(int)
    df = df.dropna(subset=['Machine_Status'])
    df =df.reset_index(drop=True)
    df[['Timestamp', 'Machine_Status']].to_csv('machine_status_timeframe_output.csv', index=False)
    fig = px.line(
    df,
    x='Timestamp',
    y='Machine_Status',
    title=f'{machine_id} Activity on {selected_date} (6 AM to 10 PM)',
    labels={'Timestamp': 'Time', 'Machine_Status': 'Activity'},
    line_shape='hv',
    )

    Timestamp Machine_Status
    2025-06-16 06:00:04 0
    2025-06-16 06:00:09 0
    2025-06-16 06:00:14 3
    2025-06-16 06:00:18 0
    2025-06-16 06:00:23 0
    2025-06-16 06:00:28 3
    2025-06-16 06:00:33 0
    2025-06-16 06:00:38 0
    2025-06-16 06:00:43 3
    2025-06-16 06:00:48 0
    2025-06-16 06:00:53 0
    2025-06-16 06:00:58 3
    2025-06-16 06:01:03 0
    2025-06-16 06:01:08 0
    2025-06-16 06:01:13 0
    2025-06-16 06:01:18 0
    2025-06-16 06:01:23 0
    2025-06-16 06:01:28 0
    2025-06-16 06:01:33 0
    2025-06-16 06:01:38 0
    2025-06-16 06:01:43 0
    2025-06-16 06:01:48 0
    2025-06-16 06:01:53 0

    Plotting number of data points

    How it should look

    Continue reading...

Compartilhe esta Página