Трасса scatter
имеет свою ось Y, установленную на y2
, а yaxis2
в layout
равно overlaying
y
.
Если вы хотите, чтобы трассировка scatter
находилась в фоновом режиме, измените назначение оси Y или установите overlaying
на y2
в yaxis
.
library(plotly)
airquality_sept <- airquality[which(airquality$Month == 9),]
airquality_sept$Date <- as.Date(paste(airquality_sept$Month,
airquality_sept$Day, 1973, sep = "."), format = "%m.%d.%Y")
plot_ly(airquality_sept) %>%
add_trace(x = ~Date, y = ~Temp, type = 'scatter', mode = 'lines', name = 'Temperature', yaxis = 'y2',
line = list(color = '#45171D')
) %>%
add_trace(x = ~Date, y = ~Wind, type = 'bar', name = 'Wind',
marker = list(color = '#C9EFF9', opacity = 0.5)
) %>%
layout(title = 'New York Wind and Temperature Measurements for September 1973',
xaxis = list(title = ""),
yaxis = list(side = 'left', title = 'Wind in mph', overlaying = "y2"),
yaxis2 = list(side = 'right', title = 'Temperature in degrees F'))