Merge pull request #2354 from BeastyBlacksmith/pgfplotsx
@JuliaRegistrator register()
This commit is contained in:
commit
dd70192de4
@ -1,7 +1,7 @@
|
|||||||
name = "Plots"
|
name = "Plots"
|
||||||
uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
|
uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
|
||||||
author = ["Tom Breloff (@tbreloff)"]
|
author = ["Tom Breloff (@tbreloff)"]
|
||||||
version = "0.28.4"
|
version = "0.28.5"
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
|
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
|
||||||
|
|||||||
@ -786,7 +786,6 @@ function processFillArg(plotattributes::KW, arg)
|
|||||||
plotattributes[:fillrange] = arg
|
plotattributes[:fillrange] = arg
|
||||||
|
|
||||||
elseif !handleColors!(plotattributes, arg, :fillcolor)
|
elseif !handleColors!(plotattributes, arg, :fillcolor)
|
||||||
|
|
||||||
plotattributes[:fillrange] = arg
|
plotattributes[:fillrange] = arg
|
||||||
end
|
end
|
||||||
# plotattributes[:fillrange] = fr
|
# plotattributes[:fillrange] = fr
|
||||||
|
|||||||
@ -34,6 +34,7 @@ function pgfx_axes(pgfx_plot::PGFPlotsXPlot)
|
|||||||
return gp isa PGFPlotsX.GroupPlot ? gp.contents : gp
|
return gp isa PGFPlotsX.GroupPlot ? gp.contents : gp
|
||||||
end
|
end
|
||||||
|
|
||||||
|
pgfx_preamble() = pgfx_preamble(current())
|
||||||
function pgfx_preamble(pgfx_plot::Plot{PGFPlotsXBackend})
|
function pgfx_preamble(pgfx_plot::Plot{PGFPlotsXBackend})
|
||||||
old_flag = pgfx_plot.attr[:tex_output_standalone]
|
old_flag = pgfx_plot.attr[:tex_output_standalone]
|
||||||
pgfx_plot.attr[:tex_output_standalone] = true
|
pgfx_plot.attr[:tex_output_standalone] = true
|
||||||
@ -91,8 +92,7 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
|
|||||||
"height" => pl_height > 0 ? string(pl_height * px) : "{}",
|
"height" => pl_height > 0 ? string(pl_height * px) : "{}",
|
||||||
"width" => pl_width > 0 ? string(pl_width * px) : "{}",
|
"width" => pl_width > 0 ? string(pl_width * px) : "{}",
|
||||||
)
|
)
|
||||||
)
|
))
|
||||||
)
|
|
||||||
end
|
end
|
||||||
for sp in plt.subplots
|
for sp in plt.subplots
|
||||||
bb = bbox(sp)
|
bb = bbox(sp)
|
||||||
@ -186,17 +186,22 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
|
|||||||
axis_opt
|
axis_opt
|
||||||
)
|
)
|
||||||
for (series_index, series) in enumerate(series_list(sp))
|
for (series_index, series) in enumerate(series_list(sp))
|
||||||
|
# give each series a uuid for fillbetween
|
||||||
|
series_id = uuid4()
|
||||||
|
_pgfplotsx_series_ids[Symbol("$series_index")] = series_id
|
||||||
opt = series.plotattributes
|
opt = series.plotattributes
|
||||||
st = series[:seriestype]
|
st = series[:seriestype]
|
||||||
|
sf = series[:fillrange]
|
||||||
series_opt = PGFPlotsX.Options(
|
series_opt = PGFPlotsX.Options(
|
||||||
"color" => single_color(opt[:linecolor]),
|
"color" => single_color(opt[:linecolor]),
|
||||||
|
"name path" => string(series_id)
|
||||||
)
|
)
|
||||||
if is3d(series) || st == :heatmap
|
if is3d(series) || st == :heatmap
|
||||||
series_func = PGFPlotsX.Plot3
|
series_func = PGFPlotsX.Plot3
|
||||||
else
|
else
|
||||||
series_func = PGFPlotsX.Plot
|
series_func = PGFPlotsX.Plot
|
||||||
end
|
end
|
||||||
if series[:fillrange] !== nothing && !isfilledcontour(series) && series[:ribbon] === nothing
|
if sf !== nothing && !isfilledcontour(series) && series[:ribbon] === nothing
|
||||||
push!(series_opt, "area legend" => nothing)
|
push!(series_opt, "area legend" => nothing)
|
||||||
end
|
end
|
||||||
if st == :heatmap
|
if st == :heatmap
|
||||||
@ -239,8 +244,10 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
|
|||||||
segment_opt = merge( segment_opt, pgfx_fillstyle(opt, i) )
|
segment_opt = merge( segment_opt, pgfx_fillstyle(opt, i) )
|
||||||
end
|
end
|
||||||
# add fillrange
|
# add fillrange
|
||||||
if series[:fillrange] !== nothing && !isfilledcontour(series) && series[:ribbon] === nothing
|
if sf !== nothing && !isfilledcontour(series) && series[:ribbon] === nothing
|
||||||
pgfx_fillrange_series!( axis, series, series_func, i, _cycle(series[:fillrange], rng), rng)
|
if sf isa Number || sf isa AVec
|
||||||
|
pgfx_fillrange_series!( axis, series, series_func, i, _cycle(sf, rng), rng)
|
||||||
|
end
|
||||||
if i == 1 && opt[:label] != "" && sp[:legend] != :none && should_add_to_legend(series)
|
if i == 1 && opt[:label] != "" && sp[:legend] != :none && should_add_to_legend(series)
|
||||||
pgfx_filllegend!(series_opt, opt)
|
pgfx_filllegend!(series_opt, opt)
|
||||||
end
|
end
|
||||||
@ -253,6 +260,15 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
|
|||||||
coordinates,
|
coordinates,
|
||||||
)
|
)
|
||||||
push!(axis, segment_plot)
|
push!(axis, segment_plot)
|
||||||
|
# fill between functions
|
||||||
|
if sf isa Tuple && series[:ribbon] === nothing
|
||||||
|
sf1, sf2 = sf
|
||||||
|
@assert sf1 == series_index "First index of the tuple has to match the current series index."
|
||||||
|
push!(axis, series_func(
|
||||||
|
merge(pgfx_fillstyle(opt, series_index), PGFPlotsX.Options("forget plot" => nothing)),
|
||||||
|
"fill between [of=$series_id and $(_pgfplotsx_series_ids[Symbol(string(sf2))])]"
|
||||||
|
))
|
||||||
|
end
|
||||||
# add ribbons?
|
# add ribbons?
|
||||||
ribbon = series[:ribbon]
|
ribbon = series[:ribbon]
|
||||||
if ribbon !== nothing
|
if ribbon !== nothing
|
||||||
@ -274,11 +290,14 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
# add subplot annotations
|
# add subplot annotations
|
||||||
anns = sp.attr[:annotations]
|
for ann in sp[:annotations]
|
||||||
for (xi,yi,txt) in anns
|
pgfx_add_annotation!(axis, locate_annotation(sp, ann...)..., pgfx_thickness_scaling(sp))
|
||||||
pgfx_add_annotation!(axis, xi, yi, txt, pgfx_thickness_scaling(sp))
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
# anns = sp.attr[:annotations]
|
||||||
|
# for (xi,yi,txt) in anns
|
||||||
|
# pgfx_add_annotation!(axis, xi, yi, txt, pgfx_thickness_scaling(sp))
|
||||||
|
# end
|
||||||
|
end # for series
|
||||||
if ispolar(sp)
|
if ispolar(sp)
|
||||||
axes = the_plot
|
axes = the_plot
|
||||||
else
|
else
|
||||||
@ -290,9 +309,9 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
|
|||||||
else
|
else
|
||||||
push!(plt.o, the_plot)
|
push!(plt.o, the_plot)
|
||||||
end
|
end
|
||||||
end
|
end # for subplots
|
||||||
pgfx_plot.is_created = true
|
pgfx_plot.is_created = true
|
||||||
end
|
end # if
|
||||||
return pgfx_plot
|
return pgfx_plot
|
||||||
end
|
end
|
||||||
## seriestype specifics
|
## seriestype specifics
|
||||||
@ -438,6 +457,8 @@ const _pgfplotsx_linestyles = KW(
|
|||||||
:dashdotdot => "dashdotdotted",
|
:dashdotdot => "dashdotdotted",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const _pgfplotsx_series_ids = KW()
|
||||||
|
|
||||||
const _pgfplotsx_markers = KW(
|
const _pgfplotsx_markers = KW(
|
||||||
:none => "none",
|
:none => "none",
|
||||||
:cross => "+",
|
:cross => "+",
|
||||||
@ -524,7 +545,7 @@ function pgfx_framestyle(style::Symbol)
|
|||||||
return style
|
return style
|
||||||
else
|
else
|
||||||
default_style = get(_pgfx_framestyle_defaults, style, :axes)
|
default_style = get(_pgfx_framestyle_defaults, style, :axes)
|
||||||
@warn("Framestyle :$style is not (yet) supported by the PGFPlots backend. :$default_style was cosen instead.")
|
@warn("Framestyle :$style is not (yet) supported by the PGFPlotsX backend. :$default_style was cosen instead.")
|
||||||
default_style
|
default_style
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -13,6 +13,7 @@ const DataPoint = Union{MaybeNumber, MaybeString}
|
|||||||
|
|
||||||
prepareSeriesData(x) = error("Cannot convert $(typeof(x)) to series data for plotting")
|
prepareSeriesData(x) = error("Cannot convert $(typeof(x)) to series data for plotting")
|
||||||
prepareSeriesData(::Nothing) = nothing
|
prepareSeriesData(::Nothing) = nothing
|
||||||
|
prepareSeriesData(t::Tuple{T, T}) where {T<:Number} = t
|
||||||
prepareSeriesData(f::Function) = f
|
prepareSeriesData(f::Function) = f
|
||||||
prepareSeriesData(a::AbstractArray{<:MaybeNumber}) = replace!(
|
prepareSeriesData(a::AbstractArray{<:MaybeNumber}) = replace!(
|
||||||
x -> ismissing(x) || isinf(x) ? NaN : x,
|
x -> ismissing(x) || isinf(x) ? NaN : x,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user