0
我在R(版本3.4)中使用plotly(版本4.6.0)在它們周圍創建兩個置信區間的線。傳說沒有顯示。任何人都有猜測發生了什麼?Plotly在R中沒有顯示兩個置信區間的圖例
看來,傳說開關被忽略。對於填充(置信區間)而言是錯誤的,對於主要情節則是正確的。把它們全部變爲真實給出了六個圖例條目,但我只想要兩個。
下面的代碼:
plot_ly(x = ~observed$time, y = ~observed$interval_upper,
type = 'scatter',
mode = 'lines',
line = list(color = 'transparent'),
showlegend = FALSE,
name = 'Upper bound')
%>% add_trace(x = ~observed$time, y = ~observed$interval_lower,
type = 'scatter',
mode = 'lines',
fill = 'tonexty',
fillcolor='rgba(255,127,14,0.2)',
line = list(color = 'transparent'),
showlegend = FALSE,
name = 'Lower bound')
%>% add_trace(x = ~observed$time, y = ~observed$observed_power,
type = 'scatter',
mode = 'lines',
line = list(color='rgb(255,127,14)'),
showlegend = TRUE,
name = 'Observed')
%>% add_trace(x = ~forecast$time, y = ~forecast$interval_upper,
type = 'scatter',
mode = 'lines',
line = list(color = 'transparent'),
showlegend = FALSE,
name = 'Upper bound')
%>% add_trace(x = ~forecast$time, y = ~forecast$interval_lower,
type = 'scatter',
mode = 'lines',
fill = 'tonexty',
fillcolor='rgba(31,119,180,0.2)',
line = list(color = 'transparent'),
showlegend = FALSE,
name = 'Lower bound')
%>% add_trace(x = ~forecast$time, y = ~forecast$baseline_power,
type = 'scatter',
mode = 'lines',
line = list(color='rgb(31,119,180)'),
showlegend = TRUE,
name = 'Forecast')
%>% layout(legend = list(x = 0.80, y = 0.90))
謝謝。那就是訣竅。 – fifthace
很高興聽到這一點 –