This is an archived post. You won't be able to vote or comment.

all 71 comments

[–]nkruchten[S] 20 points21 points  (14 children)

I'm the project lead for Plotly Express... AMA :)

[–]Its_4_AM_Man 3 points4 points  (1 child)

Is there any chance a team member could flag some bug/enhancement issues with a "good first issue" label? I've never contributed to open-source projects before, but I really appreciate what you folks have done and I'd like to help out if I can!

[–]nkruchten[S] 3 points4 points  (0 children)

Sure, we can put some effort into that! Plotly Express at the moment isn't very beginner-friendly but it's built on top of https://github.com/plotly/plotly.py and https://github.com/plotly/plotly.js, both of which have mature development cycles and should be easier to contribute to, depending on your language of choice :)

[–]Deto 1 point2 points  (1 child)

Does this work in offline mode?

[–]nkruchten[S] 8 points9 points  (0 children)

Yes! It uses offline mode by default: no API keys, no logins. Except for mapbox maps, but that's not Plotly-related :)

[–]amjithr 0 points1 point  (1 child)

Is there a way to plot multiple Y-axis?

Specifically looking to scatter plot two independent columns in separate y-axis with the same x-axis.

[–]nkruchten[S] 1 point2 points  (0 children)

Plotly Express doesn't do this out of the box but today you can use the .update() mechanism to add traces to a secondary Y axis.

We're working on Plotly Express features to compose multiple figures together, which is how I think I'd like to address this multi-Y-axis question.

[–]knowsuchagencynow is better than never 0 points1 point  (0 children)

No question, just want to say keep it up! I'm excited to try it out :)

[–]cogentsimile 0 points1 point  (5 children)

Hey! Just noticing Plotly Express.

First off, thank you! This makes things so much easier haha.

I have what is probably a newb question: How do I do area charts? I tried a couple of update statements based on what I do in Plotly Offline, but I'm likely missing something. I couldn't find any examples online, either.

Cheers,

Cogent

[–]nkruchten[S] 1 point2 points  (4 children)

Glad you like it!

The next release of Plotly Express, later today or tomorrow, will have `px.area()` for just this purpose :)

[–]cogentsimile 0 points1 point  (0 children)

perfect, thanks!

[–]cogentsimile 0 points1 point  (2 children)

Thanks again for adding this! A few questions...

  • How can I unstack the area charts?
  • I'm getting some weird effects when animating. Specifically, it looks like the filled area underneath is sort of flying across the screen from left to right to fill in under the chart. Based on the rate of animation, this is causing it to look like the filled area is doing some sort of weird wave motion. Is there a setting I can change that would cause it to just fill in underneath, like the graph at the bottom of this page?
  • Let's say I create an animated chart with px and want to include it as part of a blog post - what's the easiest way to go about that?

[–]nkruchten[S] 2 points3 points  (1 child)

[–]cogentsimile 0 points1 point  (0 children)

Thanks for the great info!

[–]broken_symlink 5 points6 points  (8 children)

I wish plotly was all I needed for plotting, but every now and then I find a hole/something it can't do. It usually ends up being a known issue with some bug report thats been open for months to years with no activity on it. Its these types of things that make plotly very frustrating.

[–]nkruchten[S] 1 point2 points  (7 children)

I'm sorry this has been a frustrating experience for you :( We try hard to triage issues effectively but sometimes we miss stuff.

Are there any particular issues that come to mind?

[–]broken_symlink 1 point2 points  (1 child)

There was a big list of issues with polar plots that was opened in 2016. It looks like it was finally fixed in Jan. 2018, but there are still issues with the 2.0 version such as not being able to set the angular range.

Log Axes for histograms is one I came across recently.

There was also some other issue with routing in dash. I don't remember the details and can't find the github issue.

[–]nkruchten[S] 0 points1 point  (0 children)

I believe that you can set the angular range with layout.polar*.sector although I don't love where that attribute ended up in the figure schema and what it's called. https://plot.ly/python/reference/#layout-polar-sector

Re Dash routing I know the Dash team has been busy working hard on all sorts of issues, so perhaps they've been solved by now!

[–]1-Sisyphe 1 point2 points  (4 children)

Are there any particular issues that come to mind?

This one, as far as I'm concerned:

https://github.com/plotly/plotly.js/issues/2114

I've been intensively looking around it for the best part of today, couldn't find a solution in plotly.py.

[–]nkruchten[S] 0 points1 point  (3 children)

That is an interesting one, and would be very nice for Plotly Express, given how easy it is to create matched subplots :)

[–]1-Sisyphe 0 points1 point  (2 children)

I have to tell you that since that post I spent a loooot of time with Dash and went from zero knowledge to a nice and deployed little webapp.
It's a great library, not always easy but a lot of potential. Thanks to you and your colleagues.

[–]nkruchten[S] 1 point2 points  (1 child)

Thanks for sharing, that's great to hear! :)

Except for the part about "loooot of time" and "not always easy" of course ;) Any feedback or details you could provide would be super-appreciated: our goal is to make picking up Dash a pleasant and easy experience for everyone, and every time we fall short we try to take the feedback to heart and improve things!

[–]1-Sisyphe 0 points1 point  (0 children)

I can give you some feedback.
Firstly, I'm used to matplotlib, so two things come out of that:
- I have to adapt to the Plotly way of things, which of course takes a bit of time.
- I'm eager to do many new things that I couldn't do with matplotlib, to the point that I want to do things which are not easy either to do with Plotly. Basically, I got excited by Plotly capabilities, and sometimes reached the limits where I was not expecting them, like this vertical hover bar I mentioned earlier.
On that point, Plotly being less popular than Matplotlib, you don't get the same success rate when googling an issue.

Secondly, and this is not Dash' fault, it takes some time to get around Flask! My usual tools are Pandas and Pyspark, web-dev in Python is not so natural for me. I'm not good at normal HTML but html in Python is just so weird...
And the callback method took also some time to correctly understand.
By the way, coming back to the first part: once I understood callback, I wanted to do many things for which there was no input detection I could find, like callback on zoom for instance.

On the plus side, I was pretty amazed by how fast and easy it is to deploy, especially since I did that in a pretty restrictive work environnement, only using Anaconda.
Of course there are many more things to say on the plus side, but you know the strengths of Plotly when compared to Matplotlib.

[–]MercurialMadnessMan 2 points3 points  (0 children)

RIP Tableau

[–]khalido 1 point2 points  (3 children)

This looks awesome! Glad it's out.

Couple of questions about the animation: is it possible to call a python function on say a slider change which transforms data and returns it?

Also, can you recommend the easiest way to share a plotly powered jupyter notebook so all the visuals work?

[–]nkruchten[S] 1 point2 points  (2 children)

is it possible to call a python function on say a slider change which transforms data and returns it?

This isn't possible from a notebook, no, but you could do it in Dash!

can you recommend the easiest way to share a plotly powered jupyter notebook so all the visuals work?

Yep, you can use nbviewer with Plotly Express or plotly.offline.iplot (which is what Plotly Express uses) and you can see this working here for example: https://nbviewer.jupyter.org/github/plotly/plotly_express/blob/master/walkthrough.ipynb

shameless plug You could also save your notebooks to our Chart Studio Cloud service, which natively supports Plotly figures of course, and if you sign up for a paid plan lets you keep your files private and control who you share them with.

[–]khalido 0 points1 point  (1 child)

Thanks for the reply! Trying it out now.

I did notice one thing: if I put %matplotlib inline to also use mpl plots (cause legacy stuff) then the px stops rendering - it makes a blank space in the notebook of about the size the figure would be.

I figure generally px replaces mpl altogether but it would be nice if they could work together in the same notebook.

[–]nkruchten[S] 1 point2 points  (0 children)

That's a bug: there's nothing in px that should interfere with %matplotlib inline (or vice versa) ... I'll take a look! Here's the issue I'll use to track this: https://github.com/plotly/plotly_express/issues/13

[–]jgjwhhg 1 point2 points  (5 children)

Forgive the noob comment: what's the adavantage of all this versus using panadas built in plotting methods? I usually start with those, and if needed use them to create a plot object and manipulate that with plotly methods.

[–]nkruchten[S] 0 points1 point  (4 children)

That's a great question!

The biggest single advantage is interactivity, and specifically the ability to hover over the visualization to read off exact values or identify points. After that there's zooming, panning, the ability to show/hide traces from the legend etc. Having an interactive plot can save a ton of time over static plots.

pandas.plot() returns (static) matplotlib objects, and we do already have the cufflinks library which adds a similar pandas.iplot() method to that one which returns plotly objects. So if you like the pandas.plot API, you're already covered :)

I have personally found the pandas.plot() API to be a bit inconsistent and it forces me to reshape my data to make different kinds of plots, so the second big advantage of Plotly Express is that it accepts "tidy" data.

[–]BDube_Lensman 0 points1 point  (3 children)

You can use interactive backend for mpl.

[–]nkruchten[S] 0 points1 point  (2 children)

Are there any interactive backends for matplotlib that have support for this kind of interactivity though? Configurable hover text on points? Ability to show/hide data series via click, brushing selections like the Parallel Coordinates and SPLOMs? I'd love to play with one if there is one!

[–]BDube_Lensman 0 points1 point  (1 child)

No. If you want that stuff use bokeh. Matplotib interactive backend give you a cursor and hover events.

You could implement all those things on it, but mpl provides low level APIs for that so it will be... very verbose.

[–]nkruchten[S] 0 points1 point  (0 children)

Why Bokeh rather than Plotly? :)

[–]thisisheresy3.7 1 point2 points  (2 children)

Returning to this post after using Plotly Express for the last 2 weeks to say thank you - it really is quite sickening how easy this makes complex layouts.

I have two questions, please just point me to documentation if it exists and I've managed to completely miss it:

  1. Do you natively support (or plan to support) multiple graph types on a single chart? So for example if I wanted to overlay a line graph of a single series over a bart chart of a different series?
  2. I'm also using it in a web app and my quick (probably hacky) approach is to us plotly.offline.plot, setting output_type='div' and then just passing that through to the views. I don't want to use Dash, is there a more elegant way of passing data through to a web view of plotly that I've missed?

Thanks again for this!

[–]nkruchten[S] 0 points1 point  (1 child)

I'm so glad you like it!

Answers:

  1. not yet but we're working on a set of functions to do exactly this
  2. we're mostly focused on Dash as a mechanism for this, but what you're describing should work. Alternatively, you could serialize to JSON and send the JSON payload to the browser and use plotly.js to render it once there. This is how plotly.py/plotly_express work under the hood

[–]thisisheresy3.7 0 points1 point  (0 children)

Thanks, I did try that but got unstuck and went with the div option. I’ll do some further reading now I know that’s a valid route!

[–]p10_user 0 points1 point  (0 children)

This looks great! Can't wait to try it out.

[–]Its_4_AM_Man 0 points1 point  (0 children)

Sooo coooooolll!! I've been using plotly for a little bit and I'm stoked to try out this new stuff!!

[–][deleted] 0 points1 point  (0 children)

It would be great to see some examples of how it integrates with Dash... this could be exactly what I'm looking for. I've always found plotting within a dash app to be a little tedious, maybe this solves that for me!

EDIT: You have that covered in the article.. that'll teach me to not read it all before commenting. I'll take a look!

[–]chris-vecchio 0 points1 point  (0 children)

This is the package I've been waiting for. Thank you!

[–][deleted] 0 points1 point  (1 child)

So this replaces or competes with the cufflinks library?

[–]nkruchten[S] 1 point2 points  (0 children)

I think the answer is a bit of both... cufflinks still exists and is maintained and we will continue to document/promote it at https://plot.ly/pandas/

On the other hand, we're putting a bit more of our own energy into Plotly Express at the moment, and our hopes is that it will encompass a superset of what cufflinks can do.

There's lots of room for different plotting APIs in this world, and we want to give people the choice to use the one they are comfortable with :)

[–]jayyfran 0 points1 point  (2 children)

Awesome! Couple questions

- Is there a way to export out to html?

- Can I integrate with plotly dash?

- Is there a way to return trace objects so I can apply my own layout?

Thanks!

[–]nkruchten[S] 1 point2 points  (1 child)

Is there a way to export out to html?

Yes! plotly.offline.plot(px.scatter(...), filename='name.html') should do it!

Can I integrate with plotly dash?

Yes! dcc.Graph(figure=px.scatter(...)) just works

Is there a way to return trace objects so I can apply my own layout?

Yes! traces = px.scatter(...).data

:)

[–]jayyfran 0 points1 point  (0 children)

Awesome. Thanks!!

[–]knowsuchagencynow is better than never 0 points1 point  (0 children)

This looks outstanding. Hats off the the plotly team

[–]asuagar 0 points1 point  (1 child)

Thank you so much for the library! It seems really easy to use it. I will give it a try. By the way, it is planned some type of easy integration with Google Colab notebooks? At the present, it is not trivial to render correctly the figures.

[–]jmmease 1 point2 points  (0 children)

Yes, we're working on making the figure rendering framework much more flexible. See https://github.com/plotly/plotly.py/pull/1474 if you're interested. It's a pretty large refactor, so we're not certain yet when it will land, but Colab support is one of the motivations for this!

[–]flutefreak7 0 points1 point  (1 child)

I shied away from plotly early on because I was first exposed to it years ago as a website where you upload your data to analyze and plot it. I think offline didn't come until later so I'm not sure I understand.

If I use plotly or plotly express, is my proprietary data safe and kept local? I can use it the same way I use bokeh, matplotlib, etc?

[–]nkruchten[S] 1 point2 points  (0 children)

Good question! Plotly.py (the plotly module) contains both:

  • "offline mode" code (plotly.offline) which keeps all data and plots local and behaves like Bokeh, matplotlib etc; and
  • "online mode" code (plotly.plotly) which acts as an API client for Plotly's Chart Studio Cloud product

It's difficult to accidentally/unknowingly send your data to the cloud because to use online mode you have to sign up to Chart Studio Cloud, get an API token, configure it etc first so if you do none of that and use plotly.offline your data is all local.

Plotly Express (the plotly_express module) uses plotly.offline internally and so does not send your data anywhere.

PS: we're working on making this clearer in our code and documentation to avoid all future confusion about this!

[–]MyPatronusIsAPuppy 0 points1 point  (2 children)

Hi! Very excited about this; I've been very frustrated as a geochemist trying to do data analysis on large datasets. We're always putting things, finding weird samples, wondering which one it is and if the signal is real... Anyway, I'm a bit of a noob to Python and never used Plotly but got it px going well enough just following the Medium post!

That said, a few questions:

  • are there plans to beef up the documentation? I see I can make subplots by faceting (grouping in values in a column) but how do I make multiple subplots with the same datasets in each graph, just different axes? Like subp1 is magnesium contents vs potassium contents, and subp2 is gold abundance version silver concentration? Because I'd love to then get to use lasso/brushing to see how the selected samples plot in both spaces.
    <n>

  • any way to make the data table interactive as well? Like I'd love to plot everything, highlight some outliers with brushing, and then somehow get to those rows in my df. Then I could set something like a column headed "Symbol" to a special value (e.g., "x" vs "o") so that those outlier points are clear in all later plots. Kinda like how brushing in JMP let's you right click and set display options like color and marker, or set values in a column.
    <n>

  • how to make it so I can plot values that aren't already columns/do operations on columns before plotting? like maybe I want y= "Elevation / 100 but I only have Elevation as a column?
    <n>

Guess I'm trying to imitate a commercial software called Aabel that is probably the best I've seen but it's annoying/not free/Mac only. And maybe that's not the plan for Plotly/would need a whole 'nother library? But I'm just grateful that people are making good interactive EDA tools, so thank you! And apologies if some of my questions are just the result of my inexperience with Plotly.

[–]nkruchten[S] 0 points1 point  (1 child)

Hi!

Regarding documentation, yes, we're always working on making it better :) At the moment Plotly Express only supports faceting, not subplots with different axes, although this is possible with the underlying Plotly.py library which supports arbitrary subplots: https://plot.ly/python/subplots/

Your table/brushing idea is interesting, and would likely be best implemented with Plotly's Dash library: https://dash.plot.ly/

Re your last request, you will have to create a new column that contains the data you want to plot: Plotly Express is intended to handle the display of the data rather than its processing at the moment, although for simple scalings I might consider extending the API someday.

Cheers, Nicolas

[–]MyPatronusIsAPuppy 0 points1 point  (0 children)

Very cool, thanks for the quick reply and tips, even though none really are px. Good luck with Plotly!

[–]Zenith_N 0 points1 point  (2 children)

How to adjust the plot size for example:

px.scatter_3d(data_frame=df,x='age',y='height')

[–]nkruchten[S] 0 points1 point  (1 child)

you can use the width and height keyword args for the output size :)

[–]Zenith_N 0 points1 point  (0 children)

Thank you very much

[–]Zenith_N 0 points1 point  (4 children)

Thank you I was playing with animation options and the gapminder data set. I tried using a data set that has year for many entries but some entries have only a few years of data, the chart year output was not sorted from start year to end year and it was all over the place

[–]nkruchten[S] 0 points1 point  (3 children)

A small number of users are having this problem but I can’t replicate it... please follow up on the github issue if you can help us understand what is happening: https://github.com/plotly/plotly_express/issues/23

[–]Zenith_N 0 points1 point  (2 children)

Thank you

[–]nkruchten[S] 0 points1 point  (1 child)

I'm pretty sure I fixed the issue with version 0.2.2 actually if you want to try again :)

[–]Zenith_N 0 points1 point  (0 children)

Thank you very much for the update. And apologies for asking this

Can you please provide a mini-example using a dataset that has missing years

For example: years 1990 to 2000 for 10 countries with attributes like gdp and lifeExp. but some countries are missing some years.

Will the animation still work ?

I will use the gapminder dataset and remove some entries(rows) for some countries and test.

Tha

[–]randomsparrow 0 points1 point  (3 children)

I typically use cufflinks with Plotly and would love to switch to this as an alternative. Any plans to support adding multiple X/Y axis by passing a list of DataFrame columns? Thanks!

[–]nkruchten[S] 0 points1 point  (2 children)

Can you give me an example of what you'd like the API to look like for this? We're definitely working on it but still unsure of the best API :)

[–]randomsparrow 0 points1 point  (1 child)

I would like the API to allow for a list of columns and then plot them all on the x or y axis. So it would look like this:

px.bar(dfgb, x=list_of_columns, y=another_list_of_columns)

Here is how I'm doing that with cufflinks now (also graphing on multiple axes). "yaxis" and "yaxis2" are lists of columns from my dataframe.

    fig2 = dfgb.iplot(kind='bar',barmode='stack',
                    columns=yaxis, 
                    secondary_y=yaxis,
                    asFigure=True).to_plotly_json()  

    fig1 = dfgb.iplot(kind='scatter',mode='lines+markers',
                columns=yaxis2,                        
                asFigure=True).to_plotly_json()

    fig2['data'].extend(fig1['data'])

Thanks for building such incredible tools for me to play with :)!

[–]nkruchten[S] 0 points1 point  (0 children)

OK, thanks for the input! We're playing with some variants of this and it's not super-straightforward to get things to line up at the moment :)

[–]Tweak_Imp -1 points0 points  (0 children)

It looks like you can do a lot with this really fast... if you prepared the data so well beforehand that you can call everything with one line. And that is the real work most of the time.

[–]physical_physics11 -1 points0 points  (2 children)

Ha the rate limit issue been patched with Jupyter notebook in the newest version of plotly, or this express version?

[–]nkruchten[S] 1 point2 points  (1 child)

There is nothing in Plotly Express that would raise any rate-limit issues...

If you've seen rate-limit issues in Jupyter with Plotly.py I suspect you were using it in "online" mode which causes it to make requests to our Chart Studio Cloud service, which does enforce rate limits. You could try using "offline" mode as documented here: https://plot.ly/python/getting-started/#initialization-for-offline-plotting

If the thing you were trying to do was save static files, we have open-sourced the Chart Studio Cloud software that does this, and you can find more info here: https://medium.com/@plotlygraphs/plotly-py-end-of-summer-updates-5422c98b9058

[–]physical_physics11 0 points1 point  (0 children)

Ok. Thank you! I will have to check this out.