简体   繁体   English

如何在R中绘制图形?

[英]how to draw the graph in R?

I can get photo11 with the following code,how can i fix my code to change photo1 into photo2? 我可以使用以下代码获取photo11,如何修复将photo1更改为photo2的代码?

x = seq(0.5, 0.9, length = 200)
y = dnorm(x,0.7,0.0458)
plot(x, y,type="l",xlab="my_x_lab")

this is a photo1.jpg 这是一个photo1.jpg 在此处输入图片说明

this is a photo2.jpg 这是一个photo2.jpg 在此处输入图片说明

and ,how to fix my code to change photo2.jpg into photo3.jpg?there are 并且,如何解决我的代码将photo2.jpg更改为photo3.jpg?
only two scales(0.7,0.8) in the x_lab. x_lab中只有两个比例(0.7,0.8)。
this is a photo3.jpg 这是一个photo3.jpg
在此处输入图片说明

to fix the code to get rid of y in the y_lab to change photo3.jpg into photo4.jpg? 修复代码以摆脱y_lab中的y将photo3.jpg更改为photo4.jpg? this is a photo4.jpg. 这是一个photo4.jpg。 在此处输入图片说明

This will do it. 这样就可以了。 xaxt='n', ann=FALSE removes the x-axis and annotations. xaxt='n', ann=FALSE删除x轴和注释。 axis(...) puts the x-axis only at the specified points. axis(...)仅将x轴放置在指定点上。 mtext() will put marginal text on the bottom axis. mtext()会将mtext()文本放在底轴上。

x <- seq(0.5, 0.9, length = 200)
y <- dnorm(x,0.7,0.0458)
plot(x, y, type="l", xaxt='n', ann=FALSE)
axis(1, at=c(0.7, 0.8))
mtext("my_x_lab", 1, at=0.9, line=2)

例

Suppress the x axis and add blanks for the labels where you do not want them. 抑制x轴,并在不需要标签的地方添加空白。

plot(x, y, type="l",  yaxt="n",ann=FALSE,bty="n", xaxt="n")
axis(1, at=c(0.5, 0.6, 0.7, 0.8, 0.9), labels=c("", "", 0.7, 0.8, 0.9) )
mtext("Proportions", 1, at=0.9, line=2)

在此处输入图片说明

If you insist on omitting the ticks in the left hand side its going to be more difficult because the base line will only extend from the first tick. 如果您坚持要省略左侧的刻度线,这将更加困难,因为基线只会从第一个刻度线开始延伸。

Except this answer is better than mine. 除了这个答案比我的要好。

how to draw the graph in R? 如何在R中绘制图形?

I guess it means this is homework? 我想这意味着这是家庭作业吗? Oh NOOOO, it's the same poster... you are posting duplicate questions? 哦,不,这是同一张海报...您要发布重复的问题? Bad poster , bad poster. 不好的海报,不好的海报。 Shame on you. 你太无耻了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM