How to automatically color Y-axes (lines and tick labels) to match plot colors in Lilaq?

Hi everyone!

I am creating a plot with two Y-axes (left and right) using lilaq:0.6.0. Here is my minimal working example:

#import "@preview/lilaq:0.6.0" as lq

#let tovu = lq.color.map.magma
#let colors = (tovu.at(2), tovu.at(6))

#lq.diagram(
  width: 15cm,
  height: 7cm,
  xlabel: [Time],
  yaxis: none,
  margin: (x: 2%),
  cycle: colors,

  lq.yaxis(
    position: left,
    label: text(fill: tovu.at(2))[Voltage],
    stroke: tovu.at(2),
    lq.plot(
      range(0, 4),
      range(0, 4),
      mark: none,
      stroke: 2pt,
    ),
  ),

  lq.yaxis(
    position: right,
    label: text(fill: tovu.at(6))[Current],
    stroke: tovu.at(6),
    lq.plot(
      range(0, 40),
      range(0, 40),
      mark: none,
      stroke: 2pt,
    ),
  ),
)

I have two questions regarding axis styling:

  1. Is there a way to make an axis (its line, label, and tick numbers) automatically inherit/take the color of its associated plot or the current color from cycle, so I don’t have to specify stroke and fill manually for every axis and label?
  2. What is the recommended way to color the tick numbers (labels) on each Y-axis to match its axis line (stroke)? I tried using show rules with lq.tick-label, but since kind: "y" matches both the left and right axes, it applies the color to both sides simultaneously instead of distinguishing between them.

Thanks in advance for any advice!

1 Like

Hi @Semmens , I think that both are not possible at the moment, unfortunately.

I see the value of this though. I invite you to post a feature request issue on GitHub - lilaq-project/lilaq: Advanced data visualization with Typst. · GitHub to keep me reminded of implementing something along these lines!