plotly / plotly/plotly.R

Bubble changing color and representing a different category in animated scatter plot

Aberta
#2,146 0 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Linguagem predominante
R
Estrelas
2.7k
Forks
641
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição


I was trying to create an animated scatter plot with each bubble representing a race category indicated by a color. In the actual data set, some race categories don't data in certain years. When those years were excluded, the plot looked fine. However, when those years were not excluded, some bubbles changed colors and turned into a different race category . For example, in the code below, race 4 changed into race 5 in year 6 when race 4 actually does not have data in year 6 - year 9. Thanks!

str <-
  "seq, race, achievement, growth, size
year 1, race 6, 41.5, 35.5,  54
year 2, race 6, 45.5, 48.5,  54
year 3, race 6, 37.0, 34.5,  64
year 4, race 6, 42.0, 29.5,  62
year 5, race 6, 39.0, 40.0,  60
year 6, race 6, 39.0, 41.0,  71
year 7, race 6, 33.0, 40.0,  74
year 8, race 6, 25.0, 42.0,  59
year 9, race 6, 24.0, 55.0,  59
year 1, race 2, 22.0, 36.0, 357
year 2, race 2, 23.0, 43.0, 357
year 3, race 2, 21.0, 42.0, 359
year 4, race 2, 18.0, 45.0, 364
year 5, race 2, 21.0, 42.0, 351
year 6, race 2, 20.0, 54.0, 353
year 7, race 2, 17.0, 41.0, 370
year 8, race 2, 13.0, 46.0, 319
year 9, race 2, 14.0, 48.0, 318
year 1, race 3, 39.0, 47.0,   2
year 2, race 3, 29.5, 28.5,   2
year 3, race 3, 36.0, 29.5,   2
year 4, race 3, 34.5, 64.5,   2
year 5, race 3, 35.5, 70.5,   2
year 6, race 3, 69.0, 35.0,   1
year 7, race 3, 60.0, 21.0,   1
year 1, race 5, 65.0, 59.0,  23
year 2, race 5, 68.0, 44.0,  23
year 3, race 5, 54.0, 57.0,  17
year 4, race 5, 49.0, 43.0,  19
year 5, race 5, 45.5, 49.0,  20
year 6, race 5, 54.0, 64.0,  23
year 7, race 5, 48.0, 56.0,  32
year 8, race 5, 37.0, 68.0,  35
year 9, race 5, 37.0, 58.0,  37
year 1, race 7, 35.0, 46.0,  99
year 2, race 7, 40.0, 57.5, 100
year 3, race 7, 37.0, 40.0, 113
year 4, race 7, 36.0, 51.5, 110
year 5, race 7, 33.0, 41.0, 108
year 6, race 7, 39.0, 53.0, 101
year 7, race 7, 30.0, 40.0, 106
year 8, race 7, 28.0, 53.0, 111
year 9, race 7, 28.0, 53.0, 106
year 1, race 4, 74.5, 93.0,   2
year 2, race 4, 69.5, 80.5,   2
year 3, race 4, 84.0, 98.0,   1
year 4, race 4, 82.0, 44.0,   1
year 5, race 4, 60.0,  3.0,   1
year 1, race 1, 47.0, 38.0, 461
year 2, race 1, 48.0, 42.5, 454
year 3, race 1, 49.0, 41.0, 449
year 4, race 1, 48.0, 52.0, 461
year 5, race 1, 47.0, 42.0, 448
year 6, race 1, 52.0, 47.0, 412
year 7, race 1, 47.0, 39.0, 416
year 8, race 1, 38.0, 46.5, 362
year 9, race 1, 41.0, 51.0, 362"
dt <- read.table(textConnection(str), header=T, sep=",", na.strings=" ")

plot_ly(dt) %>% 
  add_markers(x = ~achievement, y = ~growth, size = ~size, 
              color = ~race, 
              frame = ~seq,
              hoverinfo = 'text', text = ~paste(race, size, sep = '\n'), 
              marker = list(opacity = 0.5, sizemode = 'diameter'))  

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Direção de pesquisa

Comece executando o exemplo reproduzível em R da issue com plotly.R e compare os frames animados em que a corrida 4 não tem dados. Rastreie como os valores dos frames são associados às cores dos marcadores. A tarefa estará concluída quando cada corrida mantiver a cor atribuída a ela quando houver categorias ausentes nos anos posteriores.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
r
Domínio
data-visualization
Tipo de issue
Bug
Dificuldade
3/5
Tempo estimado
1-2 dias
Status de atividade
Estagnada
Clareza
Claramente especificada
Facilidade para iniciantes
45/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.