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]:
Lets-Plot Kotlin API v.4.12.0. Frontend: Notebook with dynamically loaded JS. Lets-Plot JS v.4.8.1.
Outputs: Web (HTML+JS), Kotlin Notebook (Swing), Static SVG (hidden)
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]:
2000 2002 2004 2006 2008 2010 2012 2014 2016 6,000 8,000 10,000 12,000 14,000 unemploy date
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]:
2000 2002 2004 2006 2008 2010 2012 2014 2016 6,000 8,000 10,000 12,000 14,000 Ticks directed inward unemploy date
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]:
2000 2002 2004 2006 2008 2010 2012 2014 2016 6,000 8,000 10,000 12,000 14,000 Different tick lengths on each axis unemploy date