R Barplot with one bar - how to plot correctly

后端 未结 2 1679
别那么骄傲
别那么骄傲 2021-01-26 11:09

I want to plot a regular bar plot in R, but with just one bar. What I don\'t like is the fact that the bar width gets to be the width of the whole plot. I want the bar to be \"t

2条回答
  •  粉色の甜心
    2021-01-26 11:19

    The width argument to barplot says:

    width optional vector of bar widths. Re-cycled to length the number of bars drawn. Specifying a single value will have no visible effect unless xlim is specified.

    So specify both width and xlim. The interaction of these two is not obvious (to me) so you will probably need to play around with them until they look like you want them to.

    percentage <- 0.25
    barplot(percentage, width=0.2, xlim=c(0,1.2), col="brown4")
    

    enter image description here

提交回复
热议问题