-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from liangliangzhuang/2023
2024年2月推文
- Loading branch information
Showing
44 changed files
with
972 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# 科研论文中常用的图形(可靠性) | ||
# 多分类条形图 | ||
library(ggplot2) | ||
library(viridis) | ||
library(forcats) | ||
# 示例数据 | ||
R_all <- data.frame( | ||
Scen = rep(c("A", "B", "C"), each = 5), | ||
Model = rep(c("M1", "M2", "M3", "M4", "M5"), 3), | ||
value = c(10, 15, 8, 12, 7, 9, 14, 18, 5, 10, 8, 11, 6, 8, 12) | ||
) | ||
# 设置 Model 列的因子顺序 | ||
model_order <- c("M1", "M2", "M3", "M4", "M5") | ||
# 绘制柱状图(版本一) | ||
ggplot(R_all, aes(x = Scen, y = value, fill = fct_relevel(Model, model_order))) + | ||
geom_col(position = "dodge", alpha = 0.8) + | ||
geom_text(aes(label = value), position = position_dodge(width = 0.9), vjust = -0.5) + # 添加标签 | ||
scale_fill_viridis(discrete = TRUE, name = "Model") + | ||
theme_bw() + | ||
theme(panel.grid = element_blank(), legend.position = "bottom") | ||
#更加复杂的场景(多一个case变量,使用分面) | ||
# 示例数据 | ||
R_all2 = rbind(R_all,R_all) | ||
R_all2$case = rep(c("Case 1", "Case 2"),each=15) | ||
R_all2$value = round(R_all2$value + 1* rnorm(30,0,1),2) | ||
ggplot(R_all2, aes(x = Scen, y = value, fill = fct_relevel(Model, model_order))) + | ||
geom_col(position = "dodge", alpha = 0.8) + | ||
geom_text(aes(label = value), position = position_dodge(width = 0.9), vjust = -0.5) + # 添加标签 | ||
facet_wrap(vars(factor(case))) + | ||
scale_fill_viridis(discrete = TRUE, name = "Model") + | ||
theme_bw() + | ||
theme(panel.grid = element_blank(), legend.position = "bottom") | ||
# 科研论文中常用的图形(可靠性) | ||
# 多分类条形图 | ||
library(ggplot2) | ||
library(viridis) | ||
library(forcats) | ||
# 示例数据 | ||
R_all <- data.frame( | ||
Scen = rep(c("A", "B", "C"), each = 5), | ||
Model = rep(c("M1", "M2", "M3", "M4", "M5"), 3), | ||
value = c(10, 15, 8, 12, 7, 9, 14, 18, 5, 10, 8, 11, 6, 8, 12) | ||
) | ||
# 设置 Model 列的因子顺序 | ||
model_order <- c("M1", "M2", "M3", "M4", "M5") | ||
# 绘制柱状图(版本一) | ||
ggplot(R_all, aes(x = Scen, y = value, fill = fct_relevel(Model, model_order))) + | ||
geom_col(position = "dodge", alpha = 0.8) + | ||
geom_text(aes(label = value), position = position_dodge(width = 0.9), vjust = -0.5) + # 添加标签 | ||
scale_fill_viridis(discrete = TRUE, name = "Model") + | ||
theme_bw() + | ||
theme(panel.grid = element_blank(), legend.position = "bottom") | ||
#更加复杂的场景(多一个case变量,使用分面) | ||
# 示例数据 | ||
R_all2 = rbind(R_all,R_all) | ||
R_all2$case = rep(c("Case 1", "Case 2"),each=15) | ||
R_all2$value = round(R_all2$value + 1* rnorm(30,0,1),2) | ||
ggplot(R_all2, aes(x = Scen, y = value, fill = fct_relevel(Model, model_order))) + | ||
geom_col(position = "dodge", alpha = 0.8) + | ||
geom_text(aes(label = value), position = position_dodge(width = 0.9), vjust = -0.5) + # 添加标签 | ||
facet_wrap(vars(factor(case))) + | ||
scale_fill_viridis(discrete = TRUE, name = "Model") + | ||
theme_bw() + | ||
theme(panel.grid = element_blank(), legend.position = "bottom") |
9 changes: 9 additions & 0 deletions
9
2024年/2024.02.07 多分类的条形图并标记数字/.Rproj.user/C6560784/pcs/files-pane.pper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"sortOrder": [ | ||
{ | ||
"columnIndex": 2, | ||
"ascending": true | ||
} | ||
], | ||
"path": "~/我的日记/wechat/+++未完成推文/2024.02.07 绘制折线图" | ||
} |
3 changes: 3 additions & 0 deletions
3
2024年/2024.02.07 多分类的条形图并标记数字/.Rproj.user/C6560784/pcs/source-pane.pper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"activeTab": 0 | ||
} |
14 changes: 14 additions & 0 deletions
14
2024年/2024.02.07 多分类的条形图并标记数字/.Rproj.user/C6560784/pcs/windowlayoutstate.pper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"left": { | ||
"splitterpos": 601, | ||
"topwindowstate": "NORMAL", | ||
"panelheight": 1107, | ||
"windowheight": 1145 | ||
}, | ||
"right": { | ||
"splitterpos": 688, | ||
"topwindowstate": "NORMAL", | ||
"panelheight": 1107, | ||
"windowheight": 1145 | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
2024年/2024.02.07 多分类的条形图并标记数字/.Rproj.user/C6560784/pcs/workbench-pane.pper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"TabSet1": 0, | ||
"TabSet2": 1, | ||
"TabZoom": {} | ||
} |
5 changes: 5 additions & 0 deletions
5
2024年/2024.02.07 多分类的条形图并标记数字/.Rproj.user/C6560784/rmd-outputs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
|
||
|
||
|
||
|
1 change: 1 addition & 0 deletions
1
2024年/2024.02.07 多分类的条形图并标记数字/.Rproj.user/C6560784/saved_source_markers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"active_set":"","sets":[]} |
27 changes: 27 additions & 0 deletions
27
2024年/2024.02.07 多分类的条形图并标记数字/.Rproj.user/C6560784/sources/per/t/AF66B3A8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"id": "AF66B3A8", | ||
"path": "~/我的日记/wechat/+++未完成推文/2024.02.07 多分类的条形图并标记数字/多分类条形图并标记数字.R", | ||
"project_path": "多分类条形图并标记数字.R", | ||
"type": "r_source", | ||
"hash": "4276122087", | ||
"contents": "", | ||
"dirty": false, | ||
"created": 1707294910121.0, | ||
"source_on_save": false, | ||
"relative_order": 1, | ||
"properties": { | ||
"tempName": "Untitled1", | ||
"source_window_id": "", | ||
"Source": "Source", | ||
"cursorPosition": "3,0", | ||
"scrollLine": "0" | ||
}, | ||
"folds": "", | ||
"lastKnownWriteTime": 1708276555, | ||
"encoding": "UTF-8", | ||
"collab_server": "", | ||
"source_window": "", | ||
"last_content_update": 1708276555603, | ||
"read_only": false, | ||
"read_only_alternatives": [] | ||
} |
43 changes: 43 additions & 0 deletions
43
2024年/2024.02.07 多分类的条形图并标记数字/.Rproj.user/C6560784/sources/per/t/AF66B3A8-contents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# 科研论文中常用的图形(可靠性) ======= | ||
# 推文:《ggplot 绘制多分类条形图并标记数字》 | ||
# 链接:https://mp.weixin.qq.com/s?__biz=MzI1NjUwMjQxMQ==&mid=2247520840&idx=1&sn=1a13fdace99353fb984d8b1ff9ae5c99&chksm=ea276dacdd50e4ba2b668a0ccb2feb87079cf0bb7b8eae26fe51122e5031cd5ca4e289f6e0f8&token=1416591993&lang=zh_CN#rd | ||
|
||
# 多分类条形图 | ||
library(ggplot2) | ||
library(viridis) | ||
library(forcats) | ||
# 示例数据 | ||
R_all <- data.frame( | ||
Scen = rep(c("A", "B", "C"), each = 5), | ||
Model = rep(c("M1", "M2", "M3", "M4", "M5"), 3), | ||
value = c(10, 15, 8, 12, 7, 9, 14, 18, 5, 10, 8, 11, 6, 8, 12) | ||
) | ||
|
||
# 设置 Model 列的因子顺序 | ||
model_order <- c("M1", "M2", "M3", "M4", "M5") | ||
|
||
# 绘制柱状图(版本一) | ||
ggplot(R_all, aes(x = Scen, y = value, fill = fct_relevel(Model, model_order))) + | ||
geom_col(position = "dodge", alpha = 0.8) + | ||
geom_text(aes(label = value), position = position_dodge(width = 0.9), vjust = -0.5) + # 添加标签 | ||
scale_fill_viridis(discrete = TRUE, name = "Model") + | ||
theme_bw() + | ||
theme(panel.grid = element_blank(), legend.position = "bottom") | ||
|
||
|
||
#更加复杂的场景(多一个case变量,使用分面) | ||
|
||
# 示例数据 | ||
R_all2 = rbind(R_all,R_all) | ||
R_all2$case = rep(c("Case 1", "Case 2"),each=15) | ||
R_all2$value = round(R_all2$value + 1* rnorm(30,0,1),2) | ||
|
||
ggplot(R_all2, aes(x = Scen, y = value, fill = fct_relevel(Model, model_order))) + | ||
geom_col(position = "dodge", alpha = 0.8) + | ||
geom_text(aes(label = value), position = position_dodge(width = 0.9), vjust = -0.5) + # 添加标签 | ||
facet_wrap(vars(factor(case))) + | ||
scale_fill_viridis(discrete = TRUE, name = "Model") + | ||
theme_bw() + | ||
theme(panel.grid = element_blank(), legend.position = "bottom") | ||
|
||
|
7 changes: 7 additions & 0 deletions
7
2024年/2024.02.07 多分类的条形图并标记数字/.Rproj.user/C6560784/sources/prop/0418CBEF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"tempName": "Untitled1", | ||
"source_window_id": "", | ||
"Source": "Source", | ||
"cursorPosition": "25,23", | ||
"scrollLine": "21" | ||
} |
7 changes: 7 additions & 0 deletions
7
2024年/2024.02.07 多分类的条形图并标记数字/.Rproj.user/C6560784/sources/prop/048F8B4D
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"tempName": "Untitled1", | ||
"source_window_id": "", | ||
"Source": "Source", | ||
"cursorPosition": "25,23", | ||
"scrollLine": "21" | ||
} |
7 changes: 7 additions & 0 deletions
7
2024年/2024.02.07 多分类的条形图并标记数字/.Rproj.user/C6560784/sources/prop/1A4EC317
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"tempName": "Untitled1", | ||
"source_window_id": "", | ||
"Source": "Source", | ||
"cursorPosition": "3,0", | ||
"scrollLine": "0" | ||
} |
3 changes: 3 additions & 0 deletions
3
2024年/2024.02.07 多分类的条形图并标记数字/.Rproj.user/C6560784/sources/prop/INDEX
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
~%2F%E6%88%91%E7%9A%84%E6%97%A5%E8%AE%B0%2Fwechat%2F%2B%2B%2B%E6%9C%AA%E5%AE%8C%E6%88%90%E6%8E%A8%E6%96%87%2F2024.02.07%20%E5%A4%9A%E5%88%86%E7%B1%BB%E7%9A%84%E6%9D%A1%E5%BD%A2%E5%9B%BE%E5%B9%B6%E6%A0%87%E8%AE%B0%E6%95%B0%E5%AD%97%2F%E5%A4%9A%E5%88%86%E7%B1%BB%E6%9D%A1%E5%BD%A2%E5%9B%BE%E5%B9%B6%E6%A0%87%E8%AE%B0%E6%95%B0%E5%AD%97.R="1A4EC317" | ||
~%2F%E6%88%91%E7%9A%84%E6%97%A5%E8%AE%B0%2Fwechat%2F%2B%2B%2B%E6%9C%AA%E5%AE%8C%E6%88%90%E6%8E%A8%E6%96%87%2F2024.02.07%20%E7%BB%98%E5%88%B6%E6%8A%98%E7%BA%BF%E5%9B%BE%2F%E5%A4%9A%E5%88%86%E7%B1%BB%E6%9D%A1%E5%BD%A2%E5%9B%BE%E5%B9%B6%E6%A0%87%E8%AE%B0%E6%95%B0%E5%AD%97.R="048F8B4D" | ||
~%2F%E6%88%91%E7%9A%84%E6%97%A5%E8%AE%B0%2Fwechat%2F%2B%2B%2B%E6%9C%AA%E5%AE%8C%E6%88%90%E6%8E%A8%E6%96%87%2F2024.02.07%20%E7%BB%98%E5%88%B6%E6%8A%98%E7%BA%BF%E5%9B%BE%2F%E5%A4%9A%E5%88%86%E7%B1%BB%E6%9D%A1%E5%BD%A2%E5%9B%BE%E5%B9%B6%E6%B7%BB%E5%8A%A0%E6%95%B0%E6%8D%AE.R="0418CBEF" |
Empty file.
2 changes: 2 additions & 0 deletions
2
2024年/2024.02.07 多分类的条形图并标记数字/.Rproj.user/shared/notebooks/paths
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/Users/liangliangzhuang/我的日记/wechat/+++未完成推文/2024.02.07 绘制折线图/多分类条形图并标记数字.R="819DA836" | ||
/Users/liangliangzhuang/我的日记/wechat/+++未完成推文/2024.02.07 绘制折线图/多分类条形图并添加数据.R="41FB4EE8" |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Version: 1.0 | ||
|
||
RestoreWorkspace: Default | ||
SaveWorkspace: Default | ||
AlwaysSaveHistory: Default | ||
|
||
EnableCodeIndexing: Yes | ||
UseSpacesForTab: Yes | ||
NumSpacesForTab: 2 | ||
Encoding: UTF-8 | ||
|
||
RnwWeave: Sweave | ||
LaTeX: XeLaTeX | ||
|
||
BuildType: Website |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# 科研论文中常用的图形(可靠性) ======= | ||
# 推文:《ggplot 绘制多分类条形图并标记数字》 | ||
# 链接:https://mp.weixin.qq.com/s?__biz=MzI1NjUwMjQxMQ==&mid=2247520840&idx=1&sn=1a13fdace99353fb984d8b1ff9ae5c99&chksm=ea276dacdd50e4ba2b668a0ccb2feb87079cf0bb7b8eae26fe51122e5031cd5ca4e289f6e0f8&token=1416591993&lang=zh_CN#rd | ||
|
||
# 多分类条形图 | ||
library(ggplot2) | ||
library(viridis) | ||
library(forcats) | ||
# 示例数据 | ||
R_all <- data.frame( | ||
Scen = rep(c("A", "B", "C"), each = 5), | ||
Model = rep(c("M1", "M2", "M3", "M4", "M5"), 3), | ||
value = c(10, 15, 8, 12, 7, 9, 14, 18, 5, 10, 8, 11, 6, 8, 12) | ||
) | ||
|
||
# 设置 Model 列的因子顺序 | ||
model_order <- c("M1", "M2", "M3", "M4", "M5") | ||
|
||
# 绘制柱状图(版本一) | ||
ggplot(R_all, aes(x = Scen, y = value, fill = fct_relevel(Model, model_order))) + | ||
geom_col(position = "dodge", alpha = 0.8) + | ||
geom_text(aes(label = value), position = position_dodge(width = 0.9), vjust = -0.5) + # 添加标签 | ||
scale_fill_viridis(discrete = TRUE, name = "Model") + | ||
theme_bw() + | ||
theme(panel.grid = element_blank(), legend.position = "bottom") | ||
|
||
|
||
#更加复杂的场景(多一个case变量,使用分面) | ||
|
||
# 示例数据 | ||
R_all2 = rbind(R_all,R_all) | ||
R_all2$case = rep(c("Case 1", "Case 2"),each=15) | ||
R_all2$value = round(R_all2$value + 1* rnorm(30,0,1),2) | ||
|
||
ggplot(R_all2, aes(x = Scen, y = value, fill = fct_relevel(Model, model_order))) + | ||
geom_col(position = "dodge", alpha = 0.8) + | ||
geom_text(aes(label = value), position = position_dodge(width = 0.9), vjust = -0.5) + # 添加标签 | ||
facet_wrap(vars(factor(case))) + | ||
scale_fill_viridis(discrete = TRUE, name = "Model") + | ||
theme_bw() + | ||
theme(panel.grid = element_blank(), legend.position = "bottom") | ||
|
||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
\relax | ||
\gdef \@abspage@last{1} |
Oops, something went wrong.