Alejandro Carrera
Alejandro Carrera

Reputation: 557

How to hide slider from plotly in R?

I'm trying to make some candlestick with plotly and I just have one problem: I don't want the slider from the bottom to show up, I just want my whole graph to be displayed.

enter image description here

I read some documentation and sliders=list(visible=F)) should do the trick but if you run the following code, the slider still appears. Any help will be much appreciated.

library(tidyverse)
library(binancer)
library(plotly)
library(TTR)
library(lubridate)
   

 sma <- binance_klines("KAVAUSDT", interval = "3m", 
        start_time=Sys.time()-hours(10), end_time=Sys.time())%>%
        select(open_time, open, high, low, close)%>%
        rename(time=1)%>%
        mutate(SMA_5= SMA(close, 5), SMA_10= SMA(close,10), SMA_20= SMA(close,20))
    
    
    sma %>% plot_ly(x = ~time, type="candlestick",
                           open = ~open, close = ~close,
                           high = ~high, low = ~low) %>%
        add_lines(x = ~time, y= ~SMA_5,  line = list(color = "tomato", width = 1.25), inherit = F,
                    name = "SMA 5", showlegend=T)%>%
        add_lines(x = ~time, y= ~SMA_10,  line = list(color = "blue", width = 1.25), inherit = F,
                    name = "SMA 10", showlegend=T)%>%
        add_lines(x = ~time, y= ~SMA_20,  line = list(color = "deeppink", width = 1.25), inherit = F,
                    name = "SMA 20", showlegend=T)%>%       
        layout(title = "KAVA Simple Moving Average 3m",
            xaxis= list(title="Time"), yaxis = list(title = "Price"),
            sliders=list(visible=F))

Upvotes: 1

Views: 319

Answers (1)

TarJae
TarJae

Reputation: 78917

See reference here: https://plotly.com/r/candlestick-charts/ Change the layout part with this code:

  layout(title = "KAVA Simple Moving Average 3m",
         xaxis = list(rangeslider = list(visible = F)), 
         yaxis = list(title = "Price"))

enter image description here

Upvotes: 2

Related Questions