R绘图-更改x轴标签

时间:2018-09-27 08:41:02

标签: r layout label plotly

如何更改x轴值以图形方式显示文本(不影响数据)?

X数据当前为:

randomCH4X <- seq(1, 12, by=1)

我想将这些X值从数字值更改为月份。但是,当我尝试使用以下方法进行操作时,图形将变得怪异/崩溃。

randomCH4X <- c('January', 'February', 'March', 'April', 'May', 'June')   

我的代码:

plot_ly(CH4, x=~X, y=~DR05, frame=~frame, 
        name='DR05',  hoverinfo = 'text',
        text = ~paste('Test Round: ', CH4$X, '<br>',
                      'Concentration: ', CH4$SECOND),
        type = 'scatter', mode = 'lines') %>%
  add_trace(x=~X, y = ~SR07, name='SR07', mode = 'lines') %>%
  animation_opts(
    100, transition = 0, redraw = FALSE
  ) %>%

  layout(yaxis = list(title = 'CH4 Concentrations'), 
         xaxis = list(title = 'Test Round'))

感谢您的帮助,谢谢!

0 个答案:

没有答案