Update gr.jl

This commit is contained in:
Anshul Singhvi 2020-05-13 14:51:37 +05:30 committed by GitHub
parent 238aca6a78
commit 67a2a0f8d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -781,13 +781,12 @@ function gr_axis_width(sp, axis)
end
function _update_min_padding!(sp::Subplot{GRBackend})
has_user_gkswstype = haskey(ENV, "GKSwstype")
withenv("GKSwstype" => 100, "GKS_ENCODING" => "utf8")
dpi = sp.plt[:thickness_scaling]
ENV["GKS_ENCODING"] = "utf8"
if !haskey(ENV, "GKSwstype")
if isijulia()
if has_user_gkswstype && isijulia()
ENV["GKSwstype"] = "svg"
end
end
# Add margin given by the user
leftpad = 2mm + sp[:left_margin]
toppad = 2mm + sp[:top_margin]
@ -936,6 +935,7 @@ function _update_min_padding!(sp::Subplot{GRBackend})
rightpad += 4mm
end
sp.minpad = Tuple(dpi * [leftpad, toppad, rightpad, bottompad])
end # end withenv
end
function is_equally_spaced(v)
@ -1938,20 +1938,17 @@ for (mime, fmt) in (
"image/svg+xml" => "svg",
)
@eval function _show(io::IO, ::MIME{Symbol($mime)}, plt::Plot{GRBackend})
ENV["GKS_ENCODING"] = "utf8"
GR.emergencyclosegks()
filepath = tempname() * "." * $fmt
env = get(ENV, "GKSwstype", "0")
ENV["GKSwstype"] = $fmt
ENV["GKS_FILEPATH"] = filepath
withenv(
"GKS_ENCODING" => "utf8",
"GKSwstype" => get(ENV, "GKSwstype", "0"),
"GKS_FILEPATH" => filepath
) do
gr_display(plt, $fmt)
GR.emergencyclosegks()
write(io, read(filepath, String))
rm(filepath)
if env != "0"
ENV["GKSwstype"] = env
else
pop!(ENV, "GKSwstype")
end
end
end