按颜色而不是按颜色*组在R绘图中绘制图例
我有两组的计数数据(按颜色而不是按颜色*组在R绘图中绘制图例,r,plotly,legend,violin-plot,R,Plotly,Legend,Violin Plot,我有两组的计数数据(G1和G2),其中第一组有两种类型的计数(T1和T2),第二组有三种类型的计数(T1、T2和T3): 其中: 如您所见,图例显示了类型*组的扩展,但我希望它只显示类型(即,在plot\ly函数中遵循color参数) 知道怎么做吗?删除split参数。删除split参数。 set.seed(1) df <- data.frame(count = rpois(100,100), type = c(rep("T1",20), rep("T2
G1
和G2
),其中第一组有两种类型的计数(T1
和T2
),第二组有三种类型的计数(T1
、T2
和T3
):
其中:
如您所见,图例显示了类型
*组
的扩展,但我希望它只显示类型
(即,在plot\ly
函数中遵循color
参数)
知道怎么做吗?删除
split
参数。删除split
参数。
set.seed(1)
df <- data.frame(count = rpois(100,100),
type = c(rep("T1",20), rep("T2",20), rep("T1",20), rep("T2",20), rep("T3",20)),
group = c(rep("G1",40), rep("G2",60)),
stringsAsFactors = F)
df$type <- factor(df$type)
library(plotly)
plot_ly(x = df$group, y = df$count, split = df$group, type = 'violin', box = list(visible = F), points = F,showlegend = T, color = df$type)