# Putting Date objects on xticks using Plots.jl

**URL:** <https://discourse.julialang.org/t/putting-date-objects-on-xticks-using-plots-jl/116171>\
**Category:** General Usage\
**Tags:** plotting, dates\
**Created:** [June 25, 2024, 2:23am UTC](https://discourse.julialang.org/t/putting-date-objects-on-xticks-using-plots-jl/116171 "2024-06-25T02:23:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aziz\_ben](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aziz_ben/32/50494_2.png) [@aziz\_ben](https://discourse.julialang.org/u/aziz_ben)\
**Post date:** [June 25, 2024, 2:23am UTC](https://discourse.julialang.org/t/putting-date-objects-on-xticks-using-plots-jl/116171/1 "2024-06-25T02:23:25Z")

</div>

Hi,

I tried to make a plot using Plots with dates under the ticks of the x axis but I ran into a problem. The dates are displayed in the plot in this format: yyyy/mm/ddT00:00:00. Does anyone know how to get rid of this? Here is the code I used.

using Dates  
using Plots

date\_strings = [“1/22/20”, “2/22/20”, “3/22/20”, “4/22/20”, “5/22/20”]  
data = [1, 2, 3, 4, 5]

format = Dates.DateFormat(“m/d/Y”)  
dates = parse.(Date, date\_strings, format) .+ Year(2000)

plot(dates, data, xticks=dates[1:end], rotation=45)

---

<div class="post-metadata">

**Author:** ![BatyLeo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/batyleo/32/35017_2.png) [@BatyLeo](https://discourse.julialang.org/u/BatyLeo)\
**Post date:** [June 25, 2024, 6:14am UTC](https://discourse.julialang.org/t/putting-date-objects-on-xticks-using-plots-jl/116171/2 "2024-06-25T06:14:27Z")

</div>

Hi,

You can use the `Dates.format` method to do that. In your example:

```julia
plot(dates, data; xticks=(dates, Dates.format.(dates, "m/d/yyyy")), rotation=45)

```

![test](https://global.discourse-cdn.com/julialang/original/3X/1/a/1a6e711db9df0ba4f69f0f28a1437e0db9a58c81.png)

---

<div class="post-metadata">

**Author:** ![aziz\_ben](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aziz_ben/32/50494_2.png) [@aziz\_ben](https://discourse.julialang.org/u/aziz_ben)\
**Post date:** [June 25, 2024, 11:42am UTC](https://discourse.julialang.org/t/putting-date-objects-on-xticks-using-plots-jl/116171/3 "2024-06-25T11:42:00Z")

</div>

Thank you 🙂
