Open aplavin opened 4 months ago
I found this in the code: https://github.com/MakieOrg/Makie.jl/blob/e73ea0ea569bf2b1b08061d03e769eb301acdafa/src/dim-converts/unitful-integration.jl#L135-L139 The example is a little wrong, because it hides units for Y and then labels them in X, but this works for your example:
f=Figure()
ax=Axis(f[1,1],
dim1_conversion=Makie.UnitfulConversion(u"m"; units_in_label=false),
xlabel="Distance (m)",
dim2_conversion=Makie.UnitfulConversion(u"W"; units_in_label=false),
ylabel="Power (W)",)
mak = scatter!(ax,(1:5)u"m", (10:10:50)u"W")
Not sure if there is a simpler way. It does retain the units in the axis, so following up with same dimension units works.
mak2 = scatter!(ax, (100:100:500)u"cm", (0.005:0.010:0.045)kW)
Yes, seems like specifying dimconversions manually works, but is very verbose for something wanted in (presumably) the vast majority of cases. Wonder what's the reason for making units a part of ticklabels: are there some fields where such plots are more common than those with units in axislabels?
Maybe something like this is possible, what do you think?
let
fig = Figure()
ax = Axis(fig[1,1], units_in_axislabels="(%s)") # common alternative values are "[%s]" and ", %s"
scatter!(ax, (1:5)u"m", (10:10:50)u"kW")
fig
end
This would put units into axislabels using the provided pattern.
Feature description
I didn't find an option to put units into axis labels instead of tick labels. Is it available anywhere? Maybe that should also be the default? I very rarely see plots with units written at each tick label in practice, the most common way is to put them into axis labels.
For plot types, please add an image of how it should look like
Top: current Unitful support. Bottom: how I'd really like it to look.