unxts.interop.matplotlib

unxts.interop.matplotlib#

unxts.interop.matplotlib is the canonical location for matplotlib integration. If installed, unxt will automatically detect this and register a converter with matplotlib to enable plotting Quantity objects.

To ensure that a compatible version of matplotlib is installed, you can install unxt with the interop-mpl extra:

uv add "unxt[interop-mpl]"
pip install unxt[interop-mpl]

Once installed, you can plot Quantity objects directly with matplotlib:

import matplotlib.pyplot as plt
import jax.numpy as jnp
import unxt as u

x = u.Q(jnp.linspace(0, 360, 100), "deg")
y = u.Q(jnp.sin(x.ustrip("rad")), "")

plt.plot(x, y)
import quaxed.numpy as jnp

x = u.Q(jnp.linspace(0, 360, 100), "deg")
y = jnp.sin(x)

plt.plot(x, y)

Install: pip install unxts.interop.matplotlib