Conversation
ppinard
left a comment
There was a problem hiding this comment.
I am not sure how to include Angstrom, but it definitely does not belong to the _PREFIXES_FACTORS. Maybe you need a new _Dimension class with Angstrom supported inside. Maybe something like LengthDimension
matplotlib_scalebar/dimension.py
Outdated
| "\u00b5": 1e-6, | ||
| "u": 1e-6, | ||
| "n": 1e-9, | ||
| "A": 1e-10, |
There was a problem hiding this comment.
Angstroms is not a prefix. It should not appear in this list.
There was a problem hiding this comment.
Just wondering how to convert between Angstrom and other units then if not using the _PREFIXES_FACTORS. Create a sperate scaling factors dictionary? and put it a new LengthDimension as the child of _Dimension? Given that except Angstrom all the other units are well covered, so it will be a class with one case only.
matplotlib_scalebar/dimension.py
Outdated
| latexrepr = "Å" # Directly add "Å" without appending "m" | ||
| self.add_units(prefix, factor, latexrepr) | ||
| else: | ||
| self.add_units(prefix + "m", factor, latexrepr) |
There was a problem hiding this comment.
I don't think Angstroms should be part of the default SILengthDimension. Angstrom is not an SI unit. Most users will not want to see Angstrom as a unit when drawing a scale bar.
There was a problem hiding this comment.
Indeed Angstrom is not a SI unit, but it is widely used in electron microscopy community for both imaging and diffaraction (reciprocal Angstrom), which is the initial drive for this PR.
matplotlib_scalebar/dimension.py
Outdated
| latexrepr = _LATEX_MU + "m" | ||
| self.add_units(prefix + "m", factor, latexrepr) | ||
| if prefix == "Å" or prefix == "A" or prefix == "angstrom": | ||
| latexrepr = "Å" # Directly add "Å" without appending "m" |
There was a problem hiding this comment.
The correct LaTeX expression would be \AA
There was a problem hiding this comment.
The correct LaTeX expression would be
\AA
sure, this can be easily done. But sometimes the whole string needs to be in the math format like r"$\AA$" to display correctly, thus I put "Å" directly at the moment.
8d12c8c to
5440f3d
Compare
* Bump CI action versions * Add python 3.12
* Add astronomical length units * add astro-length to README * Fix bugs
…rd#61) * Add a (skippable) check that the axes have equal aspect ratio. When the scalebar is not drawn on an aspect where imshow() has been called (e.g., a point cloud made with plot()), the axes aspect ratio is not automatically set to 1, in which case the scale bar will be wrong (or rather, it will only be correct in the direction (horizontal or vertical) in which it is drawn). To avoid mistakes, add a check for the aspect ratio, emitting a warning when appropriate. The check can be skipped by using new variants for `rotation`: it can now be set to "horizontal-only" ("the scalebar only applies to the horizontal direction") or "vertical-only". (This could also have been a separate kwarg, but something like `check_aspect=False` reads a bit awkwardly to me.) * Try to fix CI --------- Co-authored-by: Philippe Pinard <philippe.pinard@gmail.com>
|
@ppinard please find the class approach of hosting the Å, tried my best to adapt to all the suggestions. |
A minor PR as Å is commonly used in microscopy, would be useful to support it.