Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Rでは、方程式で与えられた2D曲線をプロットする方法はありますか? たとえば、方程式 x^2 - 3*y^2 + 2*x*y - 20 = 0 で与えられる双曲線をどのようにプロットできますか?
を使用contourして、双曲線の 2 つの分岐をプロットできます。
contour
f <- function(x,y) x^2 - 3*y^2 + 2*x*y - 20 x <- y <- seq(-10,10,length=100) z <- outer(x,y,f) contour( x=x, y=x, z=z, levels=0, las=1, drawlabels=FALSE, lwd=3 )
記録のために - ggplot バージョン
library(ggplot2) library(dplyr) f <- function(x,y) x^2 - 3*y^2 + 2*x*y - 20 seq(-10,+10,length=100) %>% expand.grid(x=.,y=.) %>% mutate(z=f(x,y)) %>% ggplot + aes(x=x,y=y,z=z) + stat_contour(breaks=0)