All,
I am using plotly 4.8.2 and python 3.7.7. I have some time-series data and a bunch of boolean flags built as metadata on the data. I would like to see what is a good way to visualize this data using plotly. Here is an example snippet of what I have:
import pandas as pd
import numpy as np
from plotly.subplots import make_subplots
import plotly.graph_objects as go
from plotly.offline import plot
# Generate some random data
date_rng = pd.date_range(start='1/1/2018', end='12/31/2018', freq='H')
df = pd.DataFrame(date_rng, columns=['date'])
df['A'] = np.random.randint(0,100,size=(len(date_rng)))
df['B'] = np.random.randint(0,100,size=(len(date_rng)))
df['C'] = np.random.randint(0,100,size=(len(date_rng)))
df.set_index("date", inplace=True)
# Implement a basic filter
for column in df.columns:
df[column + "_lowflag"] = df[column] < 10
df[column + "_highflag"] = df[column] > 90
# Prepare a sample figure
fig = make_subplots(rows=2, cols=1, shared_xaxes=True)
fig.update_layout(template="gridon", title_text="Filter Visualization Question", xaxis_title="Dates", yaxis_title="Random Data")
for column in df.columns:
if "flag" not in column:
fig.add_trace(go.Scatter(
x=df.index,
y=df[column],
name=column
),
row=1,
col=1
)
# Add filters to subplot 2
for column in df.columns:
if "flag" in column:
fig.add_trace(go.Scatter(
x=df.index,
y=df[column],
marker=dict(color="black", size=6),
mode="markers"
),
row=2,
col=1
)
# Update figure layout to auto-adjust by screen size
fig.update_layout(
autosize=True
# width=700,
# height=700
)
plot(
fig,
auto_open=True
)
Two issues I see with this is, it is very hard to distinguish between different boolean flags when there are multiple boolean flags like I do and additionally the plot is really slow. I am not opposed to using Dash, but I donβt want to go to Dash unless it is the only way to do it or unless it simplifies the problem. All constructive suggestions are welcome.
Thanks