在多彩多姿的分组条形图中更改轮廓的颜色

时间:2018-05-01 19:56:24

标签: r ggplot2

这是我的剧情:

如何为每个条形图设置黑色轮廓,还可以更改标签上的轴标签和值的字体大小?

mm1=melt(data[,c('label','cut_scorer1','cut_scorer2')], id = 1)
assign(cut_score,ggplot(mm1, aes(x = label, y = value, width = 0.8)) + 
    geom_bar(aes(fill = variable), stat = "identity", position = "dodge")+ sale_fill_manual(values=alpha(c('light green','dark green'),0.7), name = "Scorer", 
    labels = c("1", "2")) + 
    labs(title = paste(subject_name,"Cutting", sep = " - "), x = "", y = 
    "Score") + 
    theme(text = element_text(size = 15)) + coord_cartesian( ylim = 
    c(min(mm1$value),max(mm1$value))))

2 个答案:

答案 0 :(得分:1)

我真的建议您查看.flipContainer { width: 260px; height: 200px; position: relative; -webkit-perspective: 800px; -moz-perspective: 800px; -o-perspective: 800px; perspective: 800px; } .card { width: 100%; height: 100%; position: absolute; -webkit-transition: -webkit-transform 1s; -moz-transition: -moz-transform 1s; -o-transition: -o-transform 1s; transition: transform 1s; -webkit-transform-style: preserve-3d; -moz-transform-style: preserve-3d; -o-transform-style: preserve-3d; transform-style: preserve-3d; -webkit-transform-origin: 50% 50%; } .card div { display: block; height: 100%; width: 100%; line-height: 200px; color: white; text-align: center; font-weight: bold; font-size: 12px; position: absolute; -webkit-backface-visibility: hidden; -moz-backface-visibility: hidden; -o-backface-visibility: hidden; backface-visibility: hidden; } .card .front { background: red; } .card .back { background: blue; -webkit-transform: rotateY( 180deg); -moz-transform: rotateY( 180deg); -o-transform: rotateY( 180deg); transform: rotateY( 180deg); } .card.flipped { -webkit-transform: rotateY( 180deg); -moz-transform: rotateY( 180deg); -o-transform: rotateY( 180deg); transform: rotateY( 180deg); }的文档(以及基本的<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <section class="flipContainer"> <div class="card"> <button class="js-click">+</button> <div class="front">Custom Installation</div> <div class="back">Custom Installation details</div> </div> </section> <section class="flipContainer"> <div class="card"> <button class="js-click1">+</button> <div class="front">Custom Installation</div> <div class="back">Custom Installation details</div> </div> </section>文档),但这可能有助于您入门。

您可以使用geom_bar()为条形添加轮廓,并且可以使用ggplot2更改轴标签。我们使用colour = "black"中的参数来更改轴标签和刻度线上的字体大小。请参阅以下代码:

labs()

enter image description here

答案 1 :(得分:0)

我找到了解决方案,谢谢。

我在geom_bar中添加了color =“black”但在aes之外

mm1 = melt(data [,c('label','cut_scorer1','cut_scorer2')],id = 1) assign(cut_score,ggplot(mm1,aes(x = label,y = value,width = 0.8))+    geom_bar(aes(fill = variable),stat =“identity”, color =“black”, position =“dodge”)+    scale_color_manual(values ='black')+    scale_fill_manual(values = alpha(c('light green','dark green'),0.7),name =“Scorer”,labels = c(“1”,“2”))+    labs(title = paste(subject_name,“Cutting”,sep =“ - ”),x =“”,y =“Score”)+    theme(text = element_text(size = 15))+ coord_cartesian(ylim = c(min(mm1 $ value),max(mm1 $ value)))))