使用ggplot2和geom_bar

时间:2016-03-17 18:24:54

标签: r plot ggplot2 gradient

我正在用ggplot2建立一个条形图,代码如下。关于这个情节,我有两个问题。为什么'+ scale_y_log10()'在图的其余部分下方创建奇怪的0值?可以删除吗?并且在使用ggplot2和'geom_bar''填充'时,如何更改渐变的颜色可能是一个更简单的问题?我是新工作的ggplot2所以语法不是最简单的,非常感谢任何帮助。

更新: 我找到了渐变的修复程序..继承人对我有用吗

bPlot + scale_fill_gradient2(low = "grey", mid ="lightgrey", high = "blue")

R代码:

# ggplot2 
bPlot <- ggplot(dat, aes(1:nrow(dat), dat$coverage, fill = dat$uniqueness)) + geom_bar(stat = "identity") + scale_y_log10()
bPlot + ylab("Coverage") + xlab("Length") + ggtitle("Covrage & Uniquness") + theme_bw()

ggplot2

  

dput(DAT)   结构(list(coverage = c(0L,0L,0L,0L,0L,0L,0L,0L,0L,   0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,   0L,0L,0L,0L,0L,0L,0L,0L,0L,2L,2L,2L,2L,2L,2L,2L,   2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,   2L,2L,2L,2L,2L,2L,2L,2L,2L,174L,173L,172L,171L,171L,   172L,172L,170L,170L,168L,169L,169L,168L,169L,175L,0L,   0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,   0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,   279L,276L,278L,279L,277L,276L,282L,286L,291L,269L,269L,   264L,269L,277L,276L,276L,273L,275L,277L,279L,277L,275L,   271L,265L,265L,240L,240L,242L,242L,241L,239L,239L,240L,   229L,221L,213L,210L,222L,222L,223L,225L,227L,229L,238L,   239L,239L,243L,243L,243L,243L,245L,250L,247L,248L,249L,   250L,253L,252L,254L,257L,258L,265L,269L,274L,269L,258L,   266L,272L,286L,283L,291L,310L,383L,480L,500L,514L,523L,   523L,523L,525L,527L,528L,529L,530L,529L,531L,531L,527L,   521L,469L,424L,412L,413L,412L,410L,410L,409L,405L,403L,   402L,402L,400L,408L,408L,410L,410L,406L,408L,407L,407L,   402L,397L,393L,394L,394L,388L,390L,390L,390L,391L,394L,   394L,396L,394L,381L,383L,382L,382L,385L,411L,410L,412L,   408L,403L,401L,396L,397L,397L,395L,399L,398L,399L,398L,   395L,396L,399L,1035L,4068L,4058L,4046L,361L,359L,356L,   353L,352L,363L,363L,346L,343L,336L,332L,329L,327L,309L,   306L,306L,301L,300L,310L,315L,337L,339L,354L,354L,354L,   354L,354L,356L,354L,351L,354L,344L,343L,336L,334L,331L,   326L,323L,281L,258L,245L,234L,152L,40L,2473L,2446L,   1428L,1449L,1467L,1488L,1249L,1250L,1251L,1201L,1206L,   1211L,1213L,1215L,1175L,132L,124L,108L,111L,129L,134L,   140L,144L,155L,167L,170L,170L,174L,174L,174L,173L,176L,   177L,177L,180L,135L,137L,137L,140L,141L,146L,146L,146L,   141L,141L,141L,141L,142L,141L,141L,145L,145L,146L,145L,   147L,147L,148L,155L,156L,157L,157L,156L,155L,154L,155L,   155L,166L,167L,167L,167L,169L,169L,172L,176L,185L,191L,   188L,195L,195L,200L,201L,202L,205L,214L,224L,231L,235L,   239L,239L,239L,233L,238L,240L,242L,0L,0L,0L,0L,0L,   0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,   0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,   0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,194L,189L,173L,158L,   161L,164L,165L,165L,165L,166L,167L,167L,167L,162L,156L,   158L,158L,153L,154L,155L,155L,153L,152L,154L,154L,157L,   158L,161L,850L,851L,852L,852L,859L,856L,852L,854L,846L,   854L,155L,155L,156L,162L,174L,184L,191L,192L,191L,195L,   197L,202L,205L),唯一性= c(1,1,1,1,1,1,1,1,1,   1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,   1,1,1,1,0.956522,0.96,0.961538,0.961538,0.961538,0.96,   0.966667,0.967742,0.967742,0.96875,0.96875,0.96875,0.96875,   0.96875,0.96875,0.96875,0.96875,0.967742,0.966667,0.966667,   0.96875,0.96875,0.969697,0.969697,0.969697,0.969697,0.969697,   0.969697,0.969697,0.970588,0.970588,0.971429,0.946429,0.95,   0.95,0.95,0.95082,0.949153,0.948276,0.948276,0.948276,   0.949153,0.949153,0.949153,0.95082,0.95082,0.957447,0.931034,   0.928571,0.933333,0.931034,0.931034,0.933333,0.933333,0.931034,   0.931034,0.931034,0.931034,0.931034,0.931034,0.928571,0.928571,   0.925926,0.925926,0.925926,0.925926,0.925926,0.923077,0.925926,   0.925926,0.925926,0.925926,0.925926,0.925926,0.925926,0.925926,   0.925926,0.928571,0.931618,0.931618,0.951613,0.952381,0.952381,   0.953125,0.954545,0.955224,0.955045,0.9554545,0.9554545,0.9554545,   0.953846,0.955224,0.9555882,0.955224,0.9554545,0.955224,0.955224,   0.955224,0.964286,0.964286,0.963636,0.962963,0.962963,0.962963,   0.962963,0.962963,0.962963,0.962963,0.945455,0.963636,0.960784,   0.960784,0.960784,0.960784,0.960784,0.960784,0.969697,0.969697,   0.969697,0.969697,0.970588,0.969697,0.969697,0.96875,0.96875,   0.96875,0.96875,0.96875,0.96875,0.96875,0.96875,0.96875,   0.96875,0.96875,0.96875,0.96875,0.96875,0.96875,0.96875,   0.96875,0.96875,0.969697,0.969697,0.969697,0.969697,0.969697,   0.969697,0.969697,0.96875,0.967742,0.967742,0.967742,0.967742,   0.967742,0.958333,0.9595184,0.959184,0.955333,0.955333,0.958333,   0.958333,0.959518,0.9959184,0.9550184,0.959184,0.959184,0.959184,   0.959184,0.951613,0.951613,0.951613,0.95082,0.95082,0.95082,   0.95082,0.95082,0.95082,0.95082,0.95082,0.95082,0.95082,   0.95082,0.951613,0.951613,0.951613,0.951613,0.951613,0.951613,   0.953125,0.9532381,0.952381,0.95,9.951613,0.951613,0.951613,   0.951613,0.951613,0.936508,0.936508,0.951613,0.951613,0.951613,   0.951613,0.951613,0.951613,0.936508,0.936508,0.935484,0.935484,   0.888889,0.888889,0.888889,0.888889,0.883333,0.898305,0.898305,   0.898305,0.898305,0.898305,0.898305,0.9,0.898305,0.898305,   0.896552,0.896552,0.896552,0.890625,0.670588,0.6744419,0.670588,   0.830986,0.830986,0.816901,0.819444,0.819444,0.819444,0.819444,   0.816901,0.819444,0.819444,0.813333,0.808219,0.808219,0.819444,   0.819444,0.819444,0.819444,0.816901,0.194631,0.195286,0.191419,   0.194079,0.103691,0.103873,0.103691,0.109948,0.11014,0.11014,   0.110333,0.113074,0.113074,0.113074,0.114841,0.114437,0.110721,   0.110915,0.109541,0.108772,0.11014,0.111702,0.110915,0.110915,   0.110915,0.1125,0.0906516,0.0911681,0.0981308,0.0978261,   0.10061,0.100152,0.175066,0.175066,0.175532,0.176316,0.176316,   0.17801,0.17942,0.180628,0.180628,0.196023,0.200573,0.921053,   0.921053,0.921053,0.92,0.922078,0.923077,0.923077,0.911392,   0.911392,0.911392,0.946667,0.945946,0.946667,0.942857,0.942857,   0.942857,0.90411,0.90411,0.984848,0.984615,0.984615,0.984848,   0.984615,0.984615,0.984615,0.984848,0.984615,0.984375,0.984375,   0.984375,0.984375,0.984375,0.984375,0.984375,0.984375,0.984375,   0.984375,0.984375,0.984615,0.984848,0.984615,0.984615,0.984615,   0.984615,0.985294,0.985294,0.985294,0.985294,0.985294,0.985507,   0.985714,0.985714,0.985714,0.985714,0.985507,0.985507,0.985507,   0.985714,0.985714,0.985507,0.985507,0.985507,0.985507,0.985714,   0.985915,0.985714,0.985915,0.985915,0.985915,0.985714,0.985714,   0.985714,0.985714,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,   1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,   1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,   0.984848,0.985075,0.985075,0.985075,0.985075,0.984848,0.984848,   0.984848,0.984848,0.984848,0.984375,0.984127,0.984127,0.382716,   0.382716,0.380368,0.382716,0.378882,0.371951,0.371951,0.374233,   0.381818,0.379518,0.378049,0.36747,0.363095,0.3461446,0.353659,   0.353659,0.353659,0.353659,0.353659,0.353659,0.349693,0.347561,   0.347561,0.349693,0.354037,0.354037,0.35625,0.35625,0.35625,   0.36646,0.36875,0.983333,0.983607)),. Name = c(&#34; coverage&#34;,   &#34;唯一性&#34;),row.names = c(NA,500L),class =&#34; data.frame&#34;)

0 个答案:

没有答案