Plotly R: Cant get points to plot when two values present per x factor level

你离开我真会死。 提交于 2019-11-29 12:38:14
Steven Beaupré

Isn't this a duplicate of your previous question and related to this github issue ?

Currently you need to manually specify that you have a categorical axis.

plot_ly(df, x = x, y = y, mode = "markers") %>% layout(xaxis = list(type = "category"))

Right now we just sent the factor levels as a string to plotly.js

plotly_build(plot_ly(df, x = x, y = y, mode = "markers"))$data[[1]]$x

Based on those strings, plotly.js (correctly) thinks that you want a numeric axis. In the future, we should set smarter axis type defaults based on the variable mappings.

If you do:

plot_ly(df, x = x, y = y, mode = "markers") %>% 
      layout(xaxis = list(type = "category"))

You'll get:

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!