[英]R plotly: Add text in polar scatter plot
Let's say I have a simple scatter plot using R plotly
.假设我有一个使用 R
plotly
的简单散点图。 And I want to put text at each points of scatter plot as shown.我想在散点图的每个点上放置文本,如图所示。
Simple R polar chart :简单的 R 极坐标图:
library(plotly)
p <- plot_ly(
type = 'scatterpolar',
r = c(0,1,2,2),
theta = c(0,45,90,120),
size = c(10, 20, 30, 40),
sizes = c(100, 300),
mode = 'markers'
)
p
Output Chart :输出图表:
In the same way using plot_ly
with scatterpolar
, How can I put text at the center of each bubble with some value let's say value of size
column.?在使用同样的方式
plot_ly
与scatterpolar
,我怎样才能把文字在每个气泡具有一定的价值假设值中心size
列?
Thanks in Advance!提前致谢!
Adding answer, for future reference in SO community.添加答案,以供将来在 SO 社区中参考。 I found the solution using
add_trace
我使用
add_trace
找到了解决方案
R code :代码:
library(plotly)
p <- plot_ly(
type = 'scatterpolar',
r = c(0,1,2,2),
theta = c(0,45,90,120),
size = c(10, 20, 30, 40),
sizes = c(100, 300),
mode = 'markers'
) %>%
add_trace(
r = c(0,1,2,2),
theta = c(0,45,90,120),
mode = "text",
text = c(10, 20, 30, 40),
textfont = list(color = '#000000', size = 12)
)
p
Chart :图表:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.