ggplot2——玫瑰图
2015-08-13 23:18
381 查看
更多内容请见:R、ggplot2、shiny 汇总
注:更多修改的细节可见:ggplot2——饼图篇,两者类似。
转载请注明出处,谢谢!(原文链接:http://blog.csdn.net/Bone_ACE/article/details/47624987)
初始图样:
library(ggplot2) dt = data.frame(A = c(2, 7, 4, 10, 1), B = c('B','A','C','D','E')) windowsFonts(myFont = windowsFont("楷体")) ## 绑定字体 p = ggplot(dt, aes(x = B, y = A, fill = B)) + geom_bar(stat = "identity", alpha = 0.7) + coord_polar() p
修补过后的玫瑰图:
library(ggplot2) dt = data.frame(A = c(2, 7, 4, 10, 1), B = c('B','A','C','D','E')) windowsFonts(myFont = windowsFont("楷体")) ## 绑定字体 p = ggplot(dt, aes(x = B, y = A, fill = B)) + geom_bar(stat = "identity", alpha = 0.7) + coord_polar() + theme_bw() + labs(x = "", y = "", title = "这个玫瑰图有点丑") + geom_text(aes(y = A/2 + max(A)/4, label = A, color = B), size = 5) + ## 加上数字 theme(axis.text.y = element_blank()) + ## 去掉左上角的刻度标签 theme(axis.ticks = element_blank()) + ## 去掉左上角的刻度线 theme(panel.border = element_blank()) + ## 去掉外层边框 theme(legend.position = "none") + ## 去掉图例 theme(title = element_text(vjust = -56, face = "bold", family = "myFont")) ## 将图例移到图的下方,并更改一下字体格式 p
注:更多修改的细节可见:ggplot2——饼图篇,两者类似。
转载请注明出处,谢谢!(原文链接:http://blog.csdn.net/Bone_ACE/article/details/47624987)
相关文章推荐
- 网络编程01---计算机网络基础
- noip1997 棋盘 (数列求和)
- Uva 673 Parentheses Balance
- [2015-08-10] python021
- 读《javascript权威指南》第五版 第七章 对象与数组
- 在intellj idea下用sbt的坑
- MapReduce入门例子
- 数三退一问题 java
- leetcode 123: Best Time to Buy and Sell Stock III
- OpenCV机器学习库MLL
- c++继承
- Android源码大放送(实战开发必备)
- 架构师速成之路
- linux设备模型(三 device)
- 一个继承的小案例与解析
- Protocol - 4
- 进程的三种基本状态及其转换
- MyEclipse中的常用技巧
- 逻辑非运算符
- linux系统函数积累