Skip to content

Commit 7ae3b74

Browse files
authored
update GRExt.jl
1 parent 883112b commit 7ae3b74

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

PlotsBase/ext/GRExt.jl

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -851,9 +851,7 @@ gr_set_gradient(series::Series) =
851851

852852
# this is our new display func... set up the viewport_canvas, compute bounding boxes, and display each subplot
853853
function gr_display(plt::Plot, dpi_factor = 1, display = true)
854-
if display
855-
GR.clearws()
856-
end
854+
display && GR.clearws()
857855

858856
# collect some monitor/display sizes in meters and pixels
859857
dsp_width_meters, dsp_height_meters, dsp_width_px, dsp_height_px = GR.inqdspsize()
@@ -880,12 +878,8 @@ function gr_display(plt::Plot, dpi_factor = 1, display = true)
880878
end
881879

882880
if display
883-
# fill in the viewport_canvas background
884-
gr_fill_viewport(vp_canvas, plt[:background_color_outside])
885-
886-
# subplots
887-
foreach(sp -> gr_display(sp, w * px, h * px, vp_canvas), plt.subplots)
888-
881+
gr_fill_viewport(vp_canvas, plt[:background_color_outside]) # fill in the viewport_canvas background
882+
foreach(sp -> gr_display(sp, w * px, h * px, vp_canvas), plt.subplots) # display subplots
889883
GR.updatews()
890884
end
891885
return nothing
@@ -993,15 +987,15 @@ function PlotsBase._update_min_padding!(sp::Subplot{GRBackend})
993987
dpi = sp.plt[:thickness_scaling]
994988
width, height = sp_size = get_size(sp)
995989

996-
# Add margin given by the user
990+
# add margin given by the user
997991
padding = (
998992
left = Ref(2mm + sp[:left_margin]),
999993
top = Ref(2mm + sp[:top_margin]),
1000994
right = Ref(2mm + sp[:right_margin]),
1001995
bottom = Ref(2mm + sp[:bottom_margin]),
1002996
)
1003997

1004-
# Add margin for title
998+
# add margin for title
1005999
if (title = sp[:title]) |> !isempty
10061000
gr_set_font(titlefont(sp), sp)
10071001
l = last(gr_text_size(title))
@@ -1012,7 +1006,7 @@ function PlotsBase._update_min_padding!(sp::Subplot{GRBackend})
10121006
xticks, yticks, zticks = get_ticks.(Ref(sp), axes)
10131007

10141008
if gr_is3d(sp)
1015-
# Add margin for x and y ticks
1009+
# add margin for x and y ticks
10161010
m = 0mm
10171011
for (ax, tc) in ((xaxis, xticks), (yaxis, yticks))
10181012
isempty(first(tc)) && continue
@@ -1043,7 +1037,7 @@ function PlotsBase._update_min_padding!(sp::Subplot{GRBackend})
10431037
padding[zaxis[:mirror] ? :right : :left][] += 1mm + width * l * px
10441038
end
10451039

1046-
# Add margin for x or y label
1040+
# add margin for x or y label
10471041
m = 0mm
10481042
for ax in (xaxis, yaxis)
10491043
(guide = PlotsBase.get_guide(ax)) |> isempty && continue
@@ -1055,7 +1049,7 @@ function PlotsBase._update_min_padding!(sp::Subplot{GRBackend})
10551049
# NOTE: `xaxis` arbitrary here ?
10561050
padding[mirrored(xaxis, :top) ? :top : :bottom][] += m
10571051
end
1058-
# Add margin for z label
1052+
# add margin for z label
10591053
if (guide = PlotsBase.get_guide(zaxis)) |> !isempty
10601054
gr_set_font(guidefont(zaxis), sp)
10611055
l = last(gr_text_size(guide))
@@ -2289,9 +2283,7 @@ for (mime, fmt) in (
22892283
filepath = tempname() * "." * $fmt
22902284
# workaround windows bug github.com/JuliaLang/julia/issues/46989
22912285
touch(filepath)
2292-
withenv(
2293-
"GKS_ENCODING" => "utf8",
2294-
) do
2286+
withenv("GKS_ENCODING" => "utf8") do
22952287
# ensure that the canvas' workstation viewport ist set
22962288
gr_display(plt, dpi_factor, false)
22972289

0 commit comments

Comments
 (0)