Black Lives Matter. Please consider donating to Black Girls Code today.
Learn how to use COVID-19 data in open source Dash apps. Register for the Sept 23rd webinar with IQT!

How to set the default value of y- axis or any value as a default for the first plot

I have plotted the the 5 major cities temperature values, but it print like blank. I would like to set the Melbourne temperature as a default values. Can you help me out please. I have attached my interactive version here.First_Plot https://plot.ly/~Nrnjn_adhikari/23/

p2 <- plot_ly(data = temp_data) %>%

add_lines(x=~Date, y=~Melbourne, name = “Melbourne”, visible = “legendonly”) %>%
add_lines(x=~Date, y=~Sydney, name = “Sydney”, visible = “legendonly”) %>%
add_lines(x=~Date, y=~Perth, name = “Perth”, visible = “legendonly”) %>%
add_lines(x=~Date, y=~Darwin, name = “Darwin”, visible = “legendonly”) %>%
add_lines(x=~Date, y=~Adelaide, name = “Adelaide”, visible = “legendonly”) %>%

layout(title = “Australian Major Cities Temperature Time Series”, showlegend=TRUE,
xaxis=list(zeroline = FALSE,title=“Date”, rangeslider = list(type = “date”)),
yaxis=list(zeroline = FALSE,title=“Temperature (Celsius)”),
updatemenus=updatemenus)

p2

Hey @Nrnjn_adhikari

Consider using / changing active and showactive attributes in updatemenus https://plot.ly/r/reference/#layout-updatemenus-active

Hi @bcd, Thank you very much for your response. I could not get fix it yet. I have attached my update menus here. Can you please check this one. I will truly appreciate your time and effort.

updatemenus <- list(
list(
active = 0,
x = -.125,
type= ‘buttons’,
buttons = list(
list(
label = “Melbourne”,
method = “update”,
args = list(list(visible = c(TRUE, “legendonly”, “legendonly”,
“legendonly”, “legendonly” )))),
list(
label = “Sydney”,
method = “update”,
args = list(list(visible = c(“legendonly”, TRUE, “legendonly”,
“legendonly”, “legendonly”)))),
list(
label = “Perth”,
method = “update”,
args = list(list(visible = c(“legendonly”, “legendonly”, TRUE,
“legendonly”, “legendonly”)))),
list(
label = “Darwin”,
method = “update”,
args = list(list(visible = c(“legendonly”, “legendonly”, “legendonly”,
TRUE, “legendonly”)))),
list(
label = “Adelaide”,
method = “update”,
args = list(list(visible = c(“legendonly”, “legendonly”, “legendonly”,
“legendonly”, TRUE))))
)
)
)

Now, problem has been resolved :slight_smile: when I deleted the legendonly inside the add_lines.
I have changed the single code in inside the plot object, this is corrected line
add_lines(x=~Date, y=~Melbourne, name = “Melbourne”) %>%

Cheers