Updating graph with Plotly streaming does not render properly

I am using plotly 2.0
I have attached my code in a notebook.
Basically I am trying to plot 2 separate streams of data in a scatter graph.


The data is such that the x values for stream 1 (user 1 stream in the screenshot) appear ahead of those of stream 2.
As the graph updates, attempting to connect the lines in the graph there is a bug because the lines go backwards, seems to do with the way the graph is scaling up.

Here is an example of the graph updating:

I have attached my code as a notebook.

I am not sure how to fix this.

Any suggestions please?

Hi @nds,

I think the problem is that your strings are not recognized as dates and so they are being treated as categorical as categorical. Try passing datetime.datetime objects as the x and y to stream.write. You can convert your strings to datetime objects using the datetime.datetime.strptime static method (See https://docs.python.org/3/library/datetime.html#datetime.datetime.strptime).

Hope that helps!
-Jon

Hi Jon,
That seems to have worked, setting the x value to the timestamp and using the timestamp as the id as well.
Thank you!

1 Like

Hi @jmmease ,
I am having some trouble with streaming to a Map. There was a geo-streaming tutorial I followed here: https://plot.ly/python/geo-streaming/
but it seems to have been taken down.
So my question is:
1 ) Is streaming still supported in Python for maps?
2) Are there any updated samples?

Thank you!!

Hi @nds,

It was probably taken down due to the notice at the top of https://plot.ly/python/streaming-tutorial/


Streaming is no longer supported in Chart Studio Cloud.
Streaming is still available as part of Chart Studio Enterprise. Additionally, Dash supports streaming, as demonstrated by the Dash Wind Streaming example.


I don’t know when streaming will actually be disabled in Chart Studio Cloud, but it might be a good idea for you to start looking at implementing your streaming usecases in Dash. Here’s a tutorial someone made on the topic https://pythonprogramming.net/live-graphs-data-visualization-application-dash-python-tutorial/.

Hope that helps!
-Jon

Hi,

@jmmease

Thanks for sharing the link.

I read the notice about Streaming no longer being supported in Chart Studio but I do not use Dash or Chart studio. I read that Dash is β€œa python framework for web apps” and I do not have a web app, I’m only using the plotly Python API to visualize data in Jupyter notebooks.

So I am confused, would I still need to use Dash for a notebook?

Thank you!

Hi @nds,

Ok, if you’re wanting to view everything in the Jupyter notebook then another approach is to use the plotly.graph_objs.FigureWidget ipywidget. The basic idea with FigureWidget is that is displays itself in the notebook (don’t use iplot), and then updates made to the figure object are automatically synced to the figure view.

See https://plot.ly/python/#chart-events for some examples.

-Jon