Anvil Community Forum

Plotly 4: It's Here!

This has been such a popular feature request that I’m posting a quick announcement, rather than waiting for the March Update: We have upgraded Anvil to Plotly version 4!

It’s backwards-compatible, so your existing code still works, but you can now take advantage of Shapes, distplots, plotly.express, subplots, figure_factory, and more! Some of these features are only available in Server Modules (and some of them use numpy, which only works in Full Python), but of course you can return Plotly chart objects from server modules to client code :slight_smile:

Also, to make life easier, Plot components now have a figure property, so you can assign data and layout at once by giving it a Plotly Figure object.

Enjoy!

10 Likes

A few folks have asked for figure_factory-related things, and so I’ve tried importing it. The module appears to not exist (with from plotly import figure_factory and import plotly.figure_factory). Seeing the same thing for subplots and express.

Am I missing something obvious about how to import these Plotly modules?

Edit: I assume that these use numpy and therefore those Plotly modules need to be accessed from the server.

1 Like

That’s right - figure_factory is a server-side library that uses numpy. Use it in an @anvil.server.callable function, then return the figure to client code and put it into the figure property of a Plot component.

1 Like

A post was split to a new topic: Slow Figures and Plots

Woohooo

Thanks very much Anvil team. This will open up a lot of functionality for plotting!