size argument passed to annotations not respected?
Nessuno ha ancora preso questa issue.
- Lingua principale
- R
- Stelle
- 2.7k
- Fork
- 641
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
I understand this issue has a chance of being an off-topic implementation issue. If so, please accept my sincere apologies in advance. Frank Harrell reported he is unable to change size of the annotated text using the code below.
require(plotly)
p <- plot_ly()
p <- add_markers(p,x=~1:2, y=~1:2)
p <- add_annotations(p, x=~c(1.1, 2.1), y=~c(1.2, 2.4),
text=~c('XXX','YYY'), size=~c(7,20))
p
I was unable to account for size of text using the 'old' method using 'layout' (as discussed in #744).
ann <- data.frame(x = c(1.1, 2.1),
y = c(1.2, 2.4),
size = c(10, 20),
text = c("XXX", "YYY"))
xy <- data.frame(x = c(1, 2), y = c(1, 2))
a <- vector("list", nrow(ann))
for (i in 1:nrow(ann)) {
a[[i]] <- list(
x = ann$x[i],
y = ann$y[i],
text = ann$text[i],
xref = "x", yref = "y",
showarrow = TRUE,
size = ann$size[i]
)
}
plot_ly(xy, x = ~x, y = ~y) %>%
add_markers() %>%
layout(annotations = a)
@cpsievert suggested using add_annotations but I'm a bit lost on how to pass on the size argument. Based on the documentation and some examples scattered over the internet, I tried
plot_ly(xy, x = ~x, y = ~y) %>%
add_markers() %>%
add_annotations(text = ~text, font = list(size = ~size), data = ann)
with no luck. Is there something I'm doing wrong?
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia riproducendo gli esempi forniti di add_annotations, inclusa la forma font = list(size = ~size) e l’approccio di layout precedente. Segui l’entry point add_annotations per vedere come viene passato il size dell’annotazione, quindi verifica che le annotazioni vengano renderizzate con le dimensioni per riga richieste.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- r
- Ambito
- data-visualization
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100