我有一个大的数据集,有600条谱线,我的解决方案可以用更少的谱线,但是现在无法显示谱线。如果我用鼠标悬停在图表区域上,则数据信息显示出来,只有该区域是
我尝试了融化数据集并作相应的绘图。
由于某种原因,我在较小的电视机上使用的ggplotly例程不适用于此电视机。将鼠标悬停在图表区域上时会显示数据标签,但看不到任何线。
YellowBloodVar <- ncol( AEDPlotSG %>% #117
select(starts_with("Y_Bld")))
YellowCleanVar <- ncol( AEDPlotSG %>% #3
select(starts_with("Y_Cl")))
RedBloodVar <- ncol( AEDPlotSG %>% #88
select(starts_with("R_Bld")))
RedCleanVar <- ncol( AEDPlotSG %>% #1
select(starts_with("R_Cl")))
GreenBloodVar <- ncol( AEDPlotSG %>% #83
select(starts_with("G_Bld")))
GreenCleanVar <- ncol( AEDPlotSG %>% #7
select(starts_with("G_Cl")))
BlueBloodVar <- ncol( AEDPlotSG %>% #41
select(starts_with("B_Bld")))
BlueCleanVar <- ncol( AEDPlotSG %>% #159
select(starts_with("B_Cl")))
PulpBloodVar <- ncol( AEDPlotSG %>% #92
select(starts_with("P_Bld")))
PulpCleanVar <- ncol( AEDPlotSG %>% #7
select(starts_with("P_Cl")))
AEDDataMelt <- data.frame( melt(AEDPlotSG, id.vars = 'Wavelength', variable = 'series'))
MyLineType <- rep.int(2,((YellowBloodVar+YellowCleanVar+RedBloodVar+RedCleanVar+GreenBloodVar+GreenCleanVar+BlueBloodVar+BlueCleanVar+PulpBloodVar+PulpCleanVar)))
#Add linetype 1 (solid) as indication of mean value and calculate the lenght of the array------------------------------------------------
MyLineType <- append(MyLineType,c(1,1),after = length(MyLineType))
#MyColorsData <- rep.int("black",(length(PlotData[1, 2:(ncol(PlotData))])))
MyColorsYellowBlood <- rep.int("lightgoldenrod4",YellowBloodVar)
MyColorsRedBlood <- rep.int("red4",RedBloodVar)
MyColorsGreenBlood <- rep.int("green4",GreenBloodVar)
MyColorsBlueBlood <- rep.int("blue",BlueBloodVar)
MyColorsPulpBlood <- rep.int("antiquewhite",PulpBloodVar)
MyColorsYellowClean <- rep.int("lightgoldenrod1",YellowCleanVar)
MyColorsRedClean <- rep.int("red",RedCleanVar)
MyColorsGreenClean <- rep.int("green",GreenCleanVar)
MyColorsBlueClean <- rep.int("cadetblue1",BlueCleanVar)
MyColorsPulpClean <- rep.int("antiquewhite3",PulpCleanVar)
MyColors <- c(MyColorsYellowClean, MyColorsRedClean, MyColorsGreenClean, MyColorsBlueClean, MyColorsPulpClean, MyColorsYellowBlood,
MyColorsRedBlood,MyColorsGreenBlood,MyColorsBlueBlood,MyColorsPulpBlood, "red", "blue")
Q <- ggplot(AEDDataMelt) +
geom_line(aes(Wavelength, value, colour = series, linetype = series)) +
# First n lines are of one type, last line is reference and should be different--------------------------------------------------------
scale_linetype_manual(values = MyLineType)+
# First six lines are from the brewer pallette, last one a custom colour-----------------------------------------------
scale_colour_manual(values = c(MyColors))
ggplotly(Q) %>%
layout(
xaxis = list(
dtick = (BandwidthWavelength/100),
tick0 = (CenterWavelength - BandwidthWavelength),
tickmode = "linear"
))
由reprex package(v0.3.0)于2019-06-26创建