简体   繁体   中英

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?

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 在此处输入图片说明

this is a photo2.jpg 在此处输入图片说明

and ,how to fix my code to change photo2.jpg into photo3.jpg?there are
only two scales(0.7,0.8) in the x_lab.
this is a photo3.jpg
在此处输入图片说明

to fix the code to get rid of y in the y_lab to change photo3.jpg into photo4.jpg? this is a photo4.jpg. 在此处输入图片说明

This will do it. xaxt='n', ann=FALSE removes the x-axis and annotations. axis(...) puts the x-axis only at the specified points. mtext() will put marginal text on the bottom axis.

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.

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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