盈彩体育注册(中国)有限公司
盈彩体育注册(中国)有限公司 您所在的位置:网站首页 盈彩体育注册(中国)有限公司 R可视化19

R可视化19

2024-02-24 23:27:35| 来源: 网络整理

上面图片为网站作者。首发于公众号:【pythonic生物人】本文分享R语言ggplot2绘制常用30+个靓图。之前分享过Python版姊妹篇戳:Python可视化35|matplotlib&seaborn-一些有用的图

「本文目录」1、边界散点图(Scatterplot With Encircling) 2、边缘箱图/直方图(Marginal Histogram / Boxplot) 3、拟合散点图(Scatterplot)4、计数图(Counts Chart) 5、分组气泡图(Bubble plot)6、相关系数图(Correlogram)7、水平发散型文本(Diverging Texts)8、水平棒棒糖图(Diverging Lollipop Chart) 9、去棒棒糖图(Diverging Dot Plot) 10、面积图(Area Chart)11、排序条形图(Ordered Bar Chart)12、坡图(Slope Chart) 13、直方图(Histogram)14、核密度图(Density plot) 15、箱图(Box Plot)16、分组箱图17、点图结合箱图(Dot + Box Plot) 18、小提琴图(Violin Plot) 19、金字塔图(Population Pyramid)20、饼图(Pie Chart)21、树图(TreeMap)22、柱状图(Bar Chart)23、时间序列图(Time Series多图) 24、堆叠面积图(Stacked Area Chart) 25、日历热图(Calendar Heatmap) 26、季节变迁图(Seasonal Plot)27、分层树形图(Hierarchical Dendrogram)28、聚类图(Clusters)1、边界散点图(Scatterplot With Encircling)options(scipen = 999)library(ggplot2)library(ggalt)midwest_select 350000 & midwest$poptotal 0.01 & midwest$area < 0.1, ]# Plotggplot(midwest, aes(x=area, y=poptotal)) + geom_point(aes(col=state, size=popdensity)) + # draw points geom_smooth(method="loess", se=F) + xlim(c(0, 0.1)) + ylim(c(0, 500000)) + # draw smoothing line geom_encircle(aes(x=area, y=poptotal), data=midwest_select, color="red", size=2, expand=0.08) + # encircle labs(subtitle="Area Vs Population", y="Population", x="Area", title="Scatterplot + Encircle", caption="Source: midwest")2、边缘箱图/直方图(Marginal Histogram / Boxplot)

这类图,python的seaborn和R中的ggstatsplot都能很便利的绘制,参考:R可视化17|ggstatsplot几行code终结SCI级图表统计+画图 (上)Python可视化24|seaborn绘制多变量分布图(jointplot|JointGrid)

library(ggplot2)library(ggExtra)data(mpg, package="ggplot2")# Scatterplottheme_set(theme_bw()) # pre-set the bw theme.mpg_select = 35 & mpg$cty > 27, ]g 3、拟合散点图(Scatterplot)options(scipen=999) # turn-off scientific notation like 1e+48library(ggplot2)theme_set(theme_bw()) # pre-set the bw theme.data("midwest", package = "ggplot2")# midwest 4、计数图(Counts Chart)library(ggplot2)data(mpg, package="ggplot2")# mpg 5、分组气泡图(Bubble plot)library(ggplot2)data(mpg, package="ggplot2")# mpg 7、水平发散型文本(Diverging Texts)library(ggplot2)theme_set(theme_bw()) # Data Prepdata("mtcars") # load datamtcarscar name`

类似的图

library(ggplot2)theme_set(theme_bw())# Plotggplot(cty_mpg, aes(x=make, y=mileage)) + geom_point(size=3) + geom_segment(aes(x=make, xend=make, y=0, yend=mileage)) + labs(title="Lollipop Chart", subtitle="Make Vs Avg. Mileage", caption="source: mpg") + theme(axis.text.x = element_text(angle=65, vjust=0.6))library(ggplot2)library(scales)theme_set(theme_classic())# Plotggplot(cty_mpg, aes(x=make, y=mileage)) + geom_point(col="tomato2", size=3) + # Draw points geom_segment(aes(x=make, xend=make, y=min(mileage), yend=max(mileage)), linetype="dashed", size=0.1) + # Draw dashed lines labs(title="Dot Plot", subtitle="Make Vs Avg. Mileage", caption="source: mpg") + coord_flip()10、面积图(Area Chart)library(ggplot2)library(quantmod)data("economics", package = "ggplot2")# Compute % Returnseconomics$returns_perc



【本文地址】 转载请注明 

最新文章

推荐文章

CopyRight 2018-2019 盈彩体育注册(中国)有限公司 版权所有 豫ICP备16040606号-1