Axis Tick Direction¶
If the axisTicksLength, axisTicksLengthX, or axisTicksLengthY parameter in theme is set to a negative value, the ticks are drawn inward, pointing toward the plot area.
In [1]:
%useLatestDescriptors
%use dataframe
%use lets-plot
In [2]:
LetsPlot.getInfo()
Out[2]:
In [3]:
import org.jetbrains.kotlinx.dataframe.api.*
import kotlinx.datetime.LocalDate
val url = "https://raw.githubusercontent.com/JetBrains/lets-plot-docs/master/data/economics.csv"
val df = DataFrame.readCSV(url)
val start = LocalDate(2000, 1, 1)
val econ2000 = df.filter { row ->
(row["date"] as LocalDate) >= start
}.toMap()
In [4]:
val pDt = letsPlot(econ2000) { x = "date"; y = "unemploy" } +
geomLine() +
themeClassic() +
theme(panelInset = listOf(0, 10, 0, 0)) +
ggsize(600, 300)
pDt
Out[4]:
In [5]:
// To make the ticks more visible while keeping a compact layout, direct them inward
pDt + theme(axisTicksLength = -8) + ggtitle("Ticks directed inward")
Out[5]:
In [6]:
// Control the tick length separately for each axis
pDt + theme(
axisTicksLengthX = -6,
axisTicksLengthY = 4
) + ggtitle("Different tick lengths on each axis")
Out[6]: