how to draw the graph in R?

后端 未结 2 382
情歌与酒
情歌与酒 2021-01-26 06:13

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,         


        
相关标签:
2条回答
  • 2021-01-26 06:42

    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)
    

    example

    0 讨论(0)
  • 2021-01-26 06:52

    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)
    

    enter image description here

    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.

    0 讨论(0)
提交回复
热议问题