我正在使用 R 編程語言。
我正在嘗試為以下功能制作等高線圖:
library(plotly)
my_function <- function(x,y) {
final_value = x^2 y^2
}
input_1 <- seq(-1.5, 1.5,0.1)
input_2 <- seq(-1.5, 1.5,0.1)
z <- outer(input_1, input_2, my_function)
plot_ly(x = input_1, y = input_2, z = z) %>% add_surface()

我正在嘗試按照此處鏈接中的說明進行操作:
有人可以告訴我我所做的是否正確嗎?這是使用 ggplot2 為函式制作等高線圖(水平圖)的方式嗎?
我持懷疑態度的原因是因為我試圖為一個完全不同的函式重復這個程序(
z <- outer(x1, x2, my_function)
plot_ly(x = x1, y = x2, z = z) %>% add_surface()

I don't think this is correct - both functions look entirely different and I doubt they would have the same contour plots. This makes me skeptical and think that I am doing something wrong.
Thanks!
Note: Ideally, the contour plot of the second function should look something like this: 
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/443287.html
標籤:r ggplot2 data-visualization
上一篇:雙條形圖比較兩個分類變數
