Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/84.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 在箱线图中指定点符号的绘图问题_R_Plotly_Ggplotly - Fatal编程技术网

R 在箱线图中指定点符号的绘图问题

R 在箱线图中指定点符号的绘图问题,r,plotly,ggplotly,R,Plotly,Ggplotly,我试图基于一个因子指定点符号(形状),以便箱线图中的点形状可以不同(这对于高亮显示一组点非常有用)。然而,看起来第三个方框图并没有显示不同的形状,而是分成了两个方框 你能告诉我如何做到这一点吗 data(iris) iris=mutate(iris, Petal.Width_high=ifelse(Petal.Width>2,"High","Low")) iris %>% plot_ly(x = ~ Species, y = ~ Petal.Width, color= ~ S

我试图基于一个因子指定点符号(形状),以便箱线图中的点形状可以不同(这对于高亮显示一组点非常有用)。然而,看起来第三个方框图并没有显示不同的形状,而是分成了两个方框

你能告诉我如何做到这一点吗



data(iris)

iris=mutate(iris, Petal.Width_high=ifelse(Petal.Width>2,"High","Low"))

iris %>% plot_ly(x = ~ Species, y = ~ Petal.Width, color= ~ Species,
                 symbol = ~ Petal.Width_high,
                 type = "box", mode="markers",boxpoints="all",
                 jitter = 0.4, marker = list(size = 10),
                 pointpos = 0,hoverinfo='text',
                 text= ~paste('</br>Species: ', Species,
                              '</br>Petal.Width: ', Petal.Width))


数据(iris)
虹膜=变异(虹膜,花瓣宽度高=ifelse(花瓣宽度>2,“高”,“低”))
iris%>%plot\u ly(x=~物种,y=~花瓣宽度,颜色=~物种,
符号=~Petal.Width\u高,
type=“box”,mode=“markers”,boxpoints=“all”,
抖动=0.4,标记=列表(大小=10),
pointpos=0,hoverinfo='text',
text=~粘贴(“
种类:”,种类, “
花瓣宽度:”,花瓣宽度)

先绘制一个图,然后添加标记。比如:

p <- iris %>% 
  group_by(Species) %>%
  plot_ly(x = ~ Species, y = ~ Petal.Width, 
          type = "box", 
          hoverinfo='text',
          text= ~paste('</br>Species: ', Species,
                       '</br>Petal.Width: ', Petal.Width))

add_markers(p, symbol = ~ Petal.Width_high, marker = list(size = 10))
p%
组别(种类)%>%
plot\u ly(x=~物种,y=~花瓣宽度,
type=“box”,
hoverinfo='text',
text=~粘贴(“
种类:”,种类, “
花瓣宽度:”,花瓣宽度) 添加标记(p,符号=~Petal.Width,标记=列表(大小=10))