【问题标题】:How to plot figure using ggplot2? [closed]如何使用ggplot2绘制图形? [关闭]
【发布时间】:2016-03-20 00:31:15
【问题描述】:

我有以下数据。

 Variables  Cropland Forest  Shrub   Urban   Water  Baresoil MeanDecreaseAccuaracy MeanDecreaseGini
 band1       23.152  14.686  30.012  26.866  12.976    9.767                33.991          142.946
 band2       23.359  19.116  30.077  23.961  14.120   11.793                32.729          165.892
 band3       24.835  21.590  17.912  18.490  14.806   23.961                32.254          169.372
 band4       25.709  34.052  20.737  23.170  13.894   25.297                36.721          209.631
 band5       20.158  29.281  24.762  25.535  18.537   14.182                36.525          141.047
 band6       32.447  25.134  24.800  35.590  22.485   16.168                40.496          232.536
 band7       26.135  41.411  36.753  26.935  19.767    9.806                39.886          226.782
 band8        2.460   1.930   1.872  -0.434  -0.088    4.831                 4.315            5.334

现在,我想用这些数据来绘制下图

.

【问题讨论】:

  • 你应该做一些你自己的工作。 SO 不是代码编写服务。
  • 编辑后,问题没有改善到我想重新打开它的地步。对不起。请在您的问题中包含MCVE。
  • 对不起。我为我的身材做了一些工作,但效果不好。

标签: r ggplot2 figure


【解决方案1】:

您所指的情节不是使用ggplot2 制作的,而是使用lattice 库制作的。您可以在Quick-R website 上找到一些使用lattice 的示例。下面我引用本站提供的代码示例和输出图:

library(lattice)
attach(mtcars)

gear.f<-factor(gear,levels=c(3,4,5),
   labels=c("3gears","4gears","5gears"))
cyl.f <-factor(cyl,levels=c(4,6,8),
   labels=c("4cyl","6cyl","8cyl")) 

bwplot(cyl.f~mpg|gear.f,
   ylab="Cylinders", xlab="Miles per Gallon",
   main="Mileage by Cylinders and Gears",
   layout=(c(1,3)))

【讨论】:

  • 亲爱的反对者——为什么是-1?
  • 只是一个随机猜测(否决投票的动机可能非常随机),但有些人不喜欢糟糕的问题得到好的答案。他们认为这会鼓励更多人提出可怕的问题。
猜你喜欢
  • 2017-09-27
  • 1970-01-01
  • 1970-01-01
  • 2013-06-08
  • 1970-01-01
  • 1970-01-01
  • 2013-04-08
  • 2023-03-22
  • 1970-01-01
相关资源
最近更新 更多