logo

How to Remove Axis Values in Julia Plots 📂Julia

How to Remove Axis Values in Julia Plots

Overview

In Julia, there are ways to remove color bars, axes, ticks, grids, etc., but these involve graphic elements, so it’s not possible to cleanly remove numbers alone. You must use an option called formatter.

formatter = (_...) -> ""

By giving the option formatter = (_...) -> "" to the plot() function, it’s done.

using Plots

x = rand(10)
y = rand(10)
plot(
    plot(x,y)
    ,plot(x,y, formatter = (_...) -> "")
)

Alt text

In the image above, the left is a plain picture, and the right is a picture with all values removed. Originally, formatter is not just used this way; it has much more functionality. Briefly explained, it applies a given function to the values that should have been displayed in the original image. In the example above, a lambda expression (_...) -> "" is received, and returns an empty string for whatever numerical value comes in, thus removing the axis values1.

xformatter, yformatter

Of course, there are xformatter and yformatter which can be specified for each axis. If you want to remove only the x-axis, pass (_...) -> "" to yformatter, and vice versa for the y-axis.

Environment

  • OS: Windows
  • julia: v1.8.5

foreground_color_text = false

By inputting foreground_color_text = false as a keyword for the plot() function, it’s done. Although it’s a keyword for specifying the color of the tick values (names), entering false results in the values not being output at all.

x_foreground_color_text and y_foreground_color_text can be specified for each axis respectively.

using Plots

plot(
     plot(rand(10)),
     plot(rand(10), foreground_color_text = false)
)

Environment

  • OS: Windows11
  • Version: Julia 1.9.3, Plots v1.39.0