X-axis without weekends

I’m using plotly -finance , the values ​​on the x axis are dates.
I would like to remove the spaces that are formed with the weekends. Then remove the display of the days that correspond to the weekends.
How can I do?

Been trying to find a solution for the same problem. Please update if you find a solution!

I have the same issue too. Has anyone found a solution since then?

I tried to change the type of the x axis , changing in “category” , but without results .
I also tried to look for the piece of code that deals with the creation dates of the type , if you find a way to add a new type " datewithoutweekends " let me know , I 'm trying this solution .

Hi all. You can try this:

  1. replace date index with int values [from 1 to days_count]
  2. For labels with dates, there is source with ticktext example https://plot.ly/python/axes/#enumerated-ticks-with-tickvals-and-ticktext
    I stop at this point and remove plotly. :slight_smile: have a fun

Has anyone found a good solution for skipping weekends?
changing the x-axis type to ‘category’ works if all of your dates/times are consistent with each other. You start to run into issues if your time series is a list of arbitrary timestamps so the ‘category’ doesn’t necessarily line up.

This feature is now available in plotly.js 1.53 / plotly.py 4.6. See the Python documentation on date axis range breaks, which can be easily adapted to Javascript since the low-level API is shared. Also see https://plotly.com/javascript/reference/#layout-xaxis-rangebreaks

2 Likes

Does this work in R ?

I have tried the following and it doesn’t hide the weekends…


library(readr)
library(plotly)

a <- read_csv(“https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv”)

plot_ly(a[450:500,], x = ~Date, y = ~AAPL.High, type=‘scatter’, mode = ‘markers’) %>%
layout(xaxis = list(
rangebreaks= list (
values= c(“2016-12-25”, “2016-12-24”,“2016-12-26”,“2017-01-01”))
))


Output plot is given below

Is this because Rangebreaks are not yet available in R ?