Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Confused about plotly online / offline / cufflinks and the different versions

I don't get it:

I'm trying to just do a sample graph:

a = pd.DataFrame(np.random.randn(100, 4), columns=['a', 'b', 'c', 'd'])
a.iplot(kind='line', y='a')

not a very complex example.

apparently, there is:

  • plotly online (uploads your graph on their system)
  • offline (makes a local image)
  • the cufflink library that is supposed to do the interfacing with pandas dataframes

in practice the whole online / offline is not clear because half of the web content seems to be about older versions.

but, when I just use plotly to output something, I get a browser tab with my plot. since it opens an url, is that online or offline mode? no idea

to do this I have to import from plotly import graph_objs as go and not import plotly.graph_objects as go like written in the documentation because that doesn't work. not really sure why there are two different objects with almost the same name...

enters cufflink where when I copy paste samples (from this articles: https://medium.com/@kbrook10/day-7-data-visualization-how-to-use-plotly-and-cufflinks-for-interactive-data-visualizations-3a4b85fdd999) it will complain about a missing filename / url.

It looks like this:

enter image description here

so, I go to 'offline' mode:

cf.go_offline()

well, no, same error..

in the end, all I want is dataframe->plots; and eventually doing interactive plots, which is why I'm going away from matplot lib.

I'd be very grateful if someone could explain the different versions, why naming seems to change, etc and how I can use cufflink to make that dataframe->plot thing work ;)

like image 222
Thomas Avatar asked Oct 23 '25 17:10

Thomas


1 Answers

I'm sorry the situation is so confusing, let me try to clear it up...

  • We've just recently (July 2019) released version 4 of plotly which behaves somewhat differently from version 3. Here's the announcement and here's the migration guide.
  • In version 3 there was the notion of online vs offline, whereas in version 4 we are trying to clear up the confusion so there is only offline mode (and online mode has been moved to a different module called chart_studio)
  • In version 4, when you use fig.show() to render a figure this is working in what used to be called offline mode: nothing is uploaded anywhere.
  • In version 4, we added plotly.graph_objects as an alias for plotly.graph_objs as it's easier to say. Both work and do the exact same thing but for some reason certain versions of PyCharm don't do auto-completion on the newer one, and we're working on a fix.
  • The simplest way today to make a plot with plotly from a dataframe is to use plotly.express
  • No matter the mode, online or offline, charts must render in a browser, either a real one in a tab, or an inline one in a notebook or IDE, or a headless one like kaleido or orca that returns PNGs or SVGs. This means that when you use version 4 and a browser window opens, this is in offline mode and no data has left your computer.
  • cufflinks is a third-party module whose latest version at the moment (july 2019) was built to work with plotly version 3 and not yet upgraded to work with the new version 4 features and so it still has the notion of online vs offline. (update January 2021: cufflinks works with Plotly v4 since around September 2019, but Plotly Express has since been upgraded to support a pandas-like API just like cufflinks and is now the recommended way to do things)

Hopefully that clears things up.

like image 159
nicolaskruchten Avatar answered Oct 25 '25 07:10

nicolaskruchten



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!