对于像(x^2+y^2-1)^3=x^2*y^3
这样的等式,我使用emdbook,
library(emdbook)
> curve3d((x^2+y^2-1)^3-x^2*y^3,
+ sys3d="contour",level=0,from=c(-10,-10),to=c(10,10),
+ drawlabels=FALSE,axes=FALSE,xlab="",ylab="")
如何在R中绘制(x^2+y^2-1)^3=x^2*y^3
?
答案 0 :(得分:3)
如果从另一侧减去等式的一边,因此解决方案为0,您可以使用outer
计算z
值的网格,contour
可以情节:
x <- seq(-2, 2, by = 0.01) # high granularity for good resolution
z <- outer(x, x, FUN = function(x, y) x^2*y^3 - (x^2+y^2-1)^3)
# specify level to limit contour lines printed
contour(x, x, z, levels = 0)
或使用tidyverse,
library(tidyverse)
crossing(x = seq(-2, 2, by = 0.01),
y = x) %>%
mutate(z = x^2*y^3 - (x^2+y^2-1)^3) %>%
ggplot(aes(x, y, z = z)) +
geom_contour(breaks = 0)