Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在R中使用ggplot更改散点图中记号标记的名称?_R_Ggplot2_Scatter Plot_Axis Labels - Fatal编程技术网

如何在R中使用ggplot更改散点图中记号标记的名称?

如何在R中使用ggplot更改散点图中记号标记的名称?,r,ggplot2,scatter-plot,axis-labels,R,Ggplot2,Scatter Plot,Axis Labels,在我的散点图中,我想用相应的CEFR级别(A1.1到B2.2)替换勾号(1到8)的名称,而不改变数据帧 1 = A1.1, 2 = A1.2, 3 = A2.1, 4 = A2.2, 5 = B1.1, 6 = B1.2, 7 = B2.1, 8 = B2.2 我的代码: ggplot(data = doppelratings1_mit_ID, aes(x = R1 , y = R2)) + geom_jitter(shape=1, width = 0.05, height = 0.

在我的散点图中,我想用相应的CEFR级别(A1.1到B2.2)替换勾号(1到8)的名称,而不改变数据帧

1 = A1.1,
2 = A1.2,
3 = A2.1,
4 = A2.2,
5 = B1.1,
6 = B1.2,
7 = B2.1,
8 = B2.2
我的代码:

ggplot(data =  doppelratings1_mit_ID,
  aes(x = R1 , y = R2)) +
  geom_jitter(shape=1, width = 0.05, height = 0.15) + 
  geom_smooth() +
  xlab("Rater 1") +
  ylab("Rater 2") +
  ggtitle("Korrelation zwischen Rater 1 und 2", paste("n = 19 Texte ")) +
  theme_bw(12)+
  geom_abline(intercept = 0, slope = 1)
我试过了

CEFR <- c("A1.2", "A2.2", "B1.2")
但随后记号消失了

谢谢你的帮助

参见我的散点图:


将其添加到绘图定义中:

tick_names <- c('A1.1', 'A1.2', ..., 'B2.2')

ggplot() + 
  ... +
scale_x_continuous(breaks = 1:8, labels = tick_names, limits = c(1, 8)) +
scale_y_continuous(breaks = 1:8, labels = tick_names, limits = c(1, 8))

勾选名称我设法用以下代码显示散点图:

tick_names <- c("A1.1", "A1.2", "A2.1", "A2.2", "B1.1", "B1.2", "B2.1", "B2.2")
tick_names_x <- c("A1.1", "A1.2", "A2.1", "A2.2", "B1.1", "B1.2", "B2.1")

ggplot(data =  doppelratings1_mit_ID,
aes(x = R1 , y = R2)) +
geom_jitter(shape=1, width = 0.05, height = 0.15) + 
geom_smooth() +
xlab("Rater 1") +
ylab("Rater 2") +
ggtitle("Korrelation zwischen Rater 1 und 2", paste("n = 19 Texte ")) +
theme_bw(12)+
geom_abline(intercept = 0, slope = 1) +
scale_y_discrete(breaks = 1:8, labels = tick_names, limits = c(1:8)) +
scale_x_discrete(breaks = 1:7, labels = tick_names_x, limits = c(1: 7))

勾选名称我怀疑你的x轴是数字的,而不是分类的,所以
缩放x\u离散()
会使事情失去同步。请尝试使用
+连续缩放(打断=顺序(1,8),标签=c(“A1.1”,“A1.2”,“…))
?谢谢您的回答。然而,我确信这些量表是离散的,因为CEFR等级是类别(语言熟练程度等级)。谢谢你的回答!我设法显示了散点图,对代码做了细微的更改,因为比例确实是离散的。
tick_names <- c("A1.1", "A1.2", "A2.1", "A2.2", "B1.1", "B1.2", "B2.1", "B2.2")
tick_names_x <- c("A1.1", "A1.2", "A2.1", "A2.2", "B1.1", "B1.2", "B2.1")

ggplot(data =  doppelratings1_mit_ID,
aes(x = R1 , y = R2)) +
geom_jitter(shape=1, width = 0.05, height = 0.15) + 
geom_smooth() +
xlab("Rater 1") +
ylab("Rater 2") +
ggtitle("Korrelation zwischen Rater 1 und 2", paste("n = 19 Texte ")) +
theme_bw(12)+
geom_abline(intercept = 0, slope = 1) +
scale_y_discrete(breaks = 1:8, labels = tick_names, limits = c(1:8)) +
scale_x_discrete(breaks = 1:7, labels = tick_names_x, limits = c(1: 7))