plotly / plotly/plotly.py

[BUG] Data in `px.imshow` disappears at default zoom, reappears when zooming in with dense data

Offen
#5,209 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

bug P2
Vorherrschende Sprache
Python
Sterne
18.8k
Forks
2.8k
Ø Merge
16 Std. 26 Min.
Gemergte PRs (30 T.)
21

Beschreibung

Environment
Plotly Version: 6.1.2
Operating System: Windows 10 22H2 19045.5854 Windows Feature Experience Pack 1000.19061.1000.0
Browser: Chrome 137.0.7151.41

When trying to visualize dense binary time-series data (e.g., 10 channels over 4,000+ time points), both px.imshow and px.timeline fail to render the data correctly in the default, zoomed-out view. The areas that should contain data appear blank.

However, if you manually zoom into any region of the plot, the data correctly appears. Resetting the zoom causes the data to disappear again. This suggests the issue is not with the data itself, but with the rendering engine's handling of very thin graphical elements (heatmap cells or gantt bars) at a low zoom level.

Here is my origin data.
BAO_spikes_sorted_output.csv

Here is my html.(Please change the suffix to html)

BAO Spike Heatmap.txt

Here is my code.

def plot_binary_heatmap(csv_file="./data/down/combined_binary.csv", title="Binary Heatmap of Signals"):
    """
    Reads data from a combined binary CSV, processes filenames, and plots a heatmap.
    The x-axis represents time in seconds, and the y-axis represents file numbers in ascending order.
    """
    df = pd.read_csv(csv_file)

    # 1. Extract the time column (keep as float)
    if 'Time' in df.columns:
        time = df['Time'].astype(float)
        df = df.drop(columns=['Time'])
    elif 'time' in df.columns:
        time = df['time'].astype(float)
        df = df.drop(columns=['time'])
    else:
        # If no time column exists, create an index
        time = pd.Series(range(df.shape[0]))

    # 2. Transpose: each row is a file, each column is a time point
    df_t = df.T
    df_t.index.name = "File"

    # Update index, keep only the part before "_"
    df_t.index = df_t.index.to_series().str.split('_').str[0]

    # 3. Set time as column names (keep as float)
    df_t.columns = time

    z = df_t.to_numpy()
    y_labels = df_t.index.tolist()
    x_values = df_t.columns.to_numpy()

    # 4. Create the heatmap
    fig = px.imshow(
        z,
        labels=dict(x="Time (s)", y="Channel", color="Binary"),
        x=x_values,
        y=y_labels,
        color_continuous_scale=["#ffffff", "#000000"],
        aspect="auto",
        title=title
    )

    # 5. Update chart layout
    fig.update_layout(
        xaxis_title="Time (s)",
        yaxis_title="Channel",
        height=600,
        width=1000,
    )

    fig.write_html(f"{title}.html")

plot_binary_heatmap(csv_file="BAO_spikes_sorted_output.csv", title="BAO Spike Heatmap")

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne damit, den Bericht mit der beigefügten BAO_spikes_sorted_output.csv, dem bereitgestellten Python px.imshow-Beispiel und Plotly 6.1.2 zu reproduzieren, und vergleiche dabei die Standardansicht mit einer vergrößerten Ansicht. Als erledigt gilt die Aufgabe, wenn dichte binäre Heatmap-Daten ohne manuelles Zoomen sichtbar bleiben und das Verhalten anhand des bereitgestellten Falls verifiziert ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
plotly, python
Bereich
data-visualization
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.