我有来自几个组的测量数据,我想将它们绘制成小提琴图:
使用R语言的ggplot2:
我理解到您需要将以下文本从英语翻译成中文:
我得到的翻译是:
set.seed(1)
df <- data.frame(val = c(runif(100,1,5),runif(100,1,5),rep(0,100)),
group = c(rep("A",100),rep("B",100),rep("C",100)))
使用R语言的ggplot2:
library(ggplot2)
ggplot(data = df, aes(x = group, y = val, color = group)) + geom_violin()
我理解到您需要将以下文本从英语翻译成中文:
我得到:
![enter image description here](https://istack.dev59.com/1cvEw.webp)
但是当我尝试使用R
的plotly
获取等效内容时:
library(plotly)
plot_ly(x = df$group, y = df$val, split = df$group, type = 'violin', box = list(visible = F), points = F, showlegend = T, color = df$group)
我得到的翻译是:
我得到:
![enter image description here](https://istack.dev59.com/dnVno.webp)
在这里,C组获得了一个充气/人造小提琴。
有没有想法如何处理这个问题,而不使用ggplotly
?
spanmode
参数:fig = go.Figure() fig.add_trace(go.Violin(y=distances, name=name, spanmode="hard"))
根据文档,我认为这个方法在R中也适用:https://plotly.com/r/reference/#violin-spanmode - undefined