Skip to content

Commit

Permalink
Merge pull request #10 from liangliangzhuang/2023
Browse files Browse the repository at this point in the history
2024年2月推文
  • Loading branch information
liangliangzhuang committed Feb 18, 2024
2 parents c90023c + 3708af1 commit 14a9ba5
Show file tree
Hide file tree
Showing 44 changed files with 972 additions and 0 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file added 2024年/.DS_Store
Binary file not shown.
Binary file not shown.
Binary file not shown.
64 changes: 64 additions & 0 deletions 2024年/2024.02.07 多分类的条形图并标记数字/.Rhistory
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")
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"sortOrder": [
{
"columnIndex": 2,
"ascending": true
}
],
"path": "~/我的日记/wechat/+++未完成推文/2024.02.07 绘制折线图"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"activeTab": 0
}
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
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"TabSet1": 0,
"TabSet2": 1,
"TabZoom": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@





Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"active_set":"","sets":[]}
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": []
}
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")


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"
}
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"
}
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"
}
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"
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.
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
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 added 2024年/2024.02.12 TiKZ绘图/.DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions 2024年/2024.02.12 TiKZ绘图/tutorial.aux
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
\relax
\gdef \@abspage@last{1}
Loading

0 comments on commit 14a9ba5

Please sign in to comment.