Skip to content

Commit d5c64a7

Browse files
committed
Implementation comment
1 parent ffa2f02 commit d5c64a7

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/UnitfulRecipes.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,22 @@ Attribute fixing
129129
function fixaspectratio!(attr, u, axisletter)
130130
aspect_ratio = get!(attr, :aspect_ratio, :auto)
131131
if aspect_ratio in (:auto, :none)
132+
# Keep the default behavior (let Plots figure it out)
132133
return
133134
end
134135
if aspect_ratio === :equal
135136
aspect_ratio = 1
136137
end
138+
#=======================================================================================
139+
Implementation example:
140+
141+
Consider an x axis in `u"m"` and a y axis in `u"s"`, and an `aspect_ratio` in `u"m/s"`.
142+
On the first pass, `axisletter` is `:x`, so `aspect_ratio` is converted to `u"m/s"/u"m"
143+
= u"s^-1"`. On the second pass, `axisletter` is `:y`, so `aspect_ratio` becomes
144+
`u"s^-1"*u"s" = 1`. If at this point `aspect_ratio` is *not* unitless, an error has been
145+
made, and the default aspect ratio fixing of Plots throws a `DimensionError` as it tries
146+
to compare `0 < 1u"m"`.
147+
=======================================================================================#
137148
if axisletter === :y
138149
attr[:aspect_ratio] = aspect_ratio*u
139150
return

0 commit comments

Comments
 (0)