# X-axis without weekends

**URL:** <https://community.plotly.com/t/x-axis-without-weekends/1091>\
**Category:** plotly.js\
**Created:** [May 23, 2016, 11:18am UTC](https://community.plotly.com/t/x-axis-without-weekends/1091 "2016-05-23T11:18:02Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![valerio](https://avatars.discourse-cdn.com/v4/letter/v/3be4f8/32.png) [@valerio](https://community.plotly.com/u/valerio)\
**Post date:** [May 23, 2016, 11:18am UTC](https://community.plotly.com/t/x-axis-without-weekends/1091/1 "2016-05-23T11:18:02Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![prabhu](https://avatars.discourse-cdn.com/v4/letter/p/db5fbb/32.png) [@prabhu](https://community.plotly.com/u/prabhu)\
**Post date:** [May 25, 2016, 3:47pm UTC](https://community.plotly.com/t/x-axis-without-weekends/1091/2 "2016-05-25T15:47:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Laurent](https://avatars.discourse-cdn.com/v4/letter/l/ce7236/32.png) [@Laurent](https://community.plotly.com/u/Laurent)\
**Post date:** [June 6, 2016, 9:08pm UTC](https://community.plotly.com/t/x-axis-without-weekends/1091/3 "2016-06-06T21:08:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![valerio](https://avatars.discourse-cdn.com/v4/letter/v/3be4f8/32.png) [@valerio](https://community.plotly.com/u/valerio)\
**Post date:** [June 6, 2016, 10:40pm UTC](https://community.plotly.com/t/x-axis-without-weekends/1091/4 "2016-06-06T22:40:18Z")

</div>

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 .

---

<div class="post-metadata">

**Author:** ![vancuver1](https://avatars.discourse-cdn.com/v4/letter/v/9fc348/32.png) [@vancuver1](https://community.plotly.com/u/vancuver1)\
**Post date:** [June 21, 2016, 6:24am UTC](https://community.plotly.com/t/x-axis-without-weekends/1091/5 "2016-06-21T06:24:03Z")

</div>

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](https://plot.ly/python/axes/#enumerated-ticks-with-tickvals-and-ticktext)  
I stop at this point and remove plotly. 🙂 have a fun

---

<div class="post-metadata">

**Author:** ![andy\_graphs](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@andy\_graphs](https://community.plotly.com/u/andy_graphs)\
**Post date:** [October 30, 2019, 8:40pm UTC](https://community.plotly.com/t/x-axis-without-weekends/1091/6 "2019-10-30T20:40:37Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Emmanuelle](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/emmanuelle/32/7853_2.png) [@Emmanuelle](https://community.plotly.com/u/Emmanuelle)\
**Post date:** [April 2, 2020, 5:51pm UTC](https://community.plotly.com/t/x-axis-without-weekends/1091/7 "2020-04-02T17:51:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![JRP980](https://avatars.discourse-cdn.com/v4/letter/j/848f3c/32.png) [@JRP980](https://community.plotly.com/u/JRP980)\
**Post date:** [June 10, 2020, 10:17pm UTC](https://community.plotly.com/t/x-axis-without-weekends/1091/8 "2020-06-10T22:17:46Z")

</div>

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](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

 ![Screenshot 2020-06-10 at 12.10.56](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/1/13490061e36864815390229886f5a33f91ba44f2.png)

Is this because Rangebreaks are not yet available in R ?
