R Plotly Rangeslider covers tick marks - is it possible to set Rangeslider location?
I am using the Plotly package in R to make a plot with both a range and a rangeselector.
The problem is that the range of ranges tends to cover the tick marks on the x-axis.
The solution might be to manually set the location of the range, but I can't find any documentation on how to do this.
Below you will find a minimal working example of the problem along with its image.
# Make Some Data:
Dates = as.POSIXct(c("2017-08-08 00:00")) + (0:71)*60^2
Values = rep_len(mtcars$mpg, 72)
tb = dplyr::tibble(Values, Dates)
# Plot
p = tb %>% plot_ly(type = "scatter", mode = 'markers', x = ~Dates, y = ~Values) %>%
layout(xaxis = list(
rangeslider = list(type = "date"),
rangeselector = list(
buttons = list(list(step = "all", label = "All")))
))
p
Any help would be greatly appreciated! Greetings,
source to share
After running around with different options / settings, I found that increasing the length of the checkboxes and the appearance of ticks on the inside of the x-axis, and not on the outside, solved my problem.
See below code for example
# Make Some Data:
Dates = as.POSIXct(c("2017-08-08 00:00")) + (0:71)*60^2
Values = rep_len(mtcars$mpg, 72)
tb = dplyr::tibble(Values, Dates)
# Plot
p = tb %>% plot_ly(type = "scatter", mode = 'markers', x = ~Dates, y = ~Values) %>%
layout(xaxis = list(ticks = "inside", ticklen = 10,
rangeslider = list(type = "date", thickness=0.1),
rangeselector = list(
buttons = list(list(step = "all", label = "All")))
))
p
However, this is a hackish solution and I am still looking at a method for determining the position of the range.
source to share
Try to solve the overlap problem by adjusting the parameter thickness
rangeslider
:
# Make Some Data:
Dates = as.POSIXct(c("2017-08-08 00:00")) + (0:71)*60^2
Values = rep_len(mtcars$mpg, 72)
tb = dplyr::tibble(Values, Dates)
# Plot
p = tb %>% plot_ly(type = "scatter", mode = 'markers', x = ~Dates, y = ~Values) %>%
layout(xaxis = list(
rangeslider = list(type = "date", thickness=0.3),
rangeselector = list(
buttons = list(list(step = "all", label = "All")))
))
p
Hope this helps you.
source to share