Skip to content

Reattach units from MTK #1179

@vchuravy

Description

@vchuravy

[email protected] (released a few days ago) comes with support for DynamicQuantities and axis conversion.

https://docs.makie.org/dev/explanations/dim-converts#Experimental-DynamicQuantities.jl-support
MakieOrg/Makie.jl#5280

This allows one to do something like

    simulation_end = 7us"day"
    tspan = (0, ustrip(1u"s", simulation_end))

    sol = ...
    
    fig = Figure()
    ax = Axis(fig[1, 1]; 
        dim1_conversion=Makie.DQConversion(oneunit(simulation_end), units_in_label = false),
        xlabel="Time ($(dimension(simulation_end)))"
    )
    # plot!(ax, sol) -- when units are reattached
    t = sol.t .* u"s"  # reattach units manually
    lines!(ax, t, sol.u ")

And get a nice, readable plot that has time axis units in days. Now my ModelingToolkit has

@independent_variables t [unit=u"s"]  # time

(as well as units for all other variables)

So it would be fantastic if units would be reattached either generally, or specifically for plotting in Makie.

x-ref: SciML/Catalyst.jl#1341

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions