拟合散点图(Scatterplot) 4、计数图(Counts Chart) 5、分组气泡图(Bubble plot) 6、相关系数图(Correlogram) 7、水平发散型文本(Diverging Texts) 8、水平棒棒糖图(Diverging Lollipop Chart) 9、去棒棒糖图(Diverging Dot Plot) 10、面积图(Area Chart) 1
20、饼图(Pie Chart) library(ggplot2) theme_set(theme_classic()) # Source: Frequency table df <- as.data.frame(table(mpg$class)) colnames(df) <- c("class", "freq") pie <- ggplot(df, aes(x = "", y=freq, fill = factor(class))) + geom_bar(width = 1, stat = "identity")...
pie <- ggplot(df, aes(x = "", y=freq, fill = factor(class))) + geom_bar(width = 1, stat = "identity") + theme(axis.line = element_blank(), plot.title = element_text(hjust=0.5)) + labs(fill="class", x=NULL, y=NULL, title="Pie Chart of class", caption="So...
2.2 发散棒棒糖图(Diverging Lollipop Chart) 2.3 发散点图(Diverging Dot Plot) 2.4 面积图(Area Chart) 3. 排名(Ranking) 3.1 有序条形图 3.2 棒棒糖图(Lollipop Chart) 3.3 点图(Dot Plot) ...
带边界的散点图(Scatterplot With Encircling) 抖动图(Jitter Plot) 计数图(Counts Chart) 气泡图(Bubble Plot) 边际直方图/箱线图(Marginal Histogram / Boxplot) 相关图(Correlogram) 1.1 散点图(Scatterplot) 数据分析中最常用的图无疑是散点图。每当您想了解两个变量之间关系的性质时,首选始终是散点图。
pl <- tidy_movies %>% distinct(title, year, length, .keep_all=TRUE) %>% ggplot(aes(x=Genres)) + geom_bar() + scale_x_upset(n_intersections = 20) ggsave("/tmp/movie_genre_barchart.png", plot = pl) #> Saving 7 x 5 in image Session Info sessionInfo() #> R version 4.3.2...
pie <- ggplot(mpg, aes(x = "", fill = factor(class))) + geom_bar(width = 1) + theme(axis.line = element_blank(), plot.title = element_text(hjust=0.5)) + labs(fill="class", x=NULL, y=NULL, title="Pie Chart of class", ...
# pie chart chart <- tuesdata$occupation %>% bind_rows(blank) %>% left_join(colors) %>% arrange(desc(Group), Color) %>% mutate(ypos = cumsum(Percentage) - 0.5 * Percentage, label = scales::percent(Percentage, scale = 1,accuracy = 1), ...
title="Pie Chart of class", caption="Source: mpg") pie + coord_polar(theta = "y", start=0) 树形图 树形图是现实分层数据的好方法。在ggplot中,treemapify包含有树形图所需要的数据处理及绘图方法。 为了创建树形图,需要先将数据转换成treemapify()需要的数据格式。
(x = NULL, y = NULL, fill = "Vehicle Class", title = "Class of Vehicles: Pie Chart")+ coord_fixed()+ theme_bw()+ theme(aspect.ratio = 1/1, axis.ticks = element_blank(), axis.text = element_blank(), panel.grid = element_blank(), panel.border = element_blank(), plot....