# How to plot more ticks in AlgebraOfGraphics or Makie?

**URL:** <https://discourse.julialang.org/t/how-to-plot-more-ticks-in-algebraofgraphics-or-makie/77261>\
**Category:** General Usage\
**Tags:** plotting, makie, algebraofgraphics\
**Created:** [March 1, 2022, 9:35pm UTC](https://discourse.julialang.org/t/how-to-plot-more-ticks-in-algebraofgraphics-or-makie/77261 "2022-03-01T21:35:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ForceBru](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/forcebru/32/21389_2.png) [@ForceBru](https://discourse.julialang.org/u/ForceBru)\
**Post date:** [March 1, 2022, 9:35pm UTC](https://discourse.julialang.org/t/how-to-plot-more-ticks-in-algebraofgraphics-or-makie/77261/1 "2022-03-01T21:35:02Z")

</div>

I have this code to plot a time-series:

```julia
using AlgebraOfGraphics

data(
    (; x=1:100, y=randn(100))
) * mapping(:x, :y) * visual(Lines) |> draw

```

It produces this plot:

 ![plot](https://global.discourse-cdn.com/julialang/original/3X/e/6/e61db62eabf9bf3fd85a2134c2fb3a4eea364427.png)

**Question** : how to add _more ticks_ to `x` and/or `y` axis without constructing them manually? For example, I’d like to have 10 ticks on the `x` axis, not 3.

I can’t just use `axis = (xticks = LinearTicks(10),)` because in the actual plot I’m working on the `x` axis actually contains dates, so the ticks are autogenerated by AlgebraOfGraphics.

---

<div class="post-metadata">

**Author:** ![icweaver](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/icweaver/32/45764_2.png) [@icweaver](https://discourse.julialang.org/u/icweaver)\
**Post date:** [March 1, 2022, 10:40pm UTC](https://discourse.julialang.org/t/how-to-plot-more-ticks-in-algebraofgraphics-or-makie/77261/2 "2022-03-01T22:40:19Z")

</div>

I ran into this same issue too ([`LinearTicks` seems to alter the formatting for timeseries data · Issue #232 · MakieOrg/AlgebraOfGraphics.jl · GitHub](https://github.com/JuliaPlots/AlgebraOfGraphics.jl/issues/232)).

I think there is work being done upstream ([https://github.com/JuliaPlots/Makie.jl/pull/1347](https://github.com/JuliaPlots/Makie.jl/pull/1347)) so that we can handle time axes directly with Makie, but in the meantime @piever added this [convenience function](http://juliaplots.org/AlgebraOfGraphics.jl/dev/API/functions/#AlgebraOfGraphics.datetimeticks) in AoG that I think is really handy:

```julia
julia> using AlgebraOfGraphics, GLMakie, Dates

julia> t = DateTime(2021, 1, 1):Month(1):DateTime(2022, 1, 1);

julia> y = randn(length(t));

julia> df = (; t, y);

julia> ticks = AlgebraOfGraphics.datetimeticks(monthname, df.t[begin:2:end]);

julia> plt = data(df) * mapping(:t, :y) * visual(Lines);

julia> draw(plt; axis=(; xticks=ticks))

```

 ![index](https://global.discourse-cdn.com/julialang/original/3X/0/f/0ff85c50424b1e6f961e2394e0d7cfcd445d65c9.png)

You can pass any formatting function you want, although you will still need to play with the array of time points that is actually passed to it
