respect margins
This commit is contained in:
parent
d6b9a5709f
commit
990ec1370c
@ -106,9 +106,17 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
|
|||||||
for sp in plt.subplots
|
for sp in plt.subplots
|
||||||
bb1 = sp.plotarea
|
bb1 = sp.plotarea
|
||||||
bb2 = bbox(sp)
|
bb2 = bbox(sp)
|
||||||
sp_width = (width(bb1) + width(bb2)) / 2
|
sp_width = width(bb2)
|
||||||
sp_height = (height(bb1) + height(bb2)) / 2
|
sp_height = height(bb2)
|
||||||
dx, dy = bbox(sp).x0
|
dx, dy = bb2.x0
|
||||||
|
lpad = leftpad(sp) + sp[:left_margin]
|
||||||
|
rpad = rightpad(sp) + sp[:right_margin]
|
||||||
|
tpad = toppad(sp) + sp[:top_margin]
|
||||||
|
bpad = bottompad(sp) + sp[:bottom_margin]
|
||||||
|
dx += lpad
|
||||||
|
dy += tpad
|
||||||
|
axis_height = sp_height - (tpad + bpad)
|
||||||
|
axis_width = sp_width - (rpad + lpad)
|
||||||
|
|
||||||
cstr = plot_color(sp[:background_color_legend])
|
cstr = plot_color(sp[:background_color_legend])
|
||||||
a = alpha(cstr)
|
a = alpha(cstr)
|
||||||
@ -162,9 +170,9 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
|
|||||||
"xshift" => string(dx),
|
"xshift" => string(dx),
|
||||||
"yshift" => string(-dy),
|
"yshift" => string(-dy),
|
||||||
)
|
)
|
||||||
sp_width > 0 * mm ? push!(axis_opt, "width" => string(sp_width)) :
|
sp_width > 0 * mm ? push!(axis_opt, "width" => string(axis_width)) :
|
||||||
nothing
|
nothing
|
||||||
sp_height > 0 * mm ? push!(axis_opt, "height" => string(sp_height)) :
|
sp_height > 0 * mm ? push!(axis_opt, "height" => string(axis_height)) :
|
||||||
nothing
|
nothing
|
||||||
# legend position
|
# legend position
|
||||||
if sp[:legend] isa Tuple
|
if sp[:legend] isa Tuple
|
||||||
@ -1137,12 +1145,12 @@ end
|
|||||||
# Set the (left, top, right, bottom) minimum padding around the plot area
|
# Set the (left, top, right, bottom) minimum padding around the plot area
|
||||||
# to fit ticks, tick labels, guides, colorbars, etc.
|
# to fit ticks, tick labels, guides, colorbars, etc.
|
||||||
function _update_min_padding!(sp::Subplot{PGFPlotsXBackend})
|
function _update_min_padding!(sp::Subplot{PGFPlotsXBackend})
|
||||||
# TODO: make padding more intelligent
|
leg = sp[:legend]
|
||||||
# TODO: how to include margins properly?
|
if leg in (:best, :outertopright, :outerright, :outerbottomright) || (leg isa Tuple && leg[1] >= 1)
|
||||||
# sp.minpad = (50mm + sp[:left_margin],
|
sp.minpad = (0mm, 0mm, 5mm, 0mm)
|
||||||
# 0mm + sp[:top_margin],
|
else
|
||||||
# 50mm + sp[:right_margin],
|
sp.minpad = (0mm, 0mm, 0mm, 0mm)
|
||||||
# 0mm + sp[:bottom_margin])
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function _create_backend_figure(plt::Plot{PGFPlotsXBackend})
|
function _create_backend_figure(plt::Plot{PGFPlotsXBackend})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user