✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🧬 Learn how to build RNA-Seq data apps with Python & Dash. Register for the May 20 Webinar!

Overlaying contour plots


I have a contour plot and I want to draw the zero isoline / contour line at value 0 of another plot on top of it to be able to compare the two plots:
(For this example the curve was added manually.)

1.: Is there a way to overlay contour plots?

If not:
2.1: Can I draw points/lines onto a contour plot?
2.2: Can I extract the contour line that plotly found into an array or similar? I tried extracting it with marchingsquares-isocontours.js but that gave me unsatisfactory results, with interrupted or missing lines.

The ranges of my axes are the same for every sample.

Thanks in advance!

This is how I would go about this: https://codepen.io/etpinard/pen/mKMqMP?editors=0010

1 Like


I never questioned why there were brackets around the data:
var data = [ { z: [[1, 20, 30], [20, 1, 60], [30, 60, 1]], type: ‘heatmap’ }];

Now it makes sense: It’s an array. In most of the examples the array has just one element but you can add more.
I was looking for a solution for two days but I was blind on that eye.

Thank you so much! And if you coded this example just for me - and it looks like you did - thank you even more!

1 Like

Isn’t that the easier way to show something? That took me 30 seconds, so no sweet. Thanks for writing in!

One more thing: Is it possible to add more layers/curves at a later point in time or do I have to redraw the whole thing?

See https://plot.ly/javascript/plotlyjs-function-reference/#plotlyaddtraces

1 Like