I am looking to plot a irregular time series with a line shape that connects the data points vertically to the x-axis (with no lines connecting the data points themselves). Sort of like the ACF plots in R, except with irregular time points:
to my knowledge there is no available shape to do what you want, but you can create it yourself by making the y-values passing zero every time, like this, for example:
import plotly.express as px
import numpy as np
df = px.data.iris()
data = df.sepal_length
x = data.index.values
y = data.values
def create_stem_data(x,y, baseline=0.):
'''makes y data passing 0 before inbetween actual value to create data for a stem plot
x,y are 3 times the original length
'''
x=np.repeat(x,3)
y=np.repeat(y,3)
y[::3]=y[2::3]=baseline
return x,y
x,y = create_stem_data(x,y)
fig = px.line(x=x,y=y)
fig.show()
Hi
Is there an updated way to produce such a plot with plotly ?
What I would like to obtain is a something like a stem plot in matplotlib.
Using a bar plot with narrow width is not so satisfactory because I have 14000 points and if you zoom in, consecutive bars overlap. The width of the bar may depend on the zoom level.
Adding zero is an option but it leads to 3 times the amount of data.