我有一个数据集,看起来像这样:
> dput(dt)
structure(list(Odds.Ratio = c(0.34, 0.85, 0.38, 1.34, 0.98, 0.55,
0.34, 0.25), Lower.Bound.CI = c(0.12, 0.34, 0.33, 0.8, 0.67,
0.34, 0.22, 0.13), Upper.Bound.CI = c(0.66, 0.98, 0.67, 1.55,
1.42, 0.77, 0.5, 0.43), Cluster = c(1L, 1L, 1L, 1L, 2L, 2L, 2L,
2L)), class = "data.frame", row.names = c(NA, -8L))
我想绘制每个聚类的比值比,并在图中理想地指示置信区间的宽度。以下是我一直在做的:
library(plotly)
dt$Variance <- (dt$Upper.Bound.CI - dt$Lower.Bound.CI)
dt$Cluster <- as.factor(dt$Cluster)
fig <- plot_ly(
dt,
x = ~ Cluster,
y = ~ Odds.Ratio,
type = 'scatter',
mode = 'markers',
color = ~ Cluster,
size = ~ Variance
)
fig %>%
layout( xaxis = list(title = 'Cluster'),
yaxis = list(title = 'Odds Ratio'),
legend = list(title=list(text='<b> Cluster </b>')))
我的真实的数据集有更多的行,所以将点的大小与CI的方差/宽度对应起来有点困难。有更好的选择吗?谢谢!
1条答案
按热度按时间pjngdqdw1#
我们可以尝试用不同的符号来显示聚类,并用颜色来显示方差:
创建于2023-05-12带有reprex v2.0.2
数据: