Layouting (#2486)
* distances very big * better default * respect margins * remove failing example
This commit is contained in:
parent
45569c0d4d
commit
f98b191616
@ -104,14 +104,20 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
|
|||||||
end
|
end
|
||||||
|
|
||||||
for sp in plt.subplots
|
for sp in plt.subplots
|
||||||
bb = bbox(sp)
|
bb1 = sp.plotarea
|
||||||
sp_width = width(bb)
|
bb2 = bbox(sp)
|
||||||
sp_height = height(bb)
|
sp_width = width(bb2)
|
||||||
dx, dy = bb.x0
|
sp_height = height(bb2)
|
||||||
# TODO: does this hold at every scale?
|
dx, dy = bb2.x0
|
||||||
if sp[:legend] in (:outertopright, nothing)
|
lpad = leftpad(sp) + sp[:left_margin]
|
||||||
dx *= 1.2
|
rpad = rightpad(sp) + sp[:right_margin]
|
||||||
end
|
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)
|
||||||
fg_alpha = alpha(plot_color(sp[:foreground_color_legend]))
|
fg_alpha = alpha(plot_color(sp[:foreground_color_legend]))
|
||||||
@ -164,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
|
||||||
@ -1139,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})
|
||||||
|
|||||||
@ -958,6 +958,7 @@ _backend_skips = Dict(
|
|||||||
:pgfplots => [2, 5, 6, 10, 16, 20, 22, 23, 25, 28, 30, 31, 34, 37, 38, 39],
|
:pgfplots => [2, 5, 6, 10, 16, 20, 22, 23, 25, 28, 30, 31, 34, 37, 38, 39],
|
||||||
:pgfplotsx => [ 6, # images
|
:pgfplotsx => [ 6, # images
|
||||||
10, # histogram2d
|
10, # histogram2d
|
||||||
|
16, # pgfplots thinks the upper panel is too small
|
||||||
22, # contourf
|
22, # contourf
|
||||||
23, # pie
|
23, # pie
|
||||||
32, # spy
|
32, # spy
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user