fix plotly aspect_ratio and reword arg desc; closes #523
This commit is contained in:
parent
a4c25321d8
commit
04a4357684
@ -85,7 +85,7 @@ const _arg_desc = KW(
|
||||
:grid => "Bool. Show the grid lines?",
|
||||
:annotations => "(x,y,text) tuple(s). Can be a single tuple or a list of them. Text can be String or PlotText (created with `text(args...)`) Add one-off text annotations at the x,y coordinates.",
|
||||
:projection => "Symbol or String. '3d' or 'polar'",
|
||||
:aspect_ratio => "Symbol (:equal) or Number (width to height ratio of plot area).",
|
||||
:aspect_ratio => "Symbol (:equal) or Number. Plot area is resized so that 1 y-unit is the same size as `apect_ratio` x-units.",
|
||||
:margin => "Measure (multiply by `mm`, `px`, etc). Base for individual margins... not directly used. Specifies the extra padding around subplots.",
|
||||
:left_margin => "Measure (multiply by `mm`, `px`, etc) or `:match` (matches `:margin`). Specifies the extra padding to the left of the subplot.",
|
||||
:top_margin => "Measure (multiply by `mm`, `px`, etc) or `:match` (matches `:margin`). Specifies the extra padding on the top of the subplot.",
|
||||
|
||||
@ -162,14 +162,17 @@ function plotly_apply_aspect_ratio(sp::Subplot, plotarea, pcts)
|
||||
if aspect_ratio == :equal
|
||||
aspect_ratio = 1.0
|
||||
end
|
||||
xmin,xmax = axis_limits(sp[:xaxis])
|
||||
ymin,ymax = axis_limits(sp[:yaxis])
|
||||
want_ratio = ((xmax-xmin) / (ymax-ymin)) / aspect_ratio
|
||||
parea_ratio = width(plotarea) / height(plotarea)
|
||||
if aspect_ratio > parea_ratio
|
||||
if want_ratio > parea_ratio
|
||||
# need to shrink y
|
||||
ratio = parea_ratio / aspect_ratio
|
||||
ratio = parea_ratio / want_ratio
|
||||
pcts[2], pcts[4] = shrink_by(pcts[2], pcts[4], ratio)
|
||||
elseif aspect_ratio < parea_ratio
|
||||
elseif want_ratio < parea_ratio
|
||||
# need to shrink x
|
||||
ratio = aspect_ratio / parea_ratio
|
||||
ratio = want_ratio / parea_ratio
|
||||
pcts[1], pcts[3] = shrink_by(pcts[1], pcts[3], ratio)
|
||||
end
|
||||
pcts
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user