如何绘制方程(x ^ 2 + y ^ 2-1)^ 3 = x ^ 2 * y ^ 3?

问题描述 投票:2回答:1

至于像(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="")  

但得到错误的情节enter image description here

如何在R中绘制(x^2+y^2-1)^3=x^2*y^3

r
1个回答
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)

© www.soinside.com 2019 - 2024. All rights reserved.