Compare commits

...

4 Commits

Author SHA1 Message Date
Anshul Singhvi
61b5568e5e
really fix saving 2020-05-13 18:59:45 +05:30
Anshul Singhvi
d337c4edae
fix saving 2020-05-13 18:44:12 +05:30
Anshul Singhvi
8db2de64d5
forgot a do 2020-05-13 18:17:19 +05:30
Anshul Singhvi
67a2a0f8d7
Update gr.jl 2020-05-13 14:51:37 +05:30

View File

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