1

Let's say I have a simple scatter plot using R plotly. And I want to put text at each points of scatter plot as shown.

Simple R polar chart:

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:

enter image description here

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.?

Thanks in Advance!

Om Sao
  • 7,064
  • 2
  • 47
  • 61

1 Answers1

1

Adding answer, for future reference in SO community. I found the solution using 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:

enter image description here

Om Sao
  • 7,064
  • 2
  • 47
  • 61