1

I'm trying to create a contour plot in R from 3 vectors.

I have:

x=c(1,1,1,2,2,2,3,3,3)
y=c(0,10,20,0,10,20,0,10,20)
z=c(900,800,700,600,500,400,300,200,100)

And I want to plot something like that (made in SigmaPlot) enter image description here

How can I do it in R?

4

1 回答 1

6

您可以使用plotly包:

x=c(1,1,1,2,2,2,3,3,3)
y=c(0,10,20,0,10,20,0,10,20)
z=c(900,800,700,600,500,400,300,200,100)
df <- data.frame(x=x,y=y,z=z)

library(plotly)    
p <- plot_ly(data = df, x=~x,y=~y, z=~z, type = "contour", colorscale='Jet')

这会给你:

> p

在此处输入图像描述

于 2017-06-21T15:23:04.853 回答