Home > Enterprise >  Display only positive values of axis in plotly chart
Display only positive values of axis in plotly chart

Time:01-08

In the plotly chart below I want to display only the positive values of the y-axis and not the negative.

df<-data.frame(
  Country<-"AL",
  Year<-2003,
  Scope<-0
)
library(plotly)
fig <- plot_ly(
  data = df,
  x = ~ Year,
  y = ~ Scope,
  type = "scatter",
  mode = "lines markers",
  marker = list(
    size = 10,
    color = 'rgba(255, 182, 193, .9)',
    line = list(color = 'rgba(152, 0, 0, .8)',
                width = 2)
  ),
  line = list(color = 'rgba(152, 0, 0, .8)',
              width = 2)
) %>% layout(
  title = "Count of Scope per country and year",
  xaxis = list(
    dtick = 5
  ),
  yaxis = list(
    dtick = 1,
    tick0 = 0
  )
)

fig

CodePudding user response:

You can achieve the result you are looking for using, rangemode inside yaxis parameters.

According to the enter image description here

  •  Tags:  
  • Related