# Removing numeric labels from axis

**URL:** <https://discourse.julialang.org/t/removing-numeric-labels-from-axis/89237>\
**Category:** Visualization\
**Tags:** question, plotting, plots\
**Created:** [October 25, 2022, 7:11am UTC](https://discourse.julialang.org/t/removing-numeric-labels-from-axis/89237 "2022-10-25T07:11:21Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryofurue](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ryofurue/32/24531_2.png) [@ryofurue](https://discourse.julialang.org/u/ryofurue)\
**Post date:** [October 25, 2022, 7:11am UTC](https://discourse.julialang.org/t/removing-numeric-labels-from-axis/89237/1 "2022-10-25T07:11:21Z")

</div>

I fear this might be a stupid question . . . but, how does one remove the numeric labels from an axis in a `plot`?

I searched the documentation

[https://docs.juliaplots.org/latest/attributes/](https://docs.juliaplots.org/latest/attributes/)

but didn’t find an option. (It’s entirely possible that I’m missing it, though.)

In the following example, I’d like to remove the numeric labels “-4”, “-2”, “0”, etc. from the y axis, leaving the tick marks and grid lines intact.

```julia
using Plots
plot(100:100:300, hcat([1, 2, 4], [-1,-2,-4]))

```

For my actual plot, I’d like to do this because only the relative amplitudes of the curves matter.

---

<div class="post-metadata">

**Author:** ![runjaj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/runjaj/32/23628_2.png) [@runjaj](https://discourse.julialang.org/u/runjaj)\
**Post date:** [October 25, 2022, 11:13am UTC](https://discourse.julialang.org/t/removing-numeric-labels-from-axis/89237/2 "2022-10-25T11:13:49Z")

</div>

> [@ryofurue](#):
>
> `plot(100:100:300, hcat([1, 2, 4], [-1,-2,-4]))`

This is just a hack…

```julia
plot(100:100:300, hcat([1, 2, 4], [-1,-2,-4]), xtickfontcolor=:white)

```

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [October 25, 2022, 2:51pm UTC](https://discourse.julialang.org/t/removing-numeric-labels-from-axis/89237/3 "2022-10-25T14:51:02Z")

</div>

Another way:

```julia
 plot(1:3, [[1, 2, 4] [-1,-2,-4]], xformatter=_->"")

```

---

<div class="post-metadata">

**Author:** ![t-bltg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/t-bltg/32/25526_2.png) [@t-bltg](https://discourse.julialang.org/u/t-bltg)\
**Post date:** [October 30, 2022, 1:49pm UTC](https://discourse.julialang.org/t/removing-numeric-labels-from-axis/89237/4 "2022-10-30T13:49:45Z")

</div>

Should be fixed by [add `:none` formatter by t-bltg · Pull Request #4483 · JuliaPlots/Plots.jl · GitHub](https://github.com/JuliaPlots/Plots.jl/pull/4483).

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [November 1, 2022, 9:47pm UTC](https://discourse.julialang.org/t/removing-numeric-labels-from-axis/89237/5 "2022-11-01T21:47:53Z")

</div>

@t-bltg, excellent. In which version of Plots.jl will this fix be available so that we can start using it?

---

<div class="post-metadata">

**Author:** ![t-bltg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/t-bltg/32/25526_2.png) [@t-bltg](https://discourse.julialang.org/u/t-bltg)\
**Post date:** [November 1, 2022, 9:57pm UTC](https://discourse.julialang.org/t/removing-numeric-labels-from-axis/89237/6 "2022-11-01T21:57:44Z")

</div>

`1.35.6` or `1.35.7`.

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [November 1, 2022, 10:16pm UTC](https://discourse.julialang.org/t/removing-numeric-labels-from-axis/89237/7 "2022-11-01T22:16:28Z")

</div>

@t-bltg, thanks, it works in v1.35.7 for the above examples with keyword `xformatter = :none`.

However, I can’t get it to work inside a plot recipe together with `ticks := :native`, which is key when zooming linked subplots.

---

<div class="post-metadata">

**Author:** ![t-bltg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/t-bltg/32/25526_2.png) [@t-bltg](https://discourse.julialang.org/u/t-bltg)\
**Post date:** [November 2, 2022, 9:35am UTC](https://discourse.julialang.org/t/removing-numeric-labels-from-axis/89237/8 "2022-11-02T09:35:06Z")

</div>

Hum, can you post a `MRE` ?

Also, on which backend ?

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [November 2, 2022, 10:24am UTC](https://discourse.julialang.org/t/removing-numeric-labels-from-axis/89237/9 "2022-11-02T10:24:19Z")

</div>

@t-bltg, thanks.  
Please find MWE below using the ` pyplot()` backend.

The problem is to have multiple linked subplots, have only one y-scale on the left, be able to zoom-in with ticks = `:native` and keep the y-grid lines synchronized.

Notice how the y-grid lines are out of sync (_the bottom figure is a zoom-in of the top one_):

 ![Plots_pyplot_ticks_native_unzoomed](https://global.discourse-cdn.com/julialang/original/3X/a/7/a78483737b6c8e6841803231cd571dbb66e92b6a.png)

 ![Plots_pyplot_ticks_native_zoomed](https://global.discourse-cdn.com/julialang/original/3X/0/5/05fb66c02b1249921cc41fa0a7629f7cd142c1c4.png)

> **MWE CODE**
>
> ```julia
> using Measures, Plots; pyplot()
> 
> mutable struct MyMatrix
> M::Matrix{Float64}
> end
> 
> @recipe function f(MM::MyMatrix)
> seriestype := :path
> link := :y
> yflip := true
> framestyle := :box
> n = size(MM.M,2)
> layout := (1, n-1)
> for i in 2:n
> @series begin
> ylabel := nothing
> subplot := i-1
> (i==2) && (yaxis := "Y-axes [unit]")
> (i==2) && (ticks := :native)
> (i>2) && (yformatter := :none)
> leftmargin := (i==2) ? 5mm : -15mm 
> MM.M[:,i], MM.M[:,1]
> end
> end
> end
> 
> n = 1000
> x = range(0,20,n)
> MM = MyMatrix(Matrix{Float64}(undef,n,3))
> MM.M[:,1] .= x
> MM.M[:,2] .= sin.(x)
> MM.M[:,3] .= 4*cos.(x)
> plot(MM)
> 
> ```

---

<div class="post-metadata">

**Author:** ![t-bltg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/t-bltg/32/25526_2.png) [@t-bltg](https://discourse.julialang.org/u/t-bltg)\
**Post date:** [November 2, 2022, 10:38am UTC](https://discourse.julialang.org/t/removing-numeric-labels-from-axis/89237/10 "2022-11-02T10:38:11Z")

</div>

Thanks, the issues appears on the first image, the ticks are out of sync.  
This is because we use `get_shared_y_axes().join(...)` in the [`PyPlot` backend](https://github.com/JuliaPlots/Plots.jl/blob/f12da4752966160ce293acffe3bad21fb369c1f6/src/backends/pyplot.jl#L1352).  
It looks like we have to set the ticks manually, as hinted in [python - How to share x axes of two subplots after they have been created - Stack Overflow](https://stackoverflow.com/a/42974975).

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [November 2, 2022, 10:42am UTC](https://discourse.julialang.org/t/removing-numeric-labels-from-axis/89237/11 "2022-11-02T10:42:54Z")

</div>

> [@t-bltg](#):
>
> It looks like we have to set the ticks manually

It won’t work with zoom in and zoom out, will it?

Note that if we keep the y-labels on each linked subplot and use `ticks = :native`, then everything is in-sync, including during zoom-in. But then the plot looks ugly with all the y-labels repeated in all subplots…

EDIT:  
Nevermind, using selective transparency is an effective workaround: `ytickfontcolor = RGBA(0,0,0,0)`

---

<div class="post-metadata">

**Author:** ![t-bltg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/t-bltg/32/25526_2.png) [@t-bltg](https://discourse.julialang.org/u/t-bltg)\
**Post date:** [November 2, 2022, 10:59am UTC](https://discourse.julialang.org/t/removing-numeric-labels-from-axis/89237/12 "2022-11-02T10:59:21Z")

</div>

It looks like using `sharex` or `sharey` allows sync when zooming: `ax != y_ax_link && ax."sharey"(y_ax_link)`, but it makes y ticks labels appear twice …

![sharey](https://global.discourse-cdn.com/julialang/original/3X/2/f/2f7df4f506b0368a6ccc87ed3bad89eafe21cffa.png)

Would this be acceptable ?

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [November 2, 2022, 11:04am UTC](https://discourse.julialang.org/t/removing-numeric-labels-from-axis/89237/13 "2022-11-02T11:04:52Z")

</div>

As indicated in my previous post (edited), good results can be obtained using: ` ytickfontcolor = RGBA(0,0,0,0)`, in addition to `link = :y` and `ticks = :native`. Thank you.
