至于像(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,你可以使用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)