Reputation:
I would like to have a contour plot that shows where the ratio of the response is 1.
x axis is saturation, y axis is temperature and z is the ratio of spA1 to spA2
I can do this in ggplot2 but all my other figures are in plotly and I would like to be able to eventually overlay other lines and have a secondary axis which plotly does really well.
can this be done in plotly?
I have tried this in ggplot 2 using geom_raster and geom_contour(breaks=1) and it works but I tried in plotly using add_trace(z=1, type = "scatter", mode = "line")) and it just draws weird lines everywhere...
Data: https://www.dropbox.com/s/gjdr5uuys6tqswr/df.csv?dl=0
Ratio <-(spA1/spA2)
#this works
Ratio <- ggplot(Ratio, aes(x = Saturation, y = Temp, z =
Ratio, fill = Ratio)) + geom_raster(interpolate = T) +
geom_contour(breaks = 1, colour="black", size=1) + theme(plot.title
= element_text(size = 12)) +
scale_fill_gradientn(colors=c("red","white","blue"),
values=rescale(c(0,1, 3)))
#this doesn't work
Ratio <- plot_ly(Ratio, x = ~ Saturation, y = ~ Temp, z =
~Ratio, type="contour", colorbar = list(title = "Ratio"),
colorscale = list(
c(0,1,2),
c("red", "white", "blue"))) %>%
add_trace(z=1, type = "scatter", mode = "line")
Is it possible to do this in plotly? I would like to do a few of these lines and overlay them in plotly with a secondary axis. Thank you in advance!
Upvotes: 1
Views: 730
Reputation:
I figured it out. It's
colorscale = "RdBu", contours = list( start = 1, end = 1, coloring='heatmap',
coloring='lines'), line = list(color = 'black', width = 2)))
Upvotes: 2