Compare commits
4 Commits
master
...
as/more_wi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
61b5568e5e | ||
|
|
d337c4edae | ||
|
|
8db2de64d5 | ||
|
|
67a2a0f8d7 |
@ -781,161 +781,161 @@ function gr_axis_width(sp, axis)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function _update_min_padding!(sp::Subplot{GRBackend})
|
function _update_min_padding!(sp::Subplot{GRBackend})
|
||||||
dpi = sp.plt[:thickness_scaling]
|
has_user_gkswstype = haskey(ENV, "GKSwstype")
|
||||||
ENV["GKS_ENCODING"] = "utf8"
|
withenv("GKSwstype" => 100, "GKS_ENCODING" => "utf8") do
|
||||||
if !haskey(ENV, "GKSwstype")
|
dpi = sp.plt[:thickness_scaling]
|
||||||
if isijulia()
|
if has_user_gkswstype && 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]
|
rightpad = 2mm + sp[:right_margin]
|
||||||
rightpad = 2mm + sp[:right_margin]
|
bottompad = 2mm + sp[:bottom_margin]
|
||||||
bottompad = 2mm + sp[:bottom_margin]
|
# Add margin for title
|
||||||
# Add margin for title
|
if sp[:title] != ""
|
||||||
if sp[:title] != ""
|
gr_set_font(titlefont(sp), sp)
|
||||||
gr_set_font(titlefont(sp), sp)
|
l = last(last(gr_text_size(sp[:title])))
|
||||||
l = last(last(gr_text_size(sp[:title])))
|
|
||||||
h = 1mm + get_size(sp)[2] * l * px
|
|
||||||
toppad += h
|
|
||||||
end
|
|
||||||
|
|
||||||
if RecipesPipeline.is3d(sp)
|
|
||||||
xaxis, yaxis, zaxis = sp[:xaxis], sp[:yaxis], sp[:zaxis]
|
|
||||||
xticks, yticks, zticks = get_ticks(sp, xaxis), get_ticks(sp, yaxis), get_ticks(sp, zaxis)
|
|
||||||
# Add margin for x and y ticks
|
|
||||||
h = 0mm
|
|
||||||
if !(xticks in (nothing, false, :none))
|
|
||||||
gr_set_font(
|
|
||||||
tickfont(xaxis),
|
|
||||||
halign = (:left, :hcenter, :right)[sign(xaxis[:rotation]) + 2],
|
|
||||||
valign = (xaxis[:mirror] ? :bottom : :top),
|
|
||||||
rotation = xaxis[:rotation],
|
|
||||||
sp
|
|
||||||
)
|
|
||||||
l = 0.01 + last(gr_get_ticks_size(xticks, xaxis[:rotation]))
|
|
||||||
h = max(h, 1mm + get_size(sp)[2] * l * px)
|
|
||||||
end
|
|
||||||
if !(yticks in (nothing, false, :none))
|
|
||||||
gr_set_font(
|
|
||||||
tickfont(yaxis),
|
|
||||||
halign = (:left, :hcenter, :right)[sign(yaxis[:rotation]) + 2],
|
|
||||||
valign = (yaxis[:mirror] ? :bottom : :top),
|
|
||||||
rotation = yaxis[:rotation],
|
|
||||||
sp
|
|
||||||
)
|
|
||||||
l = 0.01 + last(gr_get_ticks_size(yticks, yaxis[:rotation]))
|
|
||||||
h = max(h, 1mm + get_size(sp)[2] * l * px)
|
|
||||||
end
|
|
||||||
if h > 0mm
|
|
||||||
if xaxis[:mirror] || yaxis[:mirror]
|
|
||||||
toppad += h
|
|
||||||
end
|
|
||||||
if !xaxis[:mirror] || !yaxis[:mirror]
|
|
||||||
bottompad += h
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if !(zticks in (nothing, false, :none))
|
|
||||||
gr_set_font(
|
|
||||||
tickfont(zaxis),
|
|
||||||
halign = (zaxis[:mirror] ? :left : :right),
|
|
||||||
valign = (:top, :vcenter, :bottom)[sign(zaxis[:rotation]) + 2],
|
|
||||||
rotation = zaxis[:rotation],
|
|
||||||
color = zaxis[:tickfontcolor],
|
|
||||||
sp
|
|
||||||
)
|
|
||||||
l = 0.01 + first(gr_get_ticks_size(zticks, zaxis[:rotation]))
|
|
||||||
w = 1mm + get_size(sp)[1] * l * px
|
|
||||||
if zaxis[:mirror]
|
|
||||||
rightpad += w
|
|
||||||
else
|
|
||||||
leftpad += w
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Add margin for x or y label
|
|
||||||
h = 0mm
|
|
||||||
if xaxis[:guide] != ""
|
|
||||||
gr_set_font(guidefont(sp[:xaxis]), sp)
|
|
||||||
l = last(gr_text_size(sp[:xaxis][:guide]))
|
|
||||||
h = max(h, 1mm + get_size(sp)[2] * l * px)
|
|
||||||
end
|
|
||||||
if yaxis[:guide] != ""
|
|
||||||
gr_set_font(guidefont(sp[:yaxis]), sp)
|
|
||||||
l = last(gr_text_size(sp[:yaxis][:guide]))
|
|
||||||
h = max(h, 1mm + get_size(sp)[2] * l * px)
|
|
||||||
end
|
|
||||||
if h > 0mm
|
|
||||||
if xaxis[:guide_position] == :top || (xaxis[:guide_position] == :auto && xaxis[:mirror] == true)
|
|
||||||
toppad += h
|
|
||||||
else
|
|
||||||
bottompad += h
|
|
||||||
end
|
|
||||||
end
|
|
||||||
# Add margin for z label
|
|
||||||
if zaxis[:guide] != ""
|
|
||||||
gr_set_font(guidefont(sp[:zaxis]), sp)
|
|
||||||
l = last(gr_text_size(sp[:zaxis][:guide]))
|
|
||||||
w = 1mm + get_size(sp)[2] * l * px
|
|
||||||
if zaxis[:guide_position] == :right || (zaxis[:guide_position] == :auto && zaxis[:mirror] == true)
|
|
||||||
rightpad += w
|
|
||||||
else
|
|
||||||
leftpad += w
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
# Add margin for x and y ticks
|
|
||||||
xticks, yticks = get_ticks(sp, sp[:xaxis]), get_ticks(sp, sp[:yaxis])
|
|
||||||
if !(xticks in (nothing, false, :none))
|
|
||||||
flip, mirror = gr_set_xticks_font(sp)
|
|
||||||
l = 0.01 + last(gr_get_ticks_size(xticks, sp[:xaxis][:rotation]))
|
|
||||||
h = 1mm + get_size(sp)[2] * l * px
|
h = 1mm + get_size(sp)[2] * l * px
|
||||||
if mirror
|
toppad += h
|
||||||
toppad += h
|
|
||||||
else
|
|
||||||
bottompad += h
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if !(yticks in (nothing, false, :none))
|
|
||||||
flip, mirror = gr_set_yticks_font(sp)
|
|
||||||
l = 0.01 + first(gr_get_ticks_size(yticks, sp[:yaxis][:rotation]))
|
|
||||||
w = 1mm + get_size(sp)[1] * l * px
|
|
||||||
if mirror
|
|
||||||
rightpad += w
|
|
||||||
else
|
|
||||||
leftpad += w
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Add margin for x label
|
if RecipesPipeline.is3d(sp)
|
||||||
if sp[:xaxis][:guide] != ""
|
xaxis, yaxis, zaxis = sp[:xaxis], sp[:yaxis], sp[:zaxis]
|
||||||
gr_set_font(guidefont(sp[:xaxis]), sp)
|
xticks, yticks, zticks = get_ticks(sp, xaxis), get_ticks(sp, yaxis), get_ticks(sp, zaxis)
|
||||||
l = last(gr_text_size(sp[:xaxis][:guide]))
|
# Add margin for x and y ticks
|
||||||
h = 1mm + get_size(sp)[2] * l * px
|
h = 0mm
|
||||||
if sp[:xaxis][:guide_position] == :top || (sp[:xaxis][:guide_position] == :auto && sp[:xaxis][:mirror] == true)
|
if !(xticks in (nothing, false, :none))
|
||||||
toppad += h
|
gr_set_font(
|
||||||
else
|
tickfont(xaxis),
|
||||||
bottompad += h
|
halign = (:left, :hcenter, :right)[sign(xaxis[:rotation]) + 2],
|
||||||
|
valign = (xaxis[:mirror] ? :bottom : :top),
|
||||||
|
rotation = xaxis[:rotation],
|
||||||
|
sp
|
||||||
|
)
|
||||||
|
l = 0.01 + last(gr_get_ticks_size(xticks, xaxis[:rotation]))
|
||||||
|
h = max(h, 1mm + get_size(sp)[2] * l * px)
|
||||||
|
end
|
||||||
|
if !(yticks in (nothing, false, :none))
|
||||||
|
gr_set_font(
|
||||||
|
tickfont(yaxis),
|
||||||
|
halign = (:left, :hcenter, :right)[sign(yaxis[:rotation]) + 2],
|
||||||
|
valign = (yaxis[:mirror] ? :bottom : :top),
|
||||||
|
rotation = yaxis[:rotation],
|
||||||
|
sp
|
||||||
|
)
|
||||||
|
l = 0.01 + last(gr_get_ticks_size(yticks, yaxis[:rotation]))
|
||||||
|
h = max(h, 1mm + get_size(sp)[2] * l * px)
|
||||||
|
end
|
||||||
|
if h > 0mm
|
||||||
|
if xaxis[:mirror] || yaxis[:mirror]
|
||||||
|
toppad += h
|
||||||
|
end
|
||||||
|
if !xaxis[:mirror] || !yaxis[:mirror]
|
||||||
|
bottompad += h
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if !(zticks in (nothing, false, :none))
|
||||||
|
gr_set_font(
|
||||||
|
tickfont(zaxis),
|
||||||
|
halign = (zaxis[:mirror] ? :left : :right),
|
||||||
|
valign = (:top, :vcenter, :bottom)[sign(zaxis[:rotation]) + 2],
|
||||||
|
rotation = zaxis[:rotation],
|
||||||
|
color = zaxis[:tickfontcolor],
|
||||||
|
sp
|
||||||
|
)
|
||||||
|
l = 0.01 + first(gr_get_ticks_size(zticks, zaxis[:rotation]))
|
||||||
|
w = 1mm + get_size(sp)[1] * l * px
|
||||||
|
if zaxis[:mirror]
|
||||||
|
rightpad += w
|
||||||
|
else
|
||||||
|
leftpad += w
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Add margin for x or y label
|
||||||
|
h = 0mm
|
||||||
|
if xaxis[:guide] != ""
|
||||||
|
gr_set_font(guidefont(sp[:xaxis]), sp)
|
||||||
|
l = last(gr_text_size(sp[:xaxis][:guide]))
|
||||||
|
h = max(h, 1mm + get_size(sp)[2] * l * px)
|
||||||
|
end
|
||||||
|
if yaxis[:guide] != ""
|
||||||
|
gr_set_font(guidefont(sp[:yaxis]), sp)
|
||||||
|
l = last(gr_text_size(sp[:yaxis][:guide]))
|
||||||
|
h = max(h, 1mm + get_size(sp)[2] * l * px)
|
||||||
|
end
|
||||||
|
if h > 0mm
|
||||||
|
if xaxis[:guide_position] == :top || (xaxis[:guide_position] == :auto && xaxis[:mirror] == true)
|
||||||
|
toppad += h
|
||||||
|
else
|
||||||
|
bottompad += h
|
||||||
|
end
|
||||||
|
end
|
||||||
|
# Add margin for z label
|
||||||
|
if zaxis[:guide] != ""
|
||||||
|
gr_set_font(guidefont(sp[:zaxis]), sp)
|
||||||
|
l = last(gr_text_size(sp[:zaxis][:guide]))
|
||||||
|
w = 1mm + get_size(sp)[2] * l * px
|
||||||
|
if zaxis[:guide_position] == :right || (zaxis[:guide_position] == :auto && zaxis[:mirror] == true)
|
||||||
|
rightpad += w
|
||||||
|
else
|
||||||
|
leftpad += w
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
# Add margin for x and y ticks
|
||||||
|
xticks, yticks = get_ticks(sp, sp[:xaxis]), get_ticks(sp, sp[:yaxis])
|
||||||
|
if !(xticks in (nothing, false, :none))
|
||||||
|
flip, mirror = gr_set_xticks_font(sp)
|
||||||
|
l = 0.01 + last(gr_get_ticks_size(xticks, sp[:xaxis][:rotation]))
|
||||||
|
h = 1mm + get_size(sp)[2] * l * px
|
||||||
|
if mirror
|
||||||
|
toppad += h
|
||||||
|
else
|
||||||
|
bottompad += h
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if !(yticks in (nothing, false, :none))
|
||||||
|
flip, mirror = gr_set_yticks_font(sp)
|
||||||
|
l = 0.01 + first(gr_get_ticks_size(yticks, sp[:yaxis][:rotation]))
|
||||||
|
w = 1mm + get_size(sp)[1] * l * px
|
||||||
|
if mirror
|
||||||
|
rightpad += w
|
||||||
|
else
|
||||||
|
leftpad += w
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Add margin for x label
|
||||||
|
if sp[:xaxis][:guide] != ""
|
||||||
|
gr_set_font(guidefont(sp[:xaxis]), sp)
|
||||||
|
l = last(gr_text_size(sp[:xaxis][:guide]))
|
||||||
|
h = 1mm + get_size(sp)[2] * l * px
|
||||||
|
if sp[:xaxis][:guide_position] == :top || (sp[:xaxis][:guide_position] == :auto && sp[:xaxis][:mirror] == true)
|
||||||
|
toppad += h
|
||||||
|
else
|
||||||
|
bottompad += h
|
||||||
|
end
|
||||||
|
end
|
||||||
|
# Add margin for y label
|
||||||
|
if sp[:yaxis][:guide] != ""
|
||||||
|
gr_set_font(guidefont(sp[:yaxis]), sp)
|
||||||
|
l = last(gr_text_size(sp[:yaxis][:guide]))
|
||||||
|
w = 1mm + get_size(sp)[2] * l * px
|
||||||
|
if sp[:yaxis][:guide_position] == :right || (sp[:yaxis][:guide_position] == :auto && sp[:yaxis][:mirror] == true)
|
||||||
|
rightpad += w
|
||||||
|
else
|
||||||
|
leftpad += w
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# Add margin for y label
|
if sp[:colorbar_title] != ""
|
||||||
if sp[:yaxis][:guide] != ""
|
rightpad += 4mm
|
||||||
gr_set_font(guidefont(sp[:yaxis]), sp)
|
|
||||||
l = last(gr_text_size(sp[:yaxis][:guide]))
|
|
||||||
w = 1mm + get_size(sp)[2] * l * px
|
|
||||||
if sp[:yaxis][:guide_position] == :right || (sp[:yaxis][:guide_position] == :auto && sp[:yaxis][:mirror] == true)
|
|
||||||
rightpad += w
|
|
||||||
else
|
|
||||||
leftpad += w
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
sp.minpad = Tuple(dpi * [leftpad, toppad, rightpad, bottompad])
|
||||||
if sp[:colorbar_title] != ""
|
end # end withenv
|
||||||
rightpad += 4mm
|
|
||||||
end
|
|
||||||
sp.minpad = Tuple(dpi * [leftpad, toppad, rightpad, bottompad])
|
|
||||||
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,
|
||||||
gr_display(plt, $fmt)
|
"GKS_FILEPATH" => filepath
|
||||||
GR.emergencyclosegks()
|
) do
|
||||||
write(io, read(filepath, String))
|
gr_display(plt, $fmt)
|
||||||
rm(filepath)
|
GR.emergencyclosegks()
|
||||||
if env != "0"
|
write(io, read(filepath, String))
|
||||||
ENV["GKSwstype"] = env
|
rm(filepath)
|
||||||
else
|
|
||||||
pop!(ENV, "GKSwstype")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1961,16 +1958,17 @@ 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
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user