Merge branch 'master' into webio-plotlyjs-integration
This commit is contained in:
commit
ad1216639a
@ -54,7 +54,7 @@ const _3dTypes = [
|
|||||||
:path3d, :scatter3d, :surface, :wireframe, :contour3d, :volume, :mesh3d
|
:path3d, :scatter3d, :surface, :wireframe, :contour3d, :volume, :mesh3d
|
||||||
]
|
]
|
||||||
const _allTypes = vcat([
|
const _allTypes = vcat([
|
||||||
:none, :line, :path, :steppre, :steppost, :sticks, :scatter,
|
:none, :line, :path, :steppre, :stepmid, :steppost, :sticks, :scatter,
|
||||||
:heatmap, :hexbin, :barbins, :barhist, :histogram, :scatterbins,
|
:heatmap, :hexbin, :barbins, :barhist, :histogram, :scatterbins,
|
||||||
:scatterhist, :stepbins, :stephist, :bins2d, :histogram2d, :histogram3d,
|
:scatterhist, :stepbins, :stephist, :bins2d, :histogram2d, :histogram3d,
|
||||||
:density, :bar, :hline, :vline,
|
:density, :bar, :hline, :vline,
|
||||||
@ -101,7 +101,7 @@ const _typeAliases = Dict{Symbol,Symbol}(
|
|||||||
add_non_underscore_aliases!(_typeAliases)
|
add_non_underscore_aliases!(_typeAliases)
|
||||||
|
|
||||||
const _histogram_like = [:histogram, :barhist, :barbins]
|
const _histogram_like = [:histogram, :barhist, :barbins]
|
||||||
const _line_like = [:line, :path, :steppre, :steppost]
|
const _line_like = [:line, :path, :steppre, :stepmid, :steppost]
|
||||||
const _surface_like = [:contour, :contourf, :contour3d, :heatmap, :surface, :wireframe, :image]
|
const _surface_like = [:contour, :contourf, :contour3d, :heatmap, :surface, :wireframe, :image]
|
||||||
|
|
||||||
like_histogram(seriestype::Symbol) = seriestype in _histogram_like
|
like_histogram(seriestype::Symbol) = seriestype in _histogram_like
|
||||||
|
|||||||
@ -441,7 +441,7 @@ function widen(lmin, lmax, scale = :identity)
|
|||||||
end
|
end
|
||||||
|
|
||||||
# figure out if widening is a good idea.
|
# figure out if widening is a good idea.
|
||||||
const _widen_seriestypes = (:line, :path, :steppre, :steppost, :sticks, :scatter, :barbins, :barhist, :histogram, :scatterbins, :scatterhist, :stepbins, :stephist, :bins2d, :histogram2d, :bar, :shape, :path3d, :scatter3d)
|
const _widen_seriestypes = (:line, :path, :steppre, :stepmid, :steppost, :sticks, :scatter, :barbins, :barhist, :histogram, :scatterbins, :scatterhist, :stepbins, :stephist, :bins2d, :histogram2d, :bar, :shape, :path3d, :scatter3d)
|
||||||
|
|
||||||
function default_should_widen(axis::Axis)
|
function default_should_widen(axis::Axis)
|
||||||
should_widen = false
|
should_widen = false
|
||||||
|
|||||||
@ -555,6 +555,7 @@ const _pyplot_attr = merge_with_base_supported([
|
|||||||
const _pyplot_seriestype = [
|
const _pyplot_seriestype = [
|
||||||
:path,
|
:path,
|
||||||
:steppre,
|
:steppre,
|
||||||
|
:stepmid,
|
||||||
:steppost,
|
:steppost,
|
||||||
:shape,
|
:shape,
|
||||||
:straightline,
|
:straightline,
|
||||||
@ -636,6 +637,7 @@ const _hdf5_attr = merge_with_base_supported([
|
|||||||
const _hdf5_seriestype = [
|
const _hdf5_seriestype = [
|
||||||
:path,
|
:path,
|
||||||
:steppre,
|
:steppre,
|
||||||
|
:stepmid,
|
||||||
:steppost,
|
:steppost,
|
||||||
:shape,
|
:shape,
|
||||||
:straightline,
|
:straightline,
|
||||||
@ -707,7 +709,7 @@ const _inspectdr_attr = merge_with_base_supported([
|
|||||||
])
|
])
|
||||||
const _inspectdr_style = [:auto, :solid, :dash, :dot, :dashdot]
|
const _inspectdr_style = [:auto, :solid, :dash, :dot, :dashdot]
|
||||||
const _inspectdr_seriestype = [
|
const _inspectdr_seriestype = [
|
||||||
:path, :scatter, :shape, :straightline, #, :steppre, :steppost
|
:path, :scatter, :shape, :straightline, #, :steppre, :stepmid, :steppost
|
||||||
]
|
]
|
||||||
#see: _allMarkers, _shape_keys
|
#see: _allMarkers, _shape_keys
|
||||||
const _inspectdr_marker = Symbol[
|
const _inspectdr_marker = Symbol[
|
||||||
|
|||||||
@ -571,6 +571,26 @@ end
|
|||||||
gr_view_xcenter(viewport_plotarea) = 0.5 * (viewport_plotarea[1] + viewport_plotarea[2])
|
gr_view_xcenter(viewport_plotarea) = 0.5 * (viewport_plotarea[1] + viewport_plotarea[2])
|
||||||
gr_view_ycenter(viewport_plotarea) = 0.5 * (viewport_plotarea[3] + viewport_plotarea[4])
|
gr_view_ycenter(viewport_plotarea) = 0.5 * (viewport_plotarea[3] + viewport_plotarea[4])
|
||||||
|
|
||||||
|
gr_view_xposition(viewport_plotarea, position) = viewport_plotarea[1] + position * (viewport_plotarea[2] - viewport_plotarea[1])
|
||||||
|
gr_view_yposition(viewport_plotarea, position) = viewport_plotarea[3] + position * (viewport_plotarea[4] - viewport_plotarea[3])
|
||||||
|
|
||||||
|
function position(symb)
|
||||||
|
if symb == :top || symb == :right
|
||||||
|
return 0.95
|
||||||
|
elseif symb == :left || symb == :bottom
|
||||||
|
return 0.05
|
||||||
|
end
|
||||||
|
return 0.5
|
||||||
|
end
|
||||||
|
|
||||||
|
function alignment(symb)
|
||||||
|
if symb == :top || symb == :right
|
||||||
|
return GR.TEXT_HALIGN_RIGHT
|
||||||
|
elseif symb == :left || symb == :bottom
|
||||||
|
return GR.TEXT_HALIGN_LEFT
|
||||||
|
end
|
||||||
|
return GR.TEXT_HALIGN_CENTER
|
||||||
|
end
|
||||||
|
|
||||||
# --------------------------------------------------------------------------------------
|
# --------------------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -1492,21 +1512,29 @@ function gr_label_axis(sp, letter, viewport_plotarea)
|
|||||||
if letter === :y
|
if letter === :y
|
||||||
w = 0.03 + gr_axis_width(sp, axis)
|
w = 0.03 + gr_axis_width(sp, axis)
|
||||||
GR.setcharup(-1, 0)
|
GR.setcharup(-1, 0)
|
||||||
|
#
|
||||||
|
yposition = gr_view_yposition(viewport_plotarea, position(axis[:guidefontvalign]))
|
||||||
|
yalign = alignment(axis[:guidefontvalign])
|
||||||
|
#
|
||||||
if guide_position == :right || (guide_position == :auto && axis[:mirror])
|
if guide_position == :right || (guide_position == :auto && axis[:mirror])
|
||||||
GR.settextalign(GR.TEXT_HALIGN_CENTER, GR.TEXT_VALIGN_BOTTOM)
|
GR.settextalign(yalign, GR.TEXT_VALIGN_BOTTOM)
|
||||||
gr_text(viewport_plotarea[2] + w, gr_view_ycenter(viewport_plotarea), axis[:guide])
|
gr_text(viewport_plotarea[2] + w, yposition, axis[:guide])
|
||||||
else
|
else
|
||||||
GR.settextalign(GR.TEXT_HALIGN_CENTER, GR.TEXT_VALIGN_TOP)
|
GR.settextalign(yalign, GR.TEXT_VALIGN_TOP)
|
||||||
gr_text(viewport_plotarea[1] - w, gr_view_ycenter(viewport_plotarea), axis[:guide])
|
gr_text(viewport_plotarea[1] - w, yposition, axis[:guide])
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
h = 0.015 + gr_axis_height(sp, axis)
|
h = 0.015 + gr_axis_height(sp, axis)
|
||||||
|
#
|
||||||
|
xposition = gr_view_xposition(viewport_plotarea, position(axis[:guidefonthalign]))
|
||||||
|
xalign = alignment(axis[:guidefonthalign])
|
||||||
|
#
|
||||||
if guide_position == :top || (guide_position == :auto && axis[:mirror])
|
if guide_position == :top || (guide_position == :auto && axis[:mirror])
|
||||||
GR.settextalign(GR.TEXT_HALIGN_CENTER, GR.TEXT_VALIGN_TOP)
|
GR.settextalign(xalign, GR.TEXT_VALIGN_TOP)
|
||||||
gr_text(gr_view_xcenter(viewport_plotarea), viewport_plotarea[4] + h, axis[:guide])
|
gr_text(xposition, viewport_plotarea[4] + h, axis[:guide])
|
||||||
else
|
else
|
||||||
GR.settextalign(GR.TEXT_HALIGN_CENTER, GR.TEXT_VALIGN_BOTTOM)
|
GR.settextalign(xalign, GR.TEXT_VALIGN_BOTTOM)
|
||||||
gr_text(gr_view_xcenter(viewport_plotarea), viewport_plotarea[3] - h, axis[:guide])
|
gr_text(xposition, viewport_plotarea[3] - h, axis[:guide])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
GR.restorestate()
|
GR.restorestate()
|
||||||
|
|||||||
@ -17,9 +17,6 @@ Add in functionality to Plots.jl:
|
|||||||
|
|
||||||
is_marker_supported(::InspectDRBackend, shape::Shape) = true
|
is_marker_supported(::InspectDRBackend, shape::Shape) = true
|
||||||
|
|
||||||
_inspectdr_to_pixels(bb::BoundingBox) =
|
|
||||||
InspectDR.BoundingBox(to_pixels(left(bb)), to_pixels(right(bb)), to_pixels(top(bb)), to_pixels(bottom(bb)))
|
|
||||||
|
|
||||||
#Do we avoid Map to avoid possible pre-comile issues?
|
#Do we avoid Map to avoid possible pre-comile issues?
|
||||||
function _inspectdr_mapglyph(s::Symbol)
|
function _inspectdr_mapglyph(s::Symbol)
|
||||||
s == :rect && return :square
|
s == :rect && return :square
|
||||||
@ -290,7 +287,7 @@ For st in :shape:
|
|||||||
color = linecolor, fillcolor = fillcolor
|
color = linecolor, fillcolor = fillcolor
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
elseif st in (:path, :scatter, :straightline) #, :steppre, :steppost)
|
elseif st in (:path, :scatter, :straightline) #, :steppre, :stepmid, :steppost)
|
||||||
#NOTE: In Plots.jl, :scatter plots have 0-linewidths (I think).
|
#NOTE: In Plots.jl, :scatter plots have 0-linewidths (I think).
|
||||||
linewidth = series[:linewidth]
|
linewidth = series[:linewidth]
|
||||||
#More efficient & allows some support for markerstrokewidth:
|
#More efficient & allows some support for markerstrokewidth:
|
||||||
@ -476,11 +473,16 @@ end
|
|||||||
function _update_plot_object(plt::Plot{InspectDRBackend})
|
function _update_plot_object(plt::Plot{InspectDRBackend})
|
||||||
mplot = _inspectdr_getmplot(plt.o)
|
mplot = _inspectdr_getmplot(plt.o)
|
||||||
if nothing == mplot; return; end
|
if nothing == mplot; return; end
|
||||||
|
mplot.bblist = InspectDR.BoundingBox[]
|
||||||
|
|
||||||
for (i, sp) in enumerate(plt.subplots)
|
for (i, sp) in enumerate(plt.subplots)
|
||||||
graphbb = _inspectdr_to_pixels(plotarea(sp))
|
figw, figh = sp.plt[:size]
|
||||||
plot = mplot.subplots[i]
|
pcts = bbox_to_pcts(sp.bbox, figw*px, figh*px)
|
||||||
plot.plotbb = InspectDR.plotbounds(plot.layout.values, graphbb)
|
_left, _bottom, _width, _height = pcts
|
||||||
|
ymax = 1.0-_bottom
|
||||||
|
ymin = ymax - _height
|
||||||
|
bb = InspectDR.BoundingBox(_left, _left+_width, ymin, ymax)
|
||||||
|
push!(mplot.bblist, bb)
|
||||||
end
|
end
|
||||||
|
|
||||||
gplot = _inspectdr_getgui(plt.o)
|
gplot = _inspectdr_getgui(plt.o)
|
||||||
|
|||||||
@ -789,6 +789,8 @@ function plotly_series_segments(series::Series, plotattributes_base::KW, x, y, z
|
|||||||
:width => get_linewidth(series, i),
|
:width => get_linewidth(series, i),
|
||||||
:shape => if st == :steppre
|
:shape => if st == :steppre
|
||||||
"vh"
|
"vh"
|
||||||
|
elseif st == :stepmid
|
||||||
|
"hvh"
|
||||||
elseif st == :steppost
|
elseif st == :steppost
|
||||||
"hv"
|
"hv"
|
||||||
else
|
else
|
||||||
|
|||||||
@ -152,12 +152,14 @@ end
|
|||||||
|
|
||||||
function py_stepstyle(seriestype::Symbol)
|
function py_stepstyle(seriestype::Symbol)
|
||||||
seriestype == :steppost && return "steps-post"
|
seriestype == :steppost && return "steps-post"
|
||||||
|
seriestype == :stepmid && return "steps-mid"
|
||||||
seriestype == :steppre && return "steps-pre"
|
seriestype == :steppre && return "steps-pre"
|
||||||
return "default"
|
return "default"
|
||||||
end
|
end
|
||||||
|
|
||||||
function py_fillstepstyle(seriestype::Symbol)
|
function py_fillstepstyle(seriestype::Symbol)
|
||||||
seriestype == :steppost && return "post"
|
seriestype == :steppost && return "post"
|
||||||
|
seriestype == :stepmid && return "mid"
|
||||||
seriestype == :steppre && return "pre"
|
seriestype == :steppre && return "pre"
|
||||||
return nothing
|
return nothing
|
||||||
end
|
end
|
||||||
@ -206,13 +208,13 @@ function fix_xy_lengths!(plt::Plot{PyPlotBackend}, series::Series)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function py_linecolormap(series::Series)
|
function py_linecolormap(series::Series)
|
||||||
py_colormap(cgrad(get_linecolor(series), alpha=get_linealpha(series)))
|
py_colormap(cgrad(series[:linecolor], alpha=get_linealpha(series)))
|
||||||
end
|
end
|
||||||
function py_markercolormap(series::Series)
|
function py_markercolormap(series::Series)
|
||||||
py_colormap(cgrad(get_markercolor(series), alpha=get_markeralpha(series)))
|
py_colormap(cgrad(series[:markercolor], alpha=get_markeralpha(series)))
|
||||||
end
|
end
|
||||||
function py_fillcolormap(series::Series)
|
function py_fillcolormap(series::Series)
|
||||||
py_colormap(cgrad(get_fillcolor(series), alpha=get_fillalpha(series)))
|
py_colormap(cgrad(series[:fillcolor], alpha=get_fillalpha(series)))
|
||||||
end
|
end
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
@ -408,7 +410,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
|
|||||||
# for each plotting command, optionally build and add a series handle to the list
|
# for each plotting command, optionally build and add a series handle to the list
|
||||||
|
|
||||||
# line plot
|
# line plot
|
||||||
if st in (:path, :path3d, :steppre, :steppost, :straightline)
|
if st in (:path, :path3d, :steppre, :stepmid, :steppost, :straightline)
|
||||||
if maximum(series[:linewidth]) > 0
|
if maximum(series[:linewidth]) > 0
|
||||||
# TODO: check LineCollection alternative for speed
|
# TODO: check LineCollection alternative for speed
|
||||||
# if length(segments) > 1 && (any(typeof(series[attr]) <: AbstractVector for attr in (:fillcolor, :fillalpha)) || series[:fill_z] !== nothing) && !(typeof(series[:linestyle]) <: AbstractVector)
|
# if length(segments) > 1 && (any(typeof(series[attr]) <: AbstractVector for attr in (:fillcolor, :fillalpha)) || series[:fill_z] !== nothing) && !(typeof(series[:linestyle]) <: AbstractVector)
|
||||||
@ -485,7 +487,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
|
|||||||
|
|
||||||
# add markers?
|
# add markers?
|
||||||
if series[:markershape] != :none && st in (
|
if series[:markershape] != :none && st in (
|
||||||
:path, :scatter, :path3d, :scatter3d, :steppre, :steppost, :bar
|
:path, :scatter, :path3d, :scatter3d, :steppre, :stepmid, :steppost, :bar
|
||||||
)
|
)
|
||||||
for segment in series_segments(series, :scatter)
|
for segment in series_segments(series, :scatter)
|
||||||
i, rng = segment.attr_index, segment.range
|
i, rng = segment.attr_index, segment.range
|
||||||
@ -1363,7 +1365,7 @@ function py_add_legend(plt::Plot, sp::Subplot, ax)
|
|||||||
linestyle = py_linestyle(series[:seriestype], get_linestyle(series)),
|
linestyle = py_linestyle(series[:seriestype], get_linestyle(series)),
|
||||||
capstyle = "butt"
|
capstyle = "butt"
|
||||||
)
|
)
|
||||||
elseif series[:seriestype] in (:path, :straightline, :scatter, :steppre, :steppost)
|
elseif series[:seriestype] in (:path, :straightline, :scatter, :steppre, :stepmid, :steppost)
|
||||||
hasline = get_linewidth(series) > 0
|
hasline = get_linewidth(series) > 0
|
||||||
PyPlot.plt."Line2D"((0, 1),(0,0),
|
PyPlot.plt."Line2D"((0, 1),(0,0),
|
||||||
color = py_color(single_color(get_linecolor(series, clims)), get_linealpha(series)),
|
color = py_color(single_color(get_linecolor(series, clims)), get_linealpha(series)),
|
||||||
|
|||||||
@ -1119,6 +1119,25 @@ const _examples = PlotExample[
|
|||||||
quiver(x,y,z, quiver=(u,v,w))
|
quiver(x,y,z, quiver=(u,v,w))
|
||||||
end]
|
end]
|
||||||
),
|
),
|
||||||
|
PlotExample( # 53
|
||||||
|
"Step Types",
|
||||||
|
"A comparison of the various step-like `seriestype`s",
|
||||||
|
[
|
||||||
|
:(
|
||||||
|
begin
|
||||||
|
x = 1:5
|
||||||
|
y = [1, 2, 3, 2, 1]
|
||||||
|
default(shape=:circle)
|
||||||
|
plot(
|
||||||
|
plot(x, y, markershape=:circle, seriestype=:steppre, label="steppre"),
|
||||||
|
plot(x, y, markershape=:circle, seriestype=:stepmid, label="stepmid"),
|
||||||
|
plot(x, y, markershape=:circle, seriestype=:steppost, label="steppost"),
|
||||||
|
layout=(3,1)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
# Some constants for PlotDocs and PlotReferenceImages
|
# Some constants for PlotDocs and PlotReferenceImages
|
||||||
|
|||||||
@ -181,33 +181,37 @@ end
|
|||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# steps
|
# steps
|
||||||
|
|
||||||
make_steps(x, st) = x
|
make_steps(x, st, even) = x
|
||||||
function make_steps(x::AbstractArray, st)
|
function make_steps(x::AbstractArray, st, even)
|
||||||
n = length(x)
|
n = length(x)
|
||||||
n == 0 && return zeros(0)
|
n == 0 && return zeros(0)
|
||||||
newx = zeros(2n - 1)
|
newx = zeros(2n - (even ? 0 : 1))
|
||||||
for i = 1:n
|
newx[1] = x[1]
|
||||||
|
for i = 2:n
|
||||||
idx = 2i - 1
|
idx = 2i - 1
|
||||||
|
if st == :mid
|
||||||
|
newx[idx] = newx[idx-1] = (x[i] + x[i-1]) / 2
|
||||||
|
else
|
||||||
newx[idx] = x[i]
|
newx[idx] = x[i]
|
||||||
if i > 1
|
|
||||||
newx[idx - 1] = x[st == :pre ? i : i - 1]
|
newx[idx - 1] = x[st == :pre ? i : i - 1]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
even && (newx[end] = x[end])
|
||||||
return newx
|
return newx
|
||||||
end
|
end
|
||||||
make_steps(t::Tuple, st) = Tuple(make_steps(ti, st) for ti in t)
|
make_steps(t::Tuple, st, even) = Tuple(make_steps(ti, st, even) for ti in t)
|
||||||
|
|
||||||
|
|
||||||
@nospecialize
|
@nospecialize
|
||||||
|
|
||||||
# create a path from steps
|
# create a path from steps
|
||||||
@recipe function f(::Type{Val{:steppre}}, x, y, z)
|
@recipe function f(::Type{Val{:steppre}}, x, y, z)
|
||||||
plotattributes[:x] = make_steps(x, :post)
|
plotattributes[:x] = make_steps(x, :post, false)
|
||||||
plotattributes[:y] = make_steps(y, :pre)
|
plotattributes[:y] = make_steps(y, :pre, false)
|
||||||
seriestype := :path
|
seriestype := :path
|
||||||
|
|
||||||
# handle fillrange
|
# handle fillrange
|
||||||
plotattributes[:fillrange] = make_steps(plotattributes[:fillrange], :pre)
|
plotattributes[:fillrange] = make_steps(plotattributes[:fillrange], :pre, false)
|
||||||
|
|
||||||
# create a secondary series for the markers
|
# create a secondary series for the markers
|
||||||
if plotattributes[:markershape] != :none
|
if plotattributes[:markershape] != :none
|
||||||
@ -226,13 +230,38 @@ end
|
|||||||
@deps steppre path scatter
|
@deps steppre path scatter
|
||||||
|
|
||||||
# create a path from steps
|
# create a path from steps
|
||||||
@recipe function f(::Type{Val{:steppost}}, x, y, z)
|
@recipe function f(::Type{Val{:stepmid}}, x, y, z)
|
||||||
plotattributes[:x] = make_steps(x, :pre)
|
plotattributes[:x] = make_steps(x, :mid, true)
|
||||||
plotattributes[:y] = make_steps(y, :post)
|
plotattributes[:y] = make_steps(y, :post, true)
|
||||||
seriestype := :path
|
seriestype := :path
|
||||||
|
|
||||||
# handle fillrange
|
# handle fillrange
|
||||||
plotattributes[:fillrange] = make_steps(plotattributes[:fillrange], :post)
|
plotattributes[:fillrange] = make_steps(plotattributes[:fillrange], :post, true)
|
||||||
|
|
||||||
|
# create a secondary series for the markers
|
||||||
|
if plotattributes[:markershape] != :none
|
||||||
|
@series begin
|
||||||
|
seriestype := :scatter
|
||||||
|
x := x
|
||||||
|
y := y
|
||||||
|
label := ""
|
||||||
|
primary := false
|
||||||
|
()
|
||||||
|
end
|
||||||
|
markershape := :none
|
||||||
|
end
|
||||||
|
()
|
||||||
|
end
|
||||||
|
@deps stepmid path scatter
|
||||||
|
|
||||||
|
# create a path from steps
|
||||||
|
@recipe function f(::Type{Val{:steppost}}, x, y, z)
|
||||||
|
plotattributes[:x] = make_steps(x, :pre, false)
|
||||||
|
plotattributes[:y] = make_steps(y, :post, false)
|
||||||
|
seriestype := :path
|
||||||
|
|
||||||
|
# handle fillrange
|
||||||
|
plotattributes[:fillrange] = make_steps(plotattributes[:fillrange], :post, false)
|
||||||
|
|
||||||
# create a secondary series for the markers
|
# create a secondary series for the markers
|
||||||
if plotattributes[:markershape] != :none
|
if plotattributes[:markershape] != :none
|
||||||
|
|||||||
@ -23,7 +23,7 @@ using RecipesBase
|
|||||||
@test isfile(Plots.plotly_local_file_path[])
|
@test isfile(Plots.plotly_local_file_path[])
|
||||||
@test Plots.use_local_dependencies[] = true
|
@test Plots.use_local_dependencies[] = true
|
||||||
@test_nowarn Plots._init_ijulia_plotting()
|
@test_nowarn Plots._init_ijulia_plotting()
|
||||||
end
|
end
|
||||||
Plots.plotly_local_file_path[] = nothing
|
Plots.plotly_local_file_path[] = nothing
|
||||||
Plots.use_local_dependencies[] = temp
|
Plots.use_local_dependencies[] = temp
|
||||||
end # testset
|
end # testset
|
||||||
@ -43,7 +43,7 @@ reference_dir(args...) = joinpath(homedir(), ".julia", "dev", "PlotReferenceImag
|
|||||||
function reference_file(backend, i, version)
|
function reference_file(backend, i, version)
|
||||||
refdir = reference_dir("Plots", string(backend))
|
refdir = reference_dir("Plots", string(backend))
|
||||||
fn = "ref$i.png"
|
fn = "ref$i.png"
|
||||||
versions = sort(VersionNumber.(readdir(refdir)), rev = true)
|
versions = sort(VersionNumber.(readdir(refdir)), rev=true)
|
||||||
|
|
||||||
reffn = joinpath(refdir, string(version), fn)
|
reffn = joinpath(refdir, string(version), fn)
|
||||||
for v in versions
|
for v in versions
|
||||||
@ -107,7 +107,7 @@ const IMG_TOL = VERSION < v"1.4" && Sys.iswindows() ? 1e-1 : is_ci() ? 1e-2 : 1e
|
|||||||
@static if haskey(ENV, "APPVEYOR")
|
@static if haskey(ENV, "APPVEYOR")
|
||||||
@info "Skipping GR image comparison tests on AppVeyor"
|
@info "Skipping GR image comparison tests on AppVeyor"
|
||||||
else
|
else
|
||||||
image_comparison_facts(:gr, tol=IMG_TOL, skip = Plots._backend_skips[:gr])
|
image_comparison_facts(:gr, tol=IMG_TOL, skip=Plots._backend_skips[:gr])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -156,11 +156,11 @@ end
|
|||||||
@test typeof(axis) == Plots.Axis
|
@test typeof(axis) == Plots.Axis
|
||||||
@test Plots.discrete_value!(axis, "HI") == (0.5, 1)
|
@test Plots.discrete_value!(axis, "HI") == (0.5, 1)
|
||||||
@test Plots.discrete_value!(axis, :yo) == (1.5, 2)
|
@test Plots.discrete_value!(axis, :yo) == (1.5, 2)
|
||||||
@test Plots.ignorenan_extrema(axis) == (0.5,1.5)
|
@test Plots.ignorenan_extrema(axis) == (0.5, 1.5)
|
||||||
@test axis[:discrete_map] == Dict{Any,Any}(:yo => 2, "HI" => 1)
|
@test axis[:discrete_map] == Dict{Any,Any}(:yo => 2, "HI" => 1)
|
||||||
|
|
||||||
Plots.discrete_value!(axis, ["x$i" for i=1:5])
|
Plots.discrete_value!(axis, ["x$i" for i = 1:5])
|
||||||
Plots.discrete_value!(axis, ["x$i" for i=0:2])
|
Plots.discrete_value!(axis, ["x$i" for i = 0:2])
|
||||||
@test Plots.ignorenan_extrema(axis) == (0.5, 7.5)
|
@test Plots.ignorenan_extrema(axis) == (0.5, 7.5)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -169,18 +169,27 @@ end
|
|||||||
@test unicodeplots() == Plots.UnicodePlotsBackend()
|
@test unicodeplots() == Plots.UnicodePlotsBackend()
|
||||||
@test backend() == Plots.UnicodePlotsBackend()
|
@test backend() == Plots.UnicodePlotsBackend()
|
||||||
|
|
||||||
|
@testset "Plot" begin
|
||||||
plots = [histogram([1, 0, 0, 0, 0, 0]),
|
plots = [histogram([1, 0, 0, 0, 0, 0]),
|
||||||
plot([missing]),
|
plot([missing]),
|
||||||
plot([missing; 1:4]),
|
plot([missing; 1:4]),
|
||||||
plot([fill(missing,10); 1:4]),
|
plot([fill(missing, 10); 1:4]),
|
||||||
plot([1 1; 1 missing]),
|
plot([1 1; 1 missing]),
|
||||||
plot(["a" "b"; missing "d"], [1 2; 3 4])]
|
plot(["a" "b"; missing "d"], [1 2; 3 4])]
|
||||||
for plt in plots
|
for plt in plots
|
||||||
display(plt)
|
display(plt)
|
||||||
end
|
end
|
||||||
@test_nowarn plot(x->x^2,0,2)
|
@test_nowarn plot(x -> x^2, 0, 2)
|
||||||
|
end
|
||||||
|
|
||||||
|
@testset "Bar" begin
|
||||||
|
p = bar([3,2,1], [1,2,3]);
|
||||||
|
@test isa(p, Plots.Plot)
|
||||||
|
@test isa(display(p), Nothing) == true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@testset "EmptyAnim" begin
|
@testset "EmptyAnim" begin
|
||||||
anim = @animate for i in []
|
anim = @animate for i in []
|
||||||
end
|
end
|
||||||
@ -191,7 +200,7 @@ end
|
|||||||
@testset "NaN-separated Segments" begin
|
@testset "NaN-separated Segments" begin
|
||||||
segments(args...) = collect(iter_segments(args...))
|
segments(args...) = collect(iter_segments(args...))
|
||||||
|
|
||||||
nan10 = fill(NaN,10)
|
nan10 = fill(NaN, 10)
|
||||||
@test segments(11:20) == [1:10]
|
@test segments(11:20) == [1:10]
|
||||||
@test segments([NaN]) == []
|
@test segments([NaN]) == []
|
||||||
@test segments(nan10) == []
|
@test segments(nan10) == []
|
||||||
@ -203,10 +212,10 @@ end
|
|||||||
end
|
end
|
||||||
|
|
||||||
@testset "Utils" begin
|
@testset "Utils" begin
|
||||||
zipped = ([(1,2)], [("a","b")], [(1,"a"),(2,"b")],
|
zipped = ([(1, 2)], [("a", "b")], [(1, "a"),(2, "b")],
|
||||||
[(1,2),(3,4)], [(1,2,3),(3,4,5)], [(1,2,3,4),(3,4,5,6)],
|
[(1, 2),(3, 4)], [(1, 2, 3),(3, 4, 5)], [(1, 2, 3, 4),(3, 4, 5, 6)],
|
||||||
[(1,2.0),(missing,missing)], [(1,missing),(missing,"a")],
|
[(1, 2.0),(missing, missing)], [(1, missing),(missing, "a")],
|
||||||
[(missing,missing)], [(missing,missing,missing),("a","b","c")])
|
[(missing, missing)], [(missing, missing, missing),("a", "b", "c")])
|
||||||
for z in zipped
|
for z in zipped
|
||||||
@test isequal(collect(zip(Plots.unzip(z)...)), z)
|
@test isequal(collect(zip(Plots.unzip(z)...)), z)
|
||||||
@test isequal(collect(zip(Plots.unzip(GeometryBasics.Point.(z))...)), z)
|
@test isequal(collect(zip(Plots.unzip(GeometryBasics.Point.(z))...)), z)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user