R中的动画简介——多轨迹动画——轨迹顺序

R中的动画简介——多轨迹动画——轨迹顺序,r,animation,plotly,R,Animation,Plotly,在中,对于多个迹线,如何按大陆变量操纵颜色的顺序?在最初的示例中,它是一个非对称顺序。但我希望大洋洲第一,亚洲第二,依此类推。。。。我该怎么做?非常感谢你的帮助 library(plotly) library(gapminder) df <- gapminder fig <- df %>% plot_ly( x = ~gdpPercap, y = ~lifeExp, size = ~pop, color = ~factor(cont

在中,对于多个迹线,如何按大陆变量操纵颜色的顺序?在最初的示例中,它是一个非对称顺序。但我希望大洋洲第一,亚洲第二,依此类推。。。。我该怎么做?非常感谢你的帮助

library(plotly)
library(gapminder)

df <- gapminder 
fig <- df %>%
  plot_ly(
    x = ~gdpPercap, 
    y = ~lifeExp, 
    size = ~pop, 
    color = ~factor(continent,levels = c("Oceania","Asia","Americas","Europe","Africa")), ##specifying as an ordered factor does not help
    frame = ~year, 
    text = ~country, 
    hoverinfo = "text",
    type = 'scatter',
    mode = 'markers'
  )
fig <- fig %>% layout(
  xaxis = list(
    type = "log"
  )
)

fig

library(plotly)
图书馆(gapminder)

df我在plotly support页面中发现一条注释,该注释表示还不支持对图例位置进行重新排序。这是不到6个月前的事,所以我怀疑这可能还没有改变。