是否有可能在文本注释中用绘图R来消除标记



我正在使用以下数据:

Month-year
2022年1月2日 2022年1月3日 2022年1月4日 2022年5月1日 2022年1月6日 2022年1月7日

将inherit设置为false like:

add_text(..., inherit = FALSE)

因为标记模式似乎向下传递到CCD_ 1层。

因此:

df <- read.table(
text =
"
Month-year  Salesman    Clients Portafolio  Sales   Units
1/2/2022    0015    0   0   0   0
1/3/2022    0015    0   0   0   0
1/4/2022    0015    1   1   62709.12    4.56
1/5/2022    0015    5   4   266568.56   26.97
1/6/2022    0015    14  7   1251578.81  247.76
1/7/2022    0015    15  6   1419364.39  333.6
", header = T, check.names = F
)
plot_ly(df,
x = ~`Month-year`,
y = ~Portafolio,
type = "scatter",
mode = "lines+markers",
name = "Portafolio",
marker = list(color = "#2ca02c", line = list(color = "#2ca02c")),
line = list(color = "#2ca02c")
) %>%
add_trace(
x = ~`Month-year`,
y = ~Clients,
type = "scatter",
mode = "lines+markers",
yaxis = "y2", name = "Clients",
marker = list(color = "#ff7f0e"),
line = list(color = "#ff7f0e")
) %>%
layout(
yaxis2 = list(
title = "Clients", side = "right", overlaying = "y",
side = "right", automargin = T, showgrid = FALSE,
rangemode = "tozero"
), yaxis = list(
showgrid = FALSE,
rangemode = "tozero"
),
xaxis = list(showticklabels = TRUE, visible = TRUE), title = "0015",
legend = list(orientation = "h", x = 0, y = 1), shapes =
list(list(
type = "rect", text = "Festival", fillcolor = "green",
line = list(color = "green"), opacity = 0.2, y0 = 0.0,
y1 = max(df$Clients), x0 = "2022-06-01", x1 = "2022-07-01",
plot_bgcolor = "#e5ecf6"
))
) %>%
add_text(
showlegend = FALSE, x = "2022-06-15", y = max(df$Clients) + max(df$Clients) * 0.03,
text = "Festival", textfont = list(color = "green", size = 15), inherit = F
)

最新更新