![](/img/trans.png)
[英]How to create shaded effects to display confidence interval / error bar on a ggplot2 bar chart?
[英]Plotly: How to remove the confidence interval values (from the error bar) in the tooltip?
我正在嘗試刪除 R Plotly 圖中工具提示中的誤差條值。
我曾嘗試使用這里的hovertext
參數: https : hovertext
但無法讓它工作。
我在一個函數中有這些,有時會有誤差條,但大多數時候沒有(因為我沒有數據)所以不需要工具提示中的額外細節(因為它只顯示+0/-0
)。
在下面的示例中,我希望它只顯示2010, 5
沒有置信區間。
有任何想法嗎?
library(tidyverse)
library(plotly)
data <- tibble(x = c(2010, 2011, 2012),
y = c(5, 6, 7),
err_high = c(1, 1, 1),
err_low = c(0.9, 1, 1.1))
#plotly graph
plot_ly() %>%
add_trace(data = data, x = ~x, y = ~y,
name = 'Actual', type = 'scatter', mode = 'lines+markers',
line = list(shape = 'linear', width= 4, dash = 'solid'),
error_y = list(type = "data", symmetric = FALSE, array = ~err_high, arrayminus = ~err_low)) %>%
layout(xaxis = list(title = 'Year'),
yaxis = list (title = 'Value', rangemode = "tozero"))
你可以包括
text=paste(data$x, data$y, sep=', '),
hoverinfo='text',
在add_trace()
中得到這個:
陰謀:
完整代碼:
library(tidyverse)
library(plotly)
data <- tibble(x = c(2010, 2011, 2012),
y = c(5, 6, 7),
err_high = c(1, 1, 1),
err_low = c(0.9, 1, 1.1))
#plotly graph
plot_ly() %>%
add_trace(data = data, x = ~x, y = ~y,
name = 'Actual', type = 'scatter', mode = 'lines+markers',
line = list(shape = 'linear', width= 4, dash = 'solid'),
text=paste(data$x, data$y, sep=', '),
hoverinfo='text',
error_y = list(type = "data", symmetric = FALSE, array = ~err_high, arrayminus = ~err_low)) %>%
layout(xaxis = list(title = 'Year'),
yaxis = list (title = 'Value', rangemode = "tozero"))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.