hvplot icon indicating copy to clipboard operation
hvplot copied to clipboard

When using two pandas.DataFrame.interactive() to create a single plot, one one of the is visible (and duplicated)

Open fohrloop opened this issue 1 year ago • 0 comments

Writing this bug report as requested on this Discourse thread.

ALL software version info

I have the following versions, on python 3.10 on Ubuntu 22.04:

holoviews 1.18.1 hvplot 0.9.1 panel 1.3.6 bokeh 3.3.3 param 2.0.1

Description of expected behavior and the observed behavior

When using two pandas.DataFrame.interactive() to create a single plot, one one of the is visible. Expected both to be visible.

Complete, minimal, self-contained example code that reproduces the issue

import pandas as pd
import hvplot.pandas
import panel as pn

pn.extension(sizing_mode="stretch_width")


def get_data():
    url = "https://data.seattle.gov/api/views/65db-xm6k/rows.csv?accessType=DOWNLOAD"
    file = "rows.csv"
    try:
        seattle_bikes = pd.read_csv(file, parse_dates=["Date"]).set_index("Date")
    except Exception:
        seattle_bikes = pd.read_csv(url, parse_dates=["Date"]).set_index("Date")
        seattle_bikes.to_csv(file)

    bikes = seattle_bikes["Fremont Bridge Sidewalks, south of N 34th St"]
    bikes.name = "data"
    return bikes.to_frame()


rolling = pn.widgets.IntSlider(value=50, start=10, end=100)

seattle_bikes = get_data()


plot1 = (
    seattle_bikes.interactive()
    .resample("D")
    .sum()
    .rolling(rolling, center=True, win_type="gaussian")
    .sum(std=10)
    .hvplot(
        line_dash=["solid", "dashed", "dotdash"],
        responsive=True,
        height=400,
        title="Seattle Data",
    )
)

seattle_bikes2 = seattle_bikes.copy()
seattle_bikes2["data"] += 1e4

plot2 = (
    seattle_bikes2.interactive()
    .resample("D")
    .sum()
    .rolling(rolling, center=True, win_type="gaussian")
    .sum(std=10)
    .hvplot(
        line_dash=["solid", "dashed", "dotdash"],
        responsive=True,
        height=400,
        title="Seattle Data",
    )
)
pipeline = plot1 * plot2

pn.template.FastListTemplate(
    sidebar=[pipeline.widgets()],
    main=[pn.panel(pipeline.holoviews(), sizing_mode="stretch_width")],
).servable()

Screenshots or screencasts of the bug in action

Here is a screenshot of what you get (one curve duplicated, another not shown): image

This is what you would expect to have (two curves with different data) image

  • [ ] I may be interested in making a pull request to address this

fohrloop avatar Jan 17 '24 13:01 fohrloop