jw3126 / UnitfulRecipes.jl

Plots.jl recipes for Unitful.jl arrays
MIT License
37 stars 10 forks source link

Square backets #33

Closed KronosTheLate closed 3 years ago

KronosTheLate commented 3 years ago

Is there any reference to why normal brackets () are used to denote the units on the plot axes? I am used to the convension of square backets [], and the only think I found from quick googling is that one should denote e.g. time as time / s, which seems worse to me. Could there potentially be a flag or optional argument one can use to change the default?

briochemc commented 3 years ago

No reference no, the reason was that concentrations are often denoted by square brackets, e.g., [X], so that [X] [mol/m^3] would look uglier IMHO than [X] (mol/m^3).

I don't feel strongly about this or about changing it to square brackets. Not sure what would be the best way to implement it as an option. What do you think @jw3126 ?

FWIW, I mostly use this package for quick figures, where it's useful to see the units quickly, but where the details are not too important. I don't use it for final publication-quality figures, which is when I would pay attention to details like that.

This is the line for reference:

https://github.com/jw3126/UnitfulRecipes.jl/blob/386112f8e652aee20e3eeccb7909bb00988c123c/src/UnitfulRecipes.jl#L166

jw3126 commented 3 years ago

Same thing here. I use this for quick plotting and don't feel too strongly about details like this. There could be a keyword argument, e.g. render_label or render_guide of signature (label::AbstractString, u) -> AbstractString that allows customizing this. We could provide square_brackets, round_brackets functions for convenience.

using UnitfulRecipes: round_brackets, square_brackets
plot(data..., xguide="velocity", render_label=round_brackets) # default
plot(data..., xguide="velocity", render_label=square_brackets)