我有一个数据集,其中包含理论和实验数据,我想将其绘制到同一张图上.我希望理论数据用"线"画出来,实验数据用"记号"画出来.这有点困难,因为这两个数据集具有不同数量的数据点.
我已经创建了一个简化的、可重现的示例:
library(plotly)
library(colorBlindness)
experimentaldata<-data.frame(hours=c(1,2,3,4,5,6,7,8,9),
concentration=c(0.25, 0.3, 0.8, 0.75, 0.3, 0.1, 0.9, 0.98, 1),
name=c("Chloride", "Chloride", "Chloride", "Sulfate", "Sulfate", "Sulfate", "Bicarbonate", "Bicarbonate", "Bicarbonate"))
theoreticaldata<-data.frame(hours=c(1, 3, 5, 7, 9),
concentration=c(0.45, 0.38, 0.27, 0.8, 0.66),
name=c("Chloride_exp", "Chloride_exp", "Chloride_exp", "Sulfate_exp", "Sulfate_exp")
)
allchemicals<-rbind(experimentaldata, theoreticaldata)
fig<-plot_ly(allchemicals, x=~hours, y=~concentration,type='scatter', mode="lines", color=~name, colors=SteppedSequential5Steps)
print(fig)
这段代码获取两个数据集,将它们绑定在一起,然后绘制它们.我试着以列表的形式传递这些模式,比如
模式=c("标记",...,"行"),但它一次只能采用一种模式.有什么办法解决这个问题吗?
谢谢