[英]How to plot multiple lines with several conditions (6*2*3) in R
I am trying to plot this data frame which has total of rows 36 * columns 7: Notes: 我正在尝试绘制此数据框,该数据框共有36行* 7列:注意:
There are 6 factors for stim_ending_t= 1, 1.5, 2, 2.5, 3, 3.5 stim_ending_t = 1、1.5、2、2.5、3、3.5有6个因素
Three are three repeated conditons: 三是三个重复的条件:
visbility =1 soundvolume=0 (visbility)
visbility =0 soundvolume=1 (soundvolume)
visbility = 0 soundvolume=0 (this sould be called blank or empty)
date frame name: master_all_r.csv 日期框架名称:master_all_r.csv
stim_ending_t visbility soundvolume Opening_text m sd coefVar
<dbl> <dbl> <dbl> <chr> <dbl> <dbl> <dbl>
1 1 0 0 Now focus on the Image 1.70 1.14 0.670
2 1 0 0 Now focus on the Sound 1.57 0.794 0.504
3 1 0 1 Now focus on the Image 1.62 1.25 0.772
4 1 0 1 Now focus on the Sound 1.84 1.17 0.637
5 1 1 0 Now focus on the Image 3.19 17.2 5.38
6 1 1 0 Now focus on the Sound 1.59 0.706 0.444
How the plot should look like: x= Stim_ending_t , y=m 该图应如何显示: x = Stim_ending_t,y = m
I need three lines in the same plot that satisfy the conditions above while being divided into two groups by = Opening_text. 我需要在同一绘图中满足上述条件的三行,并由= Opening_text分为两组。 If it possible it can be in one graph, but if not the two groups (Now focus on the Image & Now focus on the Sound) can be split into two separate graphs. 如果可能的话,它可以放在一个图中,但如果没有,则可以将两组(现在集中在图像上,现在集中在声音上)分成两个单独的图。
I have tried this code: 我已经试过这段代码:
ggplot(test_master, aes(x=stim_ending_t, y=m, group=Opening_text, visbility, soundvolume)) +
geom_line(aes(linetype=Opening_text, visbility, soundvolume))+
geom_point()
But got this Warning message: Duplicated aesthetics after name standardisation:
this is the result I got here 但是得到了这样的Warning message: Duplicated aesthetics after name standardisation:
这就是我得到的结果
Ideally, the plot should look like this, but with three lines here . 理想情况下,该图应看起来像这样,但此处有三行。 I found these plots here 我在这里找到这些地块
If you would like to download the excel file, you can find it here under the name master_all_r.csv 如果要下载excel文件,可以在此处找到它,名称为master_all_r.csv。
I believe you are looking for something like this: 我相信您正在寻找这样的东西:
library(tidyvere)
library(readr)
test_master <- read_csv("https://raw.githubusercontent.com/MohJumper/VisualAuditoryModality/master/master_all_r.csv")
test_master %>%
mutate(visbility_sound = case_when(
visbility == 1 & soundvolume == 0 ~ "visibility",
visbility == 0 & soundvolume == 1 ~ "soundvolume",
visbility == 0 & soundvolume == 0 ~ "empty")) %>%
mutate_at(vars(visbility_sound), factor) %>%
ggplot(aes(x = stim_ending_t, y = m, color = visbility_sound)) +
geom_line(aes(linetype = visbility_sound)) +
geom_point() +
facet_wrap(~Opening_text) +
theme_minimal()
So here's what's happenning: 所以这是正在发生的事情:
geom_line
to also use this column for linetype 告诉geom_line
也将此列用于线型 facet_wrap
(could also use facet_grid
!) 分为两个地块与facet_wrap
(也可以使用facet_grid
!)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.