Multiple traces on the same plot axes

Good evening all,

I’m trying to plot more than one column from a data table as my Y variable in a line plot. I have a log of dates, temperature and humidity stored in a Data Table which I would like to plot. I’ve had a look at the tutorial docs and examples and can easily plot dates on the X axis with temperature or humidity on the Y axis. But as yet, I’ve not been able to plot both. Here is the code I’m using to plot. db_data is returned by a server function that accesses the data table.

    self.plot_latest.data = go.Scatter(
      x = [x['record_date'] for x in db_data],
      y = [x['temperature'] for x in db_data]
    )

Is there a simple way to add another trace to this plot, with a secondary Y axis on the right?

Something like this, which I plotted in a Datalore notebook with plotly:

Unfortunately, to do this in plotly relies on libraries not available on the Anvil Free Tier. I also tried doing to do the plotting work on a Raspberry Pi using Uplink, but encountered all sorts of errors when trying to return a figure object.

Any pointers would be welcome.
Many thanks
Jon

sure it’s possible

here’s a simple adapted version adapted from the plotly docs https://plotly.com/python/multiple-axes/
with anvil

Screen Shot 2020-05-27 at 08.14.38

https://anvil.works/build#clone:26J34T62IPY3Y75J=2OREBD5ZZW5DSMQ7A7JBSFCX

2 Likes

Wow, that was so easy. I feel a bit daft for even asking now.
Thank you!