我使用这些数据:
| 月年|推销员|客户服务|投资组合|销售|单位|
| - -----|- -----|- -----|- -----|- -----|- -----|
| 2022年1月2日|0015| 0| 0| 0| 0|
| 2022年1月3日|0015| 0| 0| 0| 0|
| 2022年1月4日|0015| 1| 1| 62709.12| 4.56|
| 2022年1月5日|0015| 5个|4| 266568.56|二十六点九七|
| 2022年1月6日|0015|十四|七个|1251578.81|二百四十七点七六|
| 2022年1月7日|0015|十五|六|1419364.39| 333.6|
要在plotly R中创建双曲线图,请执行以下操作:
p <- 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))
问题是不希望标记位于文本注解的中心:
In the text annotation "Festival" in a mark in the middle :-(
有人能帮我吗?
1条答案
按热度按时间30byixjq1#
将inherit设置为false,如下所示:
因为看起来标记模式被向下传递到
add_text
层。因此: