zoukankan      html  css  js  c++  java
  • Legendsggplot2图例的一些操作

    1. 移除图例
    2. require(ggplot2)
      b = qplot(Sepal.Length,Petal.Length,data=iris,geom="point",colour = Species)
      #有图例
      b
      #去除图例
      b+theme(legend.position="none")#右图

      2.图例位置摆放
        

    b = qplot(Species,Sepal.Width,data=iris,geom="boxplot",fill = Species)+scale_fill_brewer(palette = "Pastel2")
    b+theme(legend.position="top")

      

    b+theme(legend.position=c(.92,.9))

      3.移除背景中的边框和背景颜色

      

    b+theme(legend.position=c(.92,.9))+theme(legend.key = element_blank())+theme(legend.background = element_blank())

      4.改变图例中key的顺序

    b+scale_fill_brewer(palette="Pastel2",limits=c("virginica","versicolor","setosa"))

      5.修改图例名称

    b = ggplot(iris,aes(x=Species,y=Sepal.Width,fill = Species))+geom_boxplot()
    b+theme(legend.position="top")+labs(fill = "iris-Spec")

      6.移除图例标题
      

    b = ggplot(iris,aes(x=Species,y=Sepal.Width,fill = Species))+geom_boxplot()
    b+theme(legend.position="top")+guides(fill = guide_legend(title = NULL))

      7.去掉legend的背景色

      1)去掉背景

    legend.background = element_blank()

      2)去掉KEY的背景

    legend.key = element_blank()

  • 相关阅读:
    【C++日常】C++动态命名变量名
    两个整数相除
    Jsp页面跳转 接收时的乱码问题
    Reverse a singly linked list
    Java处理excel文件
    Navicat for mysql 破解
    EasyUi 分页 和 表格数据加载
    Spring 框架下Controller 返回结果在EasyUI显示
    svn ubuntu command(转载)
    Shiro Security
  • 原文地址:https://www.cnblogs.com/yangk/p/4761994.html
Copyright © 2011-2022 走看看