修改y轴

时间:2018-08-17 16:17:08

标签: r r-plotly

我有一个使用plotly r的图。到目前为止,这种变化还看不到太多。因此,如果这样做,如果y轴为0-70%,则可以在y轴上仅显示50%-70%,这样可以更清楚地看到变化。 以下是我正在使用的代码

output$plot <- renderPlotly({
  if (is.null(ab()))
    return(NULL)
  y <- list(title = "Percentange")
  x <- list(title = "Months")
  plot_ly(ab(), x = ~ Month_considered, y = ~ pct * 100,type = 'scatter', mode = 'marker',
    fill = 'tozeroy', line = list(color = 'rgb(205, 12, 24)', width = 4)) %>%layout(xaxis = x, yaxis = y)})

enter image description here

1 个答案:

答案 0 :(得分:1)

您没有提供可复制的示例,因此很难测试,但是您可以尝试:

y <- list(title = "Percentage", range = c(50,70))

plot_ly(ab(), x = ~ Month_considered, y = ~ pct * 100,type = 'scatter', mode = 'marker', fill = 'tozeroy', line = list(color = 'rgb(205, 12, 24)', width = 4)) %>% layout(xaxis = x, yaxis = y)}) 
相关问题