Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 61b5568e5e | |||
| d337c4edae | |||
| 8db2de64d5 | |||
| 67a2a0f8d7 |
@@ -7,7 +7,7 @@ assignees: ''
|
||||
|
||||
---
|
||||
|
||||
<!-- Please search existing issues to avoid duplicates. -->
|
||||
Please search existing issues to avoid duplicates.
|
||||
|
||||
## Details
|
||||
|
||||
@@ -28,5 +28,5 @@ inspectdr | | |
|
||||
### Versions
|
||||
|
||||
Plots.jl version:
|
||||
Backend version (`]st -m`):
|
||||
Backend version:
|
||||
Output of `versioninfo()`:
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
name = "Plots"
|
||||
uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
|
||||
author = ["Tom Breloff (@tbreloff)"]
|
||||
version = "1.3.2"
|
||||
version = "1.2.4"
|
||||
|
||||
[deps]
|
||||
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
|
||||
|
||||
+2
-6
@@ -190,15 +190,11 @@ function backend(sym::Symbol)
|
||||
end
|
||||
end
|
||||
|
||||
const _deprecated_backends = [:qwt, :winston, :bokeh, :gadfly, :immerse, :glvisualize, :pgfplots]
|
||||
const _deprecated_backends = [:qwt, :winston, :bokeh, :gadfly, :immerse, :glvisualize]
|
||||
|
||||
function warn_on_deprecated_backend(bsym::Symbol)
|
||||
if bsym in _deprecated_backends
|
||||
if bsym == :pgfplots
|
||||
@warn("Backend $bsym has been deprecated. Use pgfplotsx instead.")
|
||||
else
|
||||
@warn("Backend $bsym has been deprecated.")
|
||||
end
|
||||
@warn("Backend $bsym has been deprecated.")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
+166
-168
@@ -781,161 +781,161 @@ function gr_axis_width(sp, axis)
|
||||
end
|
||||
|
||||
function _update_min_padding!(sp::Subplot{GRBackend})
|
||||
dpi = sp.plt[:thickness_scaling]
|
||||
ENV["GKS_ENCODING"] = "utf8"
|
||||
if !haskey(ENV, "GKSwstype")
|
||||
if isijulia()
|
||||
has_user_gkswstype = haskey(ENV, "GKSwstype")
|
||||
withenv("GKSwstype" => 100, "GKS_ENCODING" => "utf8") do
|
||||
dpi = sp.plt[:thickness_scaling]
|
||||
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]
|
||||
rightpad = 2mm + sp[:right_margin]
|
||||
bottompad = 2mm + sp[:bottom_margin]
|
||||
# Add margin for title
|
||||
if sp[:title] != ""
|
||||
gr_set_font(titlefont(sp), sp)
|
||||
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]))
|
||||
# Add margin given by the user
|
||||
leftpad = 2mm + sp[:left_margin]
|
||||
toppad = 2mm + sp[:top_margin]
|
||||
rightpad = 2mm + sp[:right_margin]
|
||||
bottompad = 2mm + sp[:bottom_margin]
|
||||
# Add margin for title
|
||||
if sp[:title] != ""
|
||||
gr_set_font(titlefont(sp), sp)
|
||||
l = last(last(gr_text_size(sp[:title])))
|
||||
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
|
||||
toppad += h
|
||||
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
|
||||
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
|
||||
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
|
||||
# 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
|
||||
if sp[:colorbar_title] != ""
|
||||
rightpad += 4mm
|
||||
end
|
||||
end
|
||||
if sp[:colorbar_title] != ""
|
||||
rightpad += 4mm
|
||||
end
|
||||
sp.minpad = Tuple(dpi * [leftpad, toppad, rightpad, bottompad])
|
||||
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
|
||||
gr_display(plt, $fmt)
|
||||
GR.emergencyclosegks()
|
||||
write(io, read(filepath, String))
|
||||
rm(filepath)
|
||||
if env != "0"
|
||||
ENV["GKSwstype"] = env
|
||||
else
|
||||
pop!(ENV, "GKSwstype")
|
||||
withenv(
|
||||
"GKS_ENCODING" => "utf8",
|
||||
"GKSwstype" => $fmt,
|
||||
"GKS_FILEPATH" => filepath
|
||||
) do
|
||||
gr_display(plt, $fmt)
|
||||
GR.emergencyclosegks()
|
||||
write(io, read(filepath, String))
|
||||
rm(filepath)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1961,16 +1958,17 @@ function _display(plt::Plot{GRBackend})
|
||||
if plt[:display_type] == :inline
|
||||
GR.emergencyclosegks()
|
||||
filepath = tempname() * ".pdf"
|
||||
ENV["GKSwstype"] = "pdf"
|
||||
ENV["GKS_FILEPATH"] = filepath
|
||||
gr_display(plt)
|
||||
GR.emergencyclosegks()
|
||||
content = string("\033]1337;File=inline=1;preserveAspectRatio=0:", base64encode(open(read, filepath)), "\a")
|
||||
println(content)
|
||||
rm(filepath)
|
||||
withenv("GKSwstype" => "pdf", "GKS_FILEPATH" => filepath) do
|
||||
gr_display(plt)
|
||||
GR.emergencyclosegks()
|
||||
content = string("\033]1337;File=inline=1;preserveAspectRatio=0:", base64encode(open(read, filepath)), "\a")
|
||||
println(content)
|
||||
rm(filepath)
|
||||
end
|
||||
else
|
||||
ENV["GKS_DOUBLE_BUF"] = true
|
||||
gr_display(plt)
|
||||
withenv("GKS_DOUBLE_BUF" => true) do
|
||||
gr_display(plt)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
+56
-92
@@ -136,12 +136,17 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
|
||||
bgc_inside = plot_color(sp[:background_color_inside])
|
||||
bgc_inside_a = alpha(bgc_inside)
|
||||
axis_opt = PGFPlotsX.Options(
|
||||
"point meta max" => get_clims(sp)[2],
|
||||
"point meta min" => get_clims(sp)[1],
|
||||
"legend cell align" => "left",
|
||||
"title" => sp[:title],
|
||||
"title style" => PGFPlotsX.Options(
|
||||
pgfx_get_title_pos(title_loc)...,
|
||||
"at" => if title_loc == :left
|
||||
"{(0,1)}"
|
||||
elseif title_loc == :right
|
||||
"{(1,1)}"
|
||||
elseif title_loc isa Tuple
|
||||
"{$(string(title_loc))}"
|
||||
else
|
||||
"{(0.5,1)}"
|
||||
end,
|
||||
"font" => pgfx_font(
|
||||
sp[:titlefontsize],
|
||||
pgfx_thickness_scaling(sp),
|
||||
@@ -179,7 +184,12 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
|
||||
sp_height > 0 * mm ? push!(axis_opt, "height" => string(axis_height)) :
|
||||
nothing
|
||||
# legend position
|
||||
push!(axis_opt["legend style"], pgfx_get_legend_pos(sp[:legend])...)
|
||||
if sp[:legend] isa Tuple
|
||||
x, y = sp[:legend]
|
||||
push!(axis_opt["legend style"], "at={($x, $y)}")
|
||||
else
|
||||
push!(axis_opt["legend style"], pgfx_get_legend_pos(sp[:legend])...)
|
||||
end
|
||||
for letter in (:x, :y, :z)
|
||||
if letter != :z || RecipesPipeline.is3d(sp)
|
||||
pgfx_axis!(axis_opt, sp, letter)
|
||||
@@ -196,48 +206,41 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
|
||||
# As it is likely that all series within the same axis use the same
|
||||
# colormap this should not cause any problem.
|
||||
for series in series_list(sp)
|
||||
if hascolorbar(series)
|
||||
cg = get_colorgradient(series)
|
||||
cm = pgfx_colormap(get_colorgradient(series))
|
||||
PGFPlotsX.push_preamble!(
|
||||
pgfx_plot.the_plot,
|
||||
"""\\pgfplotsset{
|
||||
colormap={plots$(sp.attr[:subplot_index])}{$cm},
|
||||
}""",
|
||||
)
|
||||
push!(axis_opt, "colormap name" => "plots$(sp.attr[:subplot_index])")
|
||||
if cg isa PlotUtils.CategoricalColorGradient
|
||||
if hascolorbar(series)
|
||||
cg = get_colorgradient(series)
|
||||
cm = pgfx_colormap(get_colorgradient(series))
|
||||
PGFPlotsX.push_preamble!(
|
||||
pgfx_plot.the_plot,
|
||||
"""\\pgfplotsset{
|
||||
colormap={plots$(sp.attr[:subplot_index])}{$cm},
|
||||
}""",
|
||||
)
|
||||
push!(
|
||||
axis_opt,
|
||||
"colormap access" => "piecewise const",
|
||||
"colorbar sampled" => nothing,
|
||||
"colorbar" => nothing,
|
||||
"colormap name" => "plots$(sp.attr[:subplot_index])",
|
||||
)
|
||||
if cg isa PlotUtils.CategoricalColorGradient
|
||||
push!(
|
||||
axis_opt,
|
||||
"colormap access" => "piecewise const",
|
||||
"colorbar sampled" => nothing,
|
||||
)
|
||||
end
|
||||
# goto is needed to break out of col and series for
|
||||
@goto colorbar_end
|
||||
end
|
||||
# goto is needed to break out of col and series for
|
||||
@goto colorbar_end
|
||||
end
|
||||
end
|
||||
@label colorbar_end
|
||||
|
||||
if hascolorbar(sp)
|
||||
colorbar_style = PGFPlotsX.Options(
|
||||
push!(
|
||||
axis_opt,
|
||||
"colorbar style" => PGFPlotsX.Options(
|
||||
"title" => sp[:colorbar_title],
|
||||
"xticklabel style" => pgfx_get_ticklabel_style(sp, sp[:xaxis]),
|
||||
"yticklabel style" => pgfx_get_ticklabel_style(sp, sp[:yaxis]),
|
||||
)
|
||||
if sp[:colorbar] === :top
|
||||
push!(colorbar_style,
|
||||
"at" => string((0.5, 1.05)),
|
||||
"anchor" => "south",
|
||||
"xticklabel pos" => "upper",
|
||||
)
|
||||
end
|
||||
push!(
|
||||
axis_opt,
|
||||
string("colorbar", pgfx_get_colorbar_pos(sp[:colorbar])) => nothing,
|
||||
"colorbar style" => colorbar_style,
|
||||
)
|
||||
end
|
||||
),
|
||||
"point meta max" => get_clims(sp)[2],
|
||||
"point meta min" => get_clims(sp)[1],
|
||||
)
|
||||
if RecipesPipeline.is3d(sp)
|
||||
azim, elev = sp[:camera]
|
||||
push!(axis_opt, "view" => (azim, elev))
|
||||
@@ -643,26 +646,6 @@ pgfx_get_marker(k) = get(
|
||||
"*",
|
||||
)
|
||||
|
||||
pgfx_get_xguide_pos(k) = get(
|
||||
(
|
||||
top = "at={(0.5,1)},above,",
|
||||
right = "at={(ticklabel* cs:1.02)}, anchor=west,",
|
||||
left = "at={(ticklabel* cs:-0.02)}, anchor=east,",
|
||||
),
|
||||
k,
|
||||
"at={(ticklabel cs:0.5)}, anchor=near ticklabel"
|
||||
)
|
||||
|
||||
pgfx_get_yguide_pos(k) = get(
|
||||
(
|
||||
top = "at={(ticklabel* cs:1.02)}, anchor=south",
|
||||
right = "at={(1,0.5)},below,",
|
||||
bottom = "at={(ticklabel* cs:-0.02)}, anchor=north,",
|
||||
),
|
||||
k,
|
||||
"at={(ticklabel cs:0.5)}, anchor=near ticklabel"
|
||||
)
|
||||
|
||||
pgfx_get_legend_pos(k) = get(
|
||||
(
|
||||
top = ("at" => string((0.5, 0.98)), "anchor" => "north"),
|
||||
@@ -685,33 +668,6 @@ pgfx_get_legend_pos(k) = get(
|
||||
Symbol(k),
|
||||
("at" => string((1.02, 1)), "anchor" => "north west"),
|
||||
)
|
||||
pgfx_get_legend_pos(t::Tuple) = ("at" => "{$(string(t))}", "anchor" => "north west")
|
||||
pgfx_get_legend_pos(nt::NamedTuple) = ("at" => "{$(string(nt.at))}", "anchor" => string(nt.anchor))
|
||||
|
||||
pgfx_get_colorbar_pos(s) =
|
||||
get((left = " left", bottom = " horizontal", top = " horizontal"), s, "")
|
||||
pgfx_get_colorbar_pos(b::Bool) = ""
|
||||
|
||||
pgfx_get_title_pos(s) =
|
||||
get((
|
||||
left = ("at" => "{(0,1)}", "anchor" => "south west"),
|
||||
right = ("at" => "{(1,1)}", "anchor" => "south east"),
|
||||
), s,
|
||||
("at" => "{(0.5,1)}", "anchor" => "south"))
|
||||
pgfx_get_title_pos(t::Tuple) = ("at" => "{$(string(t))}", "anchor" => "south")
|
||||
pgfx_get_title_pos(nt::NamedTuple) = ("at" => "{$(string(nt.at))}", "anchor" => string(nt.anchor))
|
||||
|
||||
function pgfx_get_ticklabel_style(sp, axis)
|
||||
cstr = plot_color(axis[:tickfontcolor])
|
||||
return PGFPlotsX.Options(
|
||||
"font" => pgfx_font(
|
||||
axis[:tickfontsize], pgfx_thickness_scaling(sp)
|
||||
),
|
||||
"color" => cstr,
|
||||
"draw opacity" => alpha(cstr),
|
||||
"rotate" => axis[:tickfontrotation],
|
||||
)
|
||||
end
|
||||
|
||||
## --------------------------------------------------------------------------------------
|
||||
# Generates a colormap for pgfplots based on a ColorGradient
|
||||
@@ -1053,10 +1009,10 @@ function pgfx_axis!(opt::PGFPlotsX.Options, sp::Subplot, letter)
|
||||
|
||||
# axis label position
|
||||
labelpos = ""
|
||||
if letter == :x
|
||||
labelpos = pgfx_get_xguide_pos(axis[:guide_position])
|
||||
elseif letter == :y
|
||||
labelpos = pgfx_get_yguide_pos(axis[:guide_position])
|
||||
if letter == :x && axis[:guide_position] == :top
|
||||
labelpos = "at={(0.5,1)},above,"
|
||||
elseif letter == :y && axis[:guide_position] == :right
|
||||
labelpos = "at={(1,0.5)},below,"
|
||||
end
|
||||
|
||||
# Add label font
|
||||
@@ -1149,8 +1105,17 @@ function pgfx_axis!(opt::PGFPlotsX.Options, sp::Subplot, letter)
|
||||
string(letter, "tick align") =>
|
||||
(axis[:tick_direction] == :out ? "outside" : "inside"),
|
||||
)
|
||||
cstr = plot_color(axis[:tickfontcolor])
|
||||
α = alpha(cstr)
|
||||
push!(
|
||||
opt, string(letter, "ticklabel style") => pgfx_get_ticklabel_style(sp, axis)
|
||||
opt,
|
||||
string(letter, "ticklabel style") => PGFPlotsX.Options(
|
||||
"font" =>
|
||||
pgfx_font(axis[:tickfontsize], pgfx_thickness_scaling(sp)),
|
||||
"color" => cstr,
|
||||
"draw opacity" => α,
|
||||
"rotate" => axis[:tickfontrotation],
|
||||
),
|
||||
)
|
||||
push!(
|
||||
opt,
|
||||
@@ -1238,7 +1203,6 @@ function pgfx_axis!(opt::PGFPlotsX.Options, sp::Subplot, letter)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
# --------------------------------------------------------------------------------------
|
||||
# display calls this and then _display, its called 3 times for plot(1:5)
|
||||
# Set the (left, top, right, bottom) minimum padding around the plot area
|
||||
|
||||
@@ -336,7 +336,7 @@ function plotly_layout(plt::Plot)
|
||||
plotattributes_out[:hovermode] = "none"
|
||||
end
|
||||
|
||||
plotattributes_out = recursive_merge(plotattributes_out, plt.attr[:extra_plot_kwargs])
|
||||
plotattributes_out
|
||||
end
|
||||
|
||||
function plotly_layout_json(plt::Plot)
|
||||
@@ -810,14 +810,9 @@ html_body(plt::Plot{PlotlyBackend}) = plotly_html_body(plt)
|
||||
const ijulia_initialized = Ref(false)
|
||||
|
||||
function plotly_html_head(plt::Plot)
|
||||
local_file = ("file:///" * plotly_local_file_path)
|
||||
local_file = ("file://" * plotly_local_file_path)
|
||||
plotly =
|
||||
use_local_dependencies[] ? local_file : "https://cdn.plot.ly/plotly-latest.min.js"
|
||||
|
||||
include_mathjax = get(plt[:extra_plot_kwargs], :include_mathjax, "")
|
||||
mathjax_file = include_mathjax != "cdn" ? ("file://" * include_mathjax) : "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML"
|
||||
mathjax_head = include_mathjax == "" ? "" : "<script src=\"$mathjax_file\"></script>\n\t\t"
|
||||
|
||||
if isijulia() && !ijulia_initialized[]
|
||||
# using requirejs seems to be key to load a js depency in IJulia!
|
||||
# https://requirejs.org/docs/start.html
|
||||
@@ -831,7 +826,7 @@ function plotly_html_head(plt::Plot)
|
||||
""")
|
||||
ijulia_initialized[] = true
|
||||
end
|
||||
return "$mathjax_head<script src=$(repr(plotly))></script>"
|
||||
return "<script src=$(repr(plotly))></script>"
|
||||
end
|
||||
|
||||
function plotly_html_body(plt, style = nothing)
|
||||
|
||||
@@ -589,12 +589,6 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
|
||||
push!(handles, handle)
|
||||
else
|
||||
# do a normal scatter plot
|
||||
|
||||
# Add depthshade option for 3d plots
|
||||
if RecipesPipeline.is3d(sp)
|
||||
extrakw[:depthshade] = get(series[:extra_kwargs], :depthshade, false)
|
||||
end
|
||||
|
||||
handle = ax."scatter"(xyargs...;
|
||||
label = series[:label],
|
||||
zorder = series[:series_plotindex] + 0.5,
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ function __init__()
|
||||
end
|
||||
|
||||
@require PGFPlots = "3b7a836e-365b-5785-a47d-02c71176b4aa" begin
|
||||
fn = joinpath(@__DIR__, "backends", "deprecated", "pgfplots.jl")
|
||||
fn = joinpath(@__DIR__, "backends", "pgfplots.jl")
|
||||
include(fn)
|
||||
@require Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" Revise.track(Plots, fn)
|
||||
end
|
||||
|
||||
@@ -302,11 +302,6 @@ Base.convert(::Type{Vector{T}}, rng::AbstractRange{S}) where {T<:Real,S<:Real} =
|
||||
|
||||
Base.merge(a::AbstractVector, b::AbstractVector) = sort(unique(vcat(a,b)))
|
||||
|
||||
# recursively merge kw-dicts, e.g. for merging extra_kwargs / extra_plot_kwargs in plotly)
|
||||
recursive_merge(x::AbstractDict...) = merge(recursive_merge, x...)
|
||||
# if values are not AbstractDicts, take the last definition (as does merge)
|
||||
recursive_merge(x...) = x[end]
|
||||
|
||||
nanpush!(a::AbstractVector, b) = (push!(a, NaN); push!(a, b))
|
||||
nanappend!(a::AbstractVector, b) = (push!(a, NaN); append!(a, b))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user