Skip to content

Conversation

@theDigitalGuy
Copy link

I wanted something like this

import matplotlib.pyplot as plt
import mpl_typst.as_default

color1="blue"
color2="tab:olive"
sigA = [0, 1, 2, 3, 10]
sigB =[0, -1, -2, -3, -10]

fig, axes = plt.subplots(1,1)
axes.plot(sigA, color=color1)
axes.set_ylabel("Signal A", color=color1)

ax2 = axes.twinx()
ax2.plot(sigB, color=color2)
ax2.set_ylabel("Signal B", color=color2)
fig.savefig("test1.typ")

to produce
image

but the draw_text function in backend.py didn't respect the colors.

This pullrequest should be a simple fix. Not entirely sure how to name the new color variable in the resulting typst file. Chose tcolor for now, to not confuse it with the stroke color (not used yet), but also didn't want do wast more bytes on the additional "ext" of textcolor, but feel free to change that.

If we are add it we could probably also add support for the alpha channel of the text color like backend_pgf.py. I think the typst rgb color function directly supports the alpha value as an additional forth percent value.

@daskol daskol self-assigned this Aug 27, 2025
@daskol daskol self-requested a review August 27, 2025 08:38
@daskol daskol added the enhancement New feature or request label Aug 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants