楼主: yijingqi
15835 14

[问答] R怎么画函数y=tanx+siny+x的图 [推广有奖]

11
zhangyangsmith 发表于 2014-2-25 20:08:24
A contour plot is just a 2D way of presenting a 3D plot by drawing curves on which z=f(x,y) has the same value. Here the option "levels = 0" ensures the points (x, y) on the curve has the z value of 0. Normally more than one such curves will be drawn to show different contour curves corresponding to different z values, or levels. And I added the option "labcex=0" and "labels = """ just to eliminate the labels completely. Otherwise there will be "0" or short breaks on the curve which I hate.
另外运行此程序后, 我的显示中间为 白板。怪~
I have no clue why this happened. But I did have issues running the "outer" function in the scripts where huge amount of memory was required. I had to change the resolution of both x and y dimensions to produce the plot.

12
jmpamao 发表于 2014-2-25 20:25:54
zhangyangsmith 发表于 2014-2-25 20:08
A contour plot is just a 2D way of presenting a 3D plot by drawing curves on which z=f(x,y) has the  ...
x,y的维度,已经改小了。但仍然不行。看不到中间的图

好比现在这个:
my.fun <- function(x,y){y - sin(y) - x - tan(x)}
x<-seq(-5, 5, by = 0.01)
y<-seq(-50, 50, by = 0.1)
z<-outer(x,y,my.fun)
options(max.contour.segments=50000)
contour(x, y, z,levels=0, labels="", labcex=0, xlab = "x", ylab = "y")

13
zhangyangsmith 发表于 2014-2-25 20:58:11
Will this work?
  1. contour(x, y, z, levels = 0, drawlabels = 0, xlab = "x", ylab = "y")
复制代码
已有 1 人评分学术水平 热心指数 收起 理由
jmpamao + 1 + 1 这个可以了~

总评分: 学术水平 + 1  热心指数 + 1   查看全部评分

14
jmpamao 发表于 2014-2-25 21:09:49
给个截图你看吧

soweird.jpg (2.82 KB)

soweird.jpg

15
粉红粉红的下雨天 发表于 2017-12-30 19:29:54
jmpamao 发表于 2014-2-24 16:58
这个 模拟就ok了
比如
x
请问如果只是画y=cosx的代码是怎样的?

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-26 06:08