Plotly Question

I am experimenting with options for displaying hierarchy data using Treemaps initially. I’d like to use some packed circles, but for now I’m looking at treemaps as they are in Plotly Express.

I’m not sure I understand the options I have. Can someone help me confirm what I think I’ve found.

  1. Plotly Express only runs on the server side.
  2. Plotly graph_objects can run in the client, but it appears only Bar Charts and Line graphs have been ported to the client. I would like to get the example I’m using in plotly express working in graph_objects for comparison.
  3. It is possible to use other visualization libraries that are based on D3.js, but more extensive setup would be needed.n

As an aside I’m somewhat concerned about the speed of getting the objects from the server on a very simple example I have running now with plotly express.

I’m on a paid hobby plan with a custom domain. Feel free to look at riskdemo.ashlind.com. The VaR Results page has a simple treemap on it.

Thanks in advance.

  1. You can return a plotly express figure to the client and then assign this to the Plot instance’s figure attribute
# client

    self.plot_1.figure = anvil.server.call("get_figure")
# server

@anvil.server.callable
def get_figure():
    import plotly.express as px
    df = px.data.iris()
    fig = px.scatter_3d(df, x='sepal_length', y='sepal_width', z='petal_width',
                color='species')
    return fig

  1. Pretty much anything you can do in plotly express you can do with plotly graph objects, but it’s not always obvious how to do it. The plotly docs don’t alway show you how. But take a look at this related question:

  1. Plenty of people have used other visualization libraries. You’ll want to find a javascript library and then use the javascript ↔ python bridge to get it to work with anvil.

Here’s an example from our blog:

Thanks for the quick reply.

  1. I was able to figure out the plotly express and have some treemaps working with some sample data.
  2. If I read things right, if I can get the graph objects working, I’ll be able to do less on the server and I can get some circle packing examples to work. These are not part of the plotly express choices.
  3. Hoping not to have to go to the d3 libraries directly - at least not now.

Thanks for the examples - I’ll see what I can do - for 2) I had not seen any examples that weren’t bar or x-y plots, so I didn’t know if there are limits to what was in the client side implementation in anvil.