fix margin in case there is no label (gr)
This commit is contained in:
parent
e16125cb50
commit
b3b533db94
@ -543,32 +543,36 @@ end
|
|||||||
|
|
||||||
|
|
||||||
function _update_min_padding!(sp::Subplot{GRBackend})
|
function _update_min_padding!(sp::Subplot{GRBackend})
|
||||||
|
# Add margin given by the user
|
||||||
leftpad = 10mm + sp[:left_margin]
|
leftpad = 10mm + sp[:left_margin]
|
||||||
toppad = 2mm + sp[:top_margin]
|
toppad = 2mm + sp[:top_margin]
|
||||||
rightpad = 2mm + sp[:right_margin]
|
rightpad = 4mm + sp[:right_margin]
|
||||||
bottompad = 6mm + sp[:bottom_margin]
|
bottompad = 2mm + sp[:bottom_margin]
|
||||||
|
# Add margin for title
|
||||||
if sp[:title] != ""
|
if sp[:title] != ""
|
||||||
toppad += 5mm
|
toppad += 5mm
|
||||||
end
|
end
|
||||||
if sp[:xaxis][:guide] != ""
|
# Add margin for x ticks
|
||||||
xticks = axis_drawing_info(sp)[1]
|
xticks = axis_drawing_info(sp)[1]
|
||||||
if !(xticks in (nothing, false))
|
if !(xticks in (nothing, false))
|
||||||
gr_set_font(sp[:xaxis][:tickfont],
|
gr_set_font(sp[:xaxis][:tickfont],
|
||||||
halign = (:left, :hcenter, :right)[sign(sp[:xaxis][:rotation]) + 2],
|
halign = (:left, :hcenter, :right)[sign(sp[:xaxis][:rotation]) + 2],
|
||||||
valign = :top,
|
valign = :top,
|
||||||
color = sp[:xaxis][:foreground_color_axis],
|
color = sp[:xaxis][:foreground_color_axis],
|
||||||
rotation = sp[:xaxis][:rotation])
|
rotation = sp[:xaxis][:rotation])
|
||||||
h = 0.0
|
h = 0.0
|
||||||
for (cv, dv) in zip(xticks...)
|
for (cv, dv) in zip(xticks...)
|
||||||
tbx, tby = gr_inqtext(0, 0, string(dv))
|
tbx, tby = gr_inqtext(0, 0, string(dv))
|
||||||
tby_min, tby_max = extrema(tby)
|
tby_min, tby_max = extrema(tby)
|
||||||
h = max(h, tby_max - tby_min)
|
h = max(h, tby_max - tby_min)
|
||||||
end
|
|
||||||
bottompad += 1mm + gr_plot_size[2] * h * px
|
|
||||||
else
|
|
||||||
bottompad += 4mm
|
|
||||||
end
|
end
|
||||||
|
bottompad += 1mm + gr_plot_size[2] * h * px
|
||||||
end
|
end
|
||||||
|
# Add margin for x label
|
||||||
|
if sp[:xaxis][:guide] != ""
|
||||||
|
bottompad += 4mm
|
||||||
|
end
|
||||||
|
# Add margin for y label
|
||||||
if sp[:yaxis][:guide] != ""
|
if sp[:yaxis][:guide] != ""
|
||||||
leftpad += 4mm
|
leftpad += 4mm
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user