我想使用 R 生成如下图:
https://dl.dropboxusercontent.com/u/9297902/R_desired_output.png
量表从左边的 0 到右边的 100,每个主要类别(差、一般等)占 25%。我想我需要: 1. 为颜色制作多个背景框(#D55E00、#E69F00、#56B4E9、#009E73) 2. 更改网格线颜色、位置(从我的 y 类别值到它们之间)和厚度 3。选择一个合适的符号(允许我有轮廓并用条形填充?) 4. 以更可控、可预测的方式将标签放置在图表顶部(差、一般、好、优秀)
这是我到目前为止的位置:
# assemble data
metric<-c("Bottom Substrate","Deposition",
"Substrate Stability","In-stream Cover",
"Pool Substrate","Pool Quality",
"Pool Variability","Channel Alteration",
"Channel Sinuosity","Width/Depth",
"Hydrolic Diversity","Canopy Cover",
"Bank Vegetation","Immediate Land Use",
"Flow Related Refugia")
score<-c(10.53,18.18,13.33,9.09,
26.32,6.67,6.67,57.14,
18.18,40.00,27.27,
9.09,73.33,71.43,27.27)
hab<-data.frame(metric,score) #create data frame
library(ggplot2)
# colorblind friendly colors
# #000000 # Black
# #E69F00 # Orange
# #56B4E9 # Sky Blue
# #009E73 # bluish Green
# #F0E442 # Yellow
# #0072B2 # Blue
# #D55E00 # Vermillion
# #CC79A7 # reddish Purple
# set up to remove x axis values, and axis titles
theme_mod <- theme(axis.text.x = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_blank())
qplot(score,metric) +
geom_point(aes(score,metric), size=6, pch="|") + # pch gets the symbol I want, how to lose the dot?
scale_x_continuous(limits=c(0,100)) + # locks scale to be 0-100, whcih I want
opts(title="Poor Fair Good Excellent") +
theme_mod # removes axis stuff
所以,我还没有准备好去。由于某种原因,它似乎也重新排序了我的数据集。
我在这里寻找可能性,但我不确定该走哪条路:
在 R 中使用 ggplot2,如何在不同区域使图形的背景颜色不同?
抱歉,我有点新手 - 在此先感谢您的任何指点。