Merge pull request #2148 from JuliaPlots/nothing

use === nothing
This commit is contained in:
Christopher Rackauckas 2019-08-20 08:36:04 -04:00 committed by GitHub
commit 648f26f075
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 124 additions and 124 deletions

View File

@ -685,15 +685,15 @@ function processLineArg(plotattributes::KW, arg)
plotattributes[:linestyle] = arg plotattributes[:linestyle] = arg
elseif typeof(arg) <: Stroke elseif typeof(arg) <: Stroke
arg.width == nothing || (plotattributes[:linewidth] = arg.width) arg.width === nothing || (plotattributes[:linewidth] = arg.width)
arg.color == nothing || (plotattributes[:linecolor] = arg.color == :auto ? :auto : plot_color(arg.color)) arg.color === nothing || (plotattributes[:linecolor] = arg.color == :auto ? :auto : plot_color(arg.color))
arg.alpha == nothing || (plotattributes[:linealpha] = arg.alpha) arg.alpha === nothing || (plotattributes[:linealpha] = arg.alpha)
arg.style == nothing || (plotattributes[:linestyle] = arg.style) arg.style === nothing || (plotattributes[:linestyle] = arg.style)
elseif typeof(arg) <: Brush elseif typeof(arg) <: Brush
arg.size == nothing || (plotattributes[:fillrange] = arg.size) arg.size === nothing || (plotattributes[:fillrange] = arg.size)
arg.color == nothing || (plotattributes[:fillcolor] = arg.color == :auto ? :auto : plot_color(arg.color)) arg.color === nothing || (plotattributes[:fillcolor] = arg.color == :auto ? :auto : plot_color(arg.color))
arg.alpha == nothing || (plotattributes[:fillalpha] = arg.alpha) arg.alpha === nothing || (plotattributes[:fillalpha] = arg.alpha)
elseif typeof(arg) <: Arrow || arg in (:arrow, :arrows) elseif typeof(arg) <: Arrow || arg in (:arrow, :arrows)
plotattributes[:arrow] = arg plotattributes[:arrow] = arg
@ -724,15 +724,15 @@ function processMarkerArg(plotattributes::KW, arg)
plotattributes[:markerstrokestyle] = arg plotattributes[:markerstrokestyle] = arg
elseif typeof(arg) <: Stroke elseif typeof(arg) <: Stroke
arg.width == nothing || (plotattributes[:markerstrokewidth] = arg.width) arg.width === nothing || (plotattributes[:markerstrokewidth] = arg.width)
arg.color == nothing || (plotattributes[:markerstrokecolor] = arg.color == :auto ? :auto : plot_color(arg.color)) arg.color === nothing || (plotattributes[:markerstrokecolor] = arg.color == :auto ? :auto : plot_color(arg.color))
arg.alpha == nothing || (plotattributes[:markerstrokealpha] = arg.alpha) arg.alpha === nothing || (plotattributes[:markerstrokealpha] = arg.alpha)
arg.style == nothing || (plotattributes[:markerstrokestyle] = arg.style) arg.style === nothing || (plotattributes[:markerstrokestyle] = arg.style)
elseif typeof(arg) <: Brush elseif typeof(arg) <: Brush
arg.size == nothing || (plotattributes[:markersize] = arg.size) arg.size === nothing || (plotattributes[:markersize] = arg.size)
arg.color == nothing || (plotattributes[:markercolor] = arg.color == :auto ? :auto : plot_color(arg.color)) arg.color === nothing || (plotattributes[:markercolor] = arg.color == :auto ? :auto : plot_color(arg.color))
arg.alpha == nothing || (plotattributes[:markeralpha] = arg.alpha) arg.alpha === nothing || (plotattributes[:markeralpha] = arg.alpha)
# linealpha # linealpha
elseif allAlphas(arg) elseif allAlphas(arg)
@ -757,9 +757,9 @@ end
function processFillArg(plotattributes::KW, arg) function processFillArg(plotattributes::KW, arg)
# fr = get(plotattributes, :fillrange, 0) # fr = get(plotattributes, :fillrange, 0)
if typeof(arg) <: Brush if typeof(arg) <: Brush
arg.size == nothing || (plotattributes[:fillrange] = arg.size) arg.size === nothing || (plotattributes[:fillrange] = arg.size)
arg.color == nothing || (plotattributes[:fillcolor] = arg.color == :auto ? :auto : plot_color(arg.color)) arg.color === nothing || (plotattributes[:fillcolor] = arg.color == :auto ? :auto : plot_color(arg.color))
arg.alpha == nothing || (plotattributes[:fillalpha] = arg.alpha) arg.alpha === nothing || (plotattributes[:fillalpha] = arg.alpha)
elseif typeof(arg) <: Bool elseif typeof(arg) <: Bool
plotattributes[:fillrange] = arg ? 0 : nothing plotattributes[:fillrange] = arg ? 0 : nothing
@ -793,10 +793,10 @@ function processGridArg!(plotattributes::KW, arg, letter)
plotattributes[Symbol(letter, :gridstyle)] = arg plotattributes[Symbol(letter, :gridstyle)] = arg
elseif typeof(arg) <: Stroke elseif typeof(arg) <: Stroke
arg.width == nothing || (plotattributes[Symbol(letter, :gridlinewidth)] = arg.width) arg.width === nothing || (plotattributes[Symbol(letter, :gridlinewidth)] = arg.width)
arg.color == nothing || (plotattributes[Symbol(letter, :foreground_color_grid)] = arg.color in (:auto, :match) ? :match : plot_color(arg.color)) arg.color === nothing || (plotattributes[Symbol(letter, :foreground_color_grid)] = arg.color in (:auto, :match) ? :match : plot_color(arg.color))
arg.alpha == nothing || (plotattributes[Symbol(letter, :gridalpha)] = arg.alpha) arg.alpha === nothing || (plotattributes[Symbol(letter, :gridalpha)] = arg.alpha)
arg.style == nothing || (plotattributes[Symbol(letter, :gridstyle)] = arg.style) arg.style === nothing || (plotattributes[Symbol(letter, :gridstyle)] = arg.style)
# linealpha # linealpha
elseif allAlphas(arg) elseif allAlphas(arg)
@ -822,10 +822,10 @@ function processMinorGridArg!(plotattributes::KW, arg, letter)
plotattributes[Symbol(letter, :minorgrid)] = true plotattributes[Symbol(letter, :minorgrid)] = true
elseif typeof(arg) <: Stroke elseif typeof(arg) <: Stroke
arg.width == nothing || (plotattributes[Symbol(letter, :minorgridlinewidth)] = arg.width) arg.width === nothing || (plotattributes[Symbol(letter, :minorgridlinewidth)] = arg.width)
arg.color == nothing || (plotattributes[Symbol(letter, :foreground_color_minor_grid)] = arg.color in (:auto, :match) ? :match : plot_color(arg.color)) arg.color === nothing || (plotattributes[Symbol(letter, :foreground_color_minor_grid)] = arg.color in (:auto, :match) ? :match : plot_color(arg.color))
arg.alpha == nothing || (plotattributes[Symbol(letter, :minorgridalpha)] = arg.alpha) arg.alpha === nothing || (plotattributes[Symbol(letter, :minorgridalpha)] = arg.alpha)
arg.style == nothing || (plotattributes[Symbol(letter, :minorgridstyle)] = arg.style) arg.style === nothing || (plotattributes[Symbol(letter, :minorgridstyle)] = arg.style)
plotattributes[Symbol(letter, :minorgrid)] = true plotattributes[Symbol(letter, :minorgrid)] = true
# linealpha # linealpha
@ -1121,7 +1121,7 @@ end
function _filter_input_data!(plotattributes::KW) function _filter_input_data!(plotattributes::KW)
idxfilter = pop!(plotattributes, :idxfilter, nothing) idxfilter = pop!(plotattributes, :idxfilter, nothing)
if idxfilter != nothing if idxfilter !== nothing
filter_data!(plotattributes, idxfilter) filter_data!(plotattributes, idxfilter)
end end
end end
@ -1237,7 +1237,7 @@ end
# v = plotattributes[k] # v = plotattributes[k]
# plotattributes[k] = if v == :match # plotattributes[k] = if v == :match
# match_color # match_color
# elseif v == nothing # elseif v === nothing
# plot_color(RGBA(0,0,0,0)) # plot_color(RGBA(0,0,0,0))
# else # else
# v # v
@ -1246,7 +1246,7 @@ end
function color_or_nothing!(plotattributes::KW, k::Symbol) function color_or_nothing!(plotattributes::KW, k::Symbol)
v = plotattributes[k] v = plotattributes[k]
plotattributes[k] = if v == nothing || v == false plotattributes[k] = if v === nothing || v == false
RGBA{Float64}(0,0,0,0) RGBA{Float64}(0,0,0,0)
elseif v != :match elseif v != :match
plot_color(v) plot_color(v)
@ -1563,11 +1563,11 @@ function _update_series_attributes!(plotattributes::KW, plt::Plot, sp::Subplot)
# update alphas # update alphas
for asym in (:linealpha, :markeralpha, :fillalpha) for asym in (:linealpha, :markeralpha, :fillalpha)
if plotattributes[asym] == nothing if plotattributes[asym] === nothing
plotattributes[asym] = plotattributes[:seriesalpha] plotattributes[asym] = plotattributes[:seriesalpha]
end end
end end
if plotattributes[:markerstrokealpha] == nothing if plotattributes[:markerstrokealpha] === nothing
plotattributes[:markerstrokealpha] = plotattributes[:markeralpha] plotattributes[:markerstrokealpha] = plotattributes[:markeralpha]
end end
@ -1602,13 +1602,13 @@ function _update_series_attributes!(plotattributes::KW, plt::Plot, sp::Subplot)
end end
# if marker_z, fill_z or line_z are set, ensure we have a gradient # if marker_z, fill_z or line_z are set, ensure we have a gradient
if plotattributes[:marker_z] != nothing if plotattributes[:marker_z] !== nothing
ensure_gradient!(plotattributes, :markercolor, :markeralpha) ensure_gradient!(plotattributes, :markercolor, :markeralpha)
end end
if plotattributes[:line_z] != nothing if plotattributes[:line_z] !== nothing
ensure_gradient!(plotattributes, :linecolor, :linealpha) ensure_gradient!(plotattributes, :linecolor, :linealpha)
end end
if plotattributes[:fill_z] != nothing if plotattributes[:fill_z] !== nothing
ensure_gradient!(plotattributes, :fillcolor, :fillalpha) ensure_gradient!(plotattributes, :fillcolor, :fillalpha)
end end

View File

@ -67,7 +67,7 @@ function process_axis_arg!(plotattributes::KW, arg, letter = "")
elseif T <: AVec elseif T <: AVec
plotattributes[Symbol(letter,:ticks)] = arg plotattributes[Symbol(letter,:ticks)] = arg
elseif arg == nothing elseif arg === nothing
plotattributes[Symbol(letter,:ticks)] = [] plotattributes[Symbol(letter,:ticks)] = []
elseif T <: Bool || arg in _allShowaxisArgs elseif T <: Bool || arg in _allShowaxisArgs
@ -166,7 +166,7 @@ function optimal_ticks_and_labels(sp::Subplot, axis::Axis, ticks = nothing)
# or DateTime) is chosen based on the time span between amin and amax # or DateTime) is chosen based on the time span between amin and amax
# rather than on the input format # rather than on the input format
# TODO: maybe: non-trivial scale (:ln, :log2, :log10) for date/datetime # TODO: maybe: non-trivial scale (:ln, :log2, :log10) for date/datetime
if ticks == nothing && scale == :identity if ticks === nothing && scale == :identity
if axis[:formatter] == dateformatter if axis[:formatter] == dateformatter
# optimize_datetime_ticks returns ticks and labels(!) based on # optimize_datetime_ticks returns ticks and labels(!) based on
# integers/floats corresponding to the DateTime type. Thus, the axes # integers/floats corresponding to the DateTime type. Thus, the axes
@ -184,7 +184,7 @@ function optimal_ticks_and_labels(sp::Subplot, axis::Axis, ticks = nothing)
end end
# get a list of well-laid-out ticks # get a list of well-laid-out ticks
if ticks == nothing if ticks === nothing
scaled_ticks = optimize_ticks( scaled_ticks = optimize_ticks(
sf(amin), sf(amin),
sf(amax); sf(amax);
@ -382,7 +382,7 @@ function expand_extrema!(sp::Subplot, plotattributes::KW)
data = plotattributes[letter] = Surface(Matrix{Float64}(data.surf)) data = plotattributes[letter] = Surface(Matrix{Float64}(data.surf))
end end
expand_extrema!(axis, data) expand_extrema!(axis, data)
elseif data != nothing elseif data !== nothing
# TODO: need more here... gotta track the discrete reference value # TODO: need more here... gotta track the discrete reference value
# as well as any coord offset (think of boxplot shape coords... they all # as well as any coord offset (think of boxplot shape coords... they all
# correspond to the same x-value) # correspond to the same x-value)
@ -399,10 +399,10 @@ function expand_extrema!(sp::Subplot, plotattributes::KW)
# expand for fillrange # expand for fillrange
fr = plotattributes[:fillrange] fr = plotattributes[:fillrange]
if fr == nothing && plotattributes[:seriestype] == :bar if fr === nothing && plotattributes[:seriestype] == :bar
fr = 0.0 fr = 0.0
end end
if fr != nothing && !all3D(plotattributes) if fr !== nothing && !all3D(plotattributes)
axis = sp.attr[vert ? :yaxis : :xaxis] axis = sp.attr[vert ? :yaxis : :xaxis]
if typeof(fr) <: Tuple if typeof(fr) <: Tuple
for fri in fr for fri in fr
@ -419,7 +419,7 @@ function expand_extrema!(sp::Subplot, plotattributes::KW)
data = plotattributes[dsym] data = plotattributes[dsym]
bw = plotattributes[:bar_width] bw = plotattributes[:bar_width]
if bw == nothing if bw === nothing
bw = plotattributes[:bar_width] = _bar_width * ignorenan_minimum(filter(x->x>0,diff(sort(data)))) bw = plotattributes[:bar_width] = _bar_width * ignorenan_minimum(filter(x->x>0,diff(sort(data))))
end end
axis = sp.attr[Symbol(dsym, :axis)] axis = sp.attr[Symbol(dsym, :axis)]

View File

@ -77,7 +77,7 @@ text_size(lab::AbstractString, sz::Number, rot::Number = 0) = text_size(length(l
# account for the size/length/rotation of tick labels # account for the size/length/rotation of tick labels
function tick_padding(sp::Subplot, axis::Axis) function tick_padding(sp::Subplot, axis::Axis)
ticks = get_ticks(sp, axis) ticks = get_ticks(sp, axis)
if ticks == nothing if ticks === nothing
0mm 0mm
else else
vals, labs = ticks vals, labs = ticks

View File

@ -147,7 +147,7 @@ gr_inqtext(x, y, s::Symbol) = gr_inqtext(x, y, string(s))
function gr_inqtext(x, y, s) function gr_inqtext(x, y, s)
if length(s) >= 2 && s[1] == '$' && s[end] == '$' if length(s) >= 2 && s[1] == '$' && s[end] == '$'
GR.inqmathtex(x, y, s[2:end-1]) GR.inqmathtex(x, y, s[2:end-1])
elseif findfirst(isequal('\\'), s) != nothing || occursin("10^{", s) elseif findfirst(isequal('\\'), s) !== nothing || occursin("10^{", s)
GR.inqtextext(x, y, s) GR.inqtextext(x, y, s)
else else
GR.inqtext(x, y, s) GR.inqtext(x, y, s)
@ -159,7 +159,7 @@ gr_text(x, y, s::Symbol) = gr_text(x, y, string(s))
function gr_text(x, y, s) function gr_text(x, y, s)
if length(s) >= 2 && s[1] == '$' && s[end] == '$' if length(s) >= 2 && s[1] == '$' && s[end] == '$'
GR.mathtex(x, y, s[2:end-1]) GR.mathtex(x, y, s[2:end-1])
elseif findfirst(isequal('\\'), s) != nothing || occursin("10^{", s) elseif findfirst(isequal('\\'), s) !== nothing || occursin("10^{", s)
GR.textext(x, y, s) GR.textext(x, y, s)
else else
GR.text(x, y, s) GR.text(x, y, s)
@ -237,7 +237,7 @@ gr_z_axislims(sp::Subplot) = axis_limits(sp, :z)
gr_xy_axislims(sp::Subplot) = gr_x_axislims(sp)..., gr_y_axislims(sp)... gr_xy_axislims(sp::Subplot) = gr_x_axislims(sp)..., gr_y_axislims(sp)...
function gr_lims(sp::Subplot, axis::Axis, adjust::Bool, expand = nothing) function gr_lims(sp::Subplot, axis::Axis, adjust::Bool, expand = nothing)
if expand != nothing if expand !== nothing
expand_extrema!(axis, expand) expand_extrema!(axis, expand)
end end
lims = axis_limits(sp, axis[:letter]) lims = axis_limits(sp, axis[:letter])
@ -629,11 +629,11 @@ function gr_get_color(series::Series)
series[:fillcolor] series[:fillcolor]
elseif st in (:contour, :wireframe) elseif st in (:contour, :wireframe)
series[:linecolor] series[:linecolor]
elseif series[:marker_z] != nothing elseif series[:marker_z] !== nothing
series[:markercolor] series[:markercolor]
elseif series[:line_z] != nothing elseif series[:line_z] !== nothing
series[:linecolor] series[:linecolor]
elseif series[:fill_z] != nothing elseif series[:fill_z] !== nothing
series[:fillcolor] series[:fillcolor]
end end
end end
@ -880,7 +880,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
GR.selntran(0) GR.selntran(0)
GR.setscale(0) GR.setscale(0)
gr_set_font(legendfont(sp)) gr_set_font(legendfont(sp))
if sp[:legendtitle] != nothing if sp[:legendtitle] !== nothing
tbx, tby = gr_inqtext(0, 0, string(sp[:legendtitle])) tbx, tby = gr_inqtext(0, 0, string(sp[:legendtitle]))
legendw = tbx[3] - tbx[1] legendw = tbx[3] - tbx[1]
legendn += 1 legendn += 1
@ -1247,7 +1247,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
if typeof(z) <: Surface if typeof(z) <: Surface
z = vec(transpose_z(series, z.surf, false)) z = vec(transpose_z(series, z.surf, false))
elseif ispolar(sp) elseif ispolar(sp)
if frng != nothing if frng !== nothing
_, frng = convert_to_polar(x, frng, (rmin, rmax)) _, frng = convert_to_polar(x, frng, (rmin, rmax))
end end
x, y = convert_to_polar(x, y, (rmin, rmax)) x, y = convert_to_polar(x, y, (rmin, rmax))
@ -1258,11 +1258,11 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
end end
if st in (:path, :scatter, :straightline) if st in (:path, :scatter, :straightline)
if x != nothing && length(x) > 1 if x !== nothing && length(x) > 1
lz = series[:line_z] lz = series[:line_z]
segments = iter_segments(series) segments = iter_segments(series)
# do area fill # do area fill
if frng != nothing if frng !== nothing
GR.setfillintstyle(GR.INTSTYLE_SOLID) GR.setfillintstyle(GR.INTSTYLE_SOLID)
fr_from, fr_to = (is_2tuple(frng) ? frng : (y, frng)) fr_from, fr_to = (is_2tuple(frng) ? frng : (y, frng))
for (i, rng) in enumerate(segments) for (i, rng) in enumerate(segments)
@ -1301,7 +1301,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
plot_color(series[:linecolor]) in (black,[black]) plot_color(series[:linecolor]) in (black,[black])
end end
h = gr_contour_levels(series, clims) h = gr_contour_levels(series, clims)
if series[:fillrange] != nothing if series[:fillrange] !== nothing
if series[:fillcolor] != series[:linecolor] && !is_lc_black if series[:fillcolor] != series[:linecolor] && !is_lc_black
@warn("GR: filled contour only supported with black contour lines") @warn("GR: filled contour only supported with black contour lines")
end end
@ -1496,7 +1496,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
gr_set_line(1, :solid, sp[:foreground_color_legend]) gr_set_line(1, :solid, sp[:foreground_color_legend])
GR.drawrect(xpos - 0.08, xpos + w + 0.02, ypos + dy, ypos - dy * n) GR.drawrect(xpos - 0.08, xpos + w + 0.02, ypos + dy, ypos - dy * n)
i = 0 i = 0
if sp[:legendtitle] != nothing if sp[:legendtitle] !== nothing
GR.settextalign(GR.TEXT_HALIGN_CENTER, GR.TEXT_VALIGN_HALF) GR.settextalign(GR.TEXT_HALIGN_CENTER, GR.TEXT_VALIGN_HALF)
gr_set_textcolor(sp[:legendfontcolor]) gr_set_textcolor(sp[:legendfontcolor])
gr_set_transparency(sp[:legendfontcolor]) gr_set_transparency(sp[:legendfontcolor])
@ -1509,7 +1509,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
lc = get_linecolor(series, clims) lc = get_linecolor(series, clims)
gr_set_line(get_linewidth(series), get_linestyle(series), lc) #, series[:linealpha]) gr_set_line(get_linewidth(series), get_linestyle(series), lc) #, series[:linealpha])
if (st == :shape || series[:fillrange] != nothing) && series[:ribbon] == nothing if (st == :shape || series[:fillrange] !== nothing) && series[:ribbon] === nothing
fc = get_fillcolor(series, clims) fc = get_fillcolor(series, clims)
gr_set_fill(fc) #, series[:fillalpha]) gr_set_fill(fc) #, series[:fillalpha])
l, r = xpos-0.07, xpos-0.01 l, r = xpos-0.07, xpos-0.01
@ -1526,7 +1526,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
if st in (:path, :straightline) if st in (:path, :straightline)
gr_set_transparency(lc, get_linealpha(series)) gr_set_transparency(lc, get_linealpha(series))
if series[:fillrange] == nothing || series[:ribbon] != nothing if series[:fillrange] === nothing || series[:ribbon] !== nothing
GR.polyline([xpos - 0.07, xpos - 0.01], [ypos, ypos]) GR.polyline([xpos - 0.07, xpos - 0.01], [ypos, ypos])
else else
GR.polyline([xpos - 0.07, xpos - 0.01], [ypos+0.4dy, ypos+0.4dy]) GR.polyline([xpos - 0.07, xpos - 0.01], [ypos+0.4dy, ypos+0.4dy])

View File

@ -121,9 +121,9 @@ function _create_backend_figure(plt::Plot{InspectDRBackend})
gplot = _inspectdr_getgui(plt.o) gplot = _inspectdr_getgui(plt.o)
#:overwrite_figure: want to reuse current figure #:overwrite_figure: want to reuse current figure
if plt[:overwrite_figure] && mplot != nothing if plt[:overwrite_figure] && mplot !== nothing
mplot.subplots = [] #Reset mplot.subplots = [] #Reset
if gplot != nothing #Ensure still references current plot if gplot !== nothing #Ensure still references current plot
gplot.src = mplot gplot.src = mplot
end end
else #want new one: else #want new one:

View File

@ -96,7 +96,7 @@ pgf_thickness_scaling(series) = pgf_thickness_scaling(series[:subplot])
function pgf_fillstyle(plotattributes, i = 1) function pgf_fillstyle(plotattributes, i = 1)
cstr,a = pgf_color(get_fillcolor(plotattributes, i)) cstr,a = pgf_color(get_fillcolor(plotattributes, i))
fa = get_fillalpha(plotattributes, i) fa = get_fillalpha(plotattributes, i)
if fa != nothing if fa !== nothing
a = fa a = fa
end end
"fill = $cstr, fill opacity=$a" "fill = $cstr, fill opacity=$a"
@ -216,12 +216,12 @@ function pgf_series(sp::Subplot, series::Series)
# add to legend? # add to legend?
if i == 1 && sp[:legend] != :none && should_add_to_legend(series) if i == 1 && sp[:legend] != :none && should_add_to_legend(series)
if plotattributes[:fillrange] != nothing if plotattributes[:fillrange] !== nothing
push!(style, "forget plot") push!(style, "forget plot")
push!(series_collection, pgf_fill_legend_hack(plotattributes, args)) push!(series_collection, pgf_fill_legend_hack(plotattributes, args))
else else
kw[:legendentry] = plotattributes[:label] kw[:legendentry] = plotattributes[:label]
if st == :shape # || plotattributes[:fillrange] != nothing if st == :shape # || plotattributes[:fillrange] !== nothing
push!(style, "area legend") push!(style, "area legend")
end end
end end
@ -238,7 +238,7 @@ function pgf_series(sp::Subplot, series::Series)
kw[:style] = join(style, ',') kw[:style] = join(style, ',')
# add fillrange # add fillrange
if series[:fillrange] != nothing && st != :shape if series[:fillrange] !== nothing && st != :shape
push!(series_collection, pgf_fillrange_series(series, i, _cycle(series[:fillrange], rng), seg_args...)) push!(series_collection, pgf_fillrange_series(series, i, _cycle(series[:fillrange], rng), seg_args...))
end end

View File

@ -403,7 +403,7 @@ end
function plotly_data(series::Series, letter::Symbol, data) function plotly_data(series::Series, letter::Symbol, data)
axis = series[:subplot][Symbol(letter, :axis)] axis = series[:subplot][Symbol(letter, :axis)]
data = if axis[:ticks] == :native && data != nothing data = if axis[:ticks] == :native && data !== nothing
plotly_native_data(axis, data) plotly_native_data(axis, data)
else else
data data
@ -415,7 +415,7 @@ function plotly_data(series::Series, letter::Symbol, data)
plotly_data(data) plotly_data(data)
end end
end end
plotly_data(v) = v != nothing ? collect(v) : v plotly_data(v) = v !== nothing ? collect(v) : v
plotly_data(surf::Surface) = surf.surf plotly_data(surf::Surface) = surf.surf
plotly_data(v::AbstractArray{R}) where {R<:Rational} = float(v) plotly_data(v::AbstractArray{R}) where {R<:Rational} = float(v)
@ -529,7 +529,7 @@ function plotly_series(plt::Plot, series::Series)
else else
plotattributes_out[:colorscale] = plotly_colorscale(series[:fillcolor], series[:fillalpha]) plotattributes_out[:colorscale] = plotly_colorscale(series[:fillcolor], series[:fillalpha])
plotattributes_out[:opacity] = series[:fillalpha] plotattributes_out[:opacity] = series[:fillalpha]
if series[:fill_z] != nothing if series[:fill_z] !== nothing
plotattributes_out[:surfacecolor] = plotly_surface_data(series, series[:fill_z]) plotattributes_out[:surfacecolor] = plotly_surface_data(series, series[:fill_z])
end end
plotattributes_out[:showscale] = hascolorbar(sp) plotattributes_out[:showscale] = hascolorbar(sp)
@ -611,11 +611,11 @@ function plotly_series_shapes(plt::Plot, series::Series, clims)
plotly_hover!(plotattributes_out, _cycle(series[:hover], i)) plotly_hover!(plotattributes_out, _cycle(series[:hover], i))
plotattributes_outs[i] = plotattributes_out plotattributes_outs[i] = plotattributes_out
end end
if series[:fill_z] != nothing if series[:fill_z] !== nothing
push!(plotattributes_outs, plotly_colorbar_hack(series, plotattributes_base, :fill)) push!(plotattributes_outs, plotly_colorbar_hack(series, plotattributes_base, :fill))
elseif series[:line_z] != nothing elseif series[:line_z] !== nothing
push!(plotattributes_outs, plotly_colorbar_hack(series, plotattributes_base, :line)) push!(plotattributes_outs, plotly_colorbar_hack(series, plotattributes_base, :line))
elseif series[:marker_z] != nothing elseif series[:marker_z] !== nothing
push!(plotattributes_outs, plotly_colorbar_hack(series, plotattributes_base, :marker)) push!(plotattributes_outs, plotly_colorbar_hack(series, plotattributes_base, :marker))
end end
plotattributes_outs plotattributes_outs
@ -733,11 +733,11 @@ function plotly_series_segments(series::Series, plotattributes_base::KW, x, y, z
end end
end end
if series[:line_z] != nothing if series[:line_z] !== nothing
push!(plotattributes_outs, plotly_colorbar_hack(series, plotattributes_base, :line)) push!(plotattributes_outs, plotly_colorbar_hack(series, plotattributes_base, :line))
elseif series[:fill_z] != nothing elseif series[:fill_z] !== nothing
push!(plotattributes_outs, plotly_colorbar_hack(series, plotattributes_base, :fill)) push!(plotattributes_outs, plotly_colorbar_hack(series, plotattributes_base, :fill))
elseif series[:marker_z] != nothing elseif series[:marker_z] !== nothing
push!(plotattributes_outs, plotly_colorbar_hack(series, plotattributes_base, :marker)) push!(plotattributes_outs, plotly_colorbar_hack(series, plotattributes_base, :marker))
end end
@ -782,7 +782,7 @@ function plotly_hover!(plotattributes_out::KW, hover)
# hover text # hover text
if hover in (:none, false) if hover in (:none, false)
plotattributes_out[:hoverinfo] = "none" plotattributes_out[:hoverinfo] = "none"
elseif hover != nothing elseif hover !== nothing
plotattributes_out[:hoverinfo] = "text" plotattributes_out[:hoverinfo] = "text"
plotattributes_out[:text] = hover plotattributes_out[:text] = hover
end end
@ -827,7 +827,7 @@ function plotly_html_head(plt::Plot)
end end
function plotly_html_body(plt, style = nothing) function plotly_html_body(plt, style = nothing)
if style == nothing if style === nothing
w, h = plt[:size] w, h = plt[:size]
style = "width:$(w)px;height:$(h)px;" style = "width:$(w)px;height:$(h)px;"
end end

View File

@ -216,7 +216,7 @@ end
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
function fix_xy_lengths!(plt::Plot{PyPlotBackend}, series::Series) function fix_xy_lengths!(plt::Plot{PyPlotBackend}, series::Series)
if series[:x] != nothing if series[:x] !== nothing
x, y = series[:x], series[:y] x, y = series[:x], series[:y]
nx, ny = length(x), length(y) nx, ny = length(x), length(y)
if !isa(get(series.plotattributes, :z, nothing), Surface) && nx != ny if !isa(get(series.plotattributes, :z, nothing), Surface) && nx != ny
@ -434,7 +434,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
if maximum(series[:linewidth]) > 0 if maximum(series[:linewidth]) > 0
segments = iter_segments(series) segments = iter_segments(series)
# 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)
# # multicolored line segments # # multicolored line segments
# n = length(segments) # n = length(segments)
# # segments = Array(Any,n) # # segments = Array(Any,n)
@ -478,7 +478,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
# end # end
a = series[:arrow] a = series[:arrow]
if a != nothing && !is3d(st) # TODO: handle 3d later if a !== nothing && !is3d(st) # TODO: handle 3d later
if typeof(a) != Arrow if typeof(a) != Arrow
@warn("Unexpected type for arrow: $(typeof(a))") @warn("Unexpected type for arrow: $(typeof(a))")
else else
@ -508,7 +508,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
if series[:markershape] != :none && st in (:path, :scatter, :path3d, if series[:markershape] != :none && st in (:path, :scatter, :path3d,
:scatter3d, :steppre, :steppost, :scatter3d, :steppre, :steppost,
:bar) :bar)
markercolor = if any(typeof(series[arg]) <: AVec for arg in (:markercolor, :markeralpha)) || series[:marker_z] != nothing markercolor = if any(typeof(series[arg]) <: AVec for arg in (:markercolor, :markeralpha)) || series[:marker_z] !== nothing
# py_color(plot_color.(get_markercolor.(series, clims, eachindex(x)), get_markeralpha.(series, eachindex(x)))) # py_color(plot_color.(get_markercolor.(series, clims, eachindex(x)), get_markeralpha.(series, eachindex(x))))
[py_color(plot_color(get_markercolor(series, clims, i), get_markeralpha(series, i))) for i in eachindex(x)] [py_color(plot_color(get_markercolor(series, clims, i), get_markeralpha(series, i))) for i in eachindex(x)]
else else
@ -672,7 +672,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
push!(handles, handle) push!(handles, handle)
# contour fills # contour fills
if series[:fillrange] != nothing if series[:fillrange] !== nothing
handle = ax."contourf"(x, y, z, levelargs...; handle = ax."contourf"(x, y, z, levelargs...;
label = series[:label], label = series[:label],
zorder = series[:series_plotindex] + 0.5, zorder = series[:series_plotindex] + 0.5,
@ -691,7 +691,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
end end
z = transpose_z(series, z) z = transpose_z(series, z)
if st == :surface if st == :surface
if series[:fill_z] != nothing if series[:fill_z] !== nothing
# the surface colors are different than z-value # the surface colors are different than z-value
extrakw[:facecolors] = py_shading(series[:fillcolor], transpose_z(series, series[:fill_z].surf)) extrakw[:facecolors] = py_shading(series[:fillcolor], transpose_z(series, series[:fill_z].surf))
extrakw[:shade] = false extrakw[:shade] = false
@ -830,7 +830,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
# handle area filling # handle area filling
fillrange = series[:fillrange] fillrange = series[:fillrange]
if fillrange != nothing && st != :contour if fillrange !== nothing && st != :contour
for (i, rng) in enumerate(iter_segments(series)) for (i, rng) in enumerate(iter_segments(series))
f, dim1, dim2 = if isvertical(series) f, dim1, dim2 = if isvertical(series)
:fill_between, x[rng], y[rng] :fill_between, x[rng], y[rng]
@ -871,7 +871,7 @@ end
function py_set_ticks(ax, ticks, letter) function py_set_ticks(ax, ticks, letter)
ticks == :auto && return ticks == :auto && return
axis = getproperty(ax, Symbol(letter,"axis")) axis = getproperty(ax, Symbol(letter,"axis"))
if ticks == :none || ticks == nothing || ticks == false if ticks == :none || ticks === nothing || ticks == false
kw = KW() kw = KW()
for dir in (:top,:bottom,:left,:right) for dir in (:top,:bottom,:left,:right)
kw[dir] = kw[Symbol(:label,dir)] = false kw[dir] = kw[Symbol(:label,dir)] = false
@ -978,7 +978,7 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend})
# update subplots # update subplots
for sp in plt.subplots for sp in plt.subplots
ax = sp.o ax = sp.o
if ax == nothing if ax === nothing
continue continue
end end
@ -1018,12 +1018,12 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend})
kw[:ticks] = locator kw[:ticks] = locator
kw[:format] = formatter kw[:format] = formatter
kw[:boundaries] = vcat(0, kw[:values] + 0.5) kw[:boundaries] = vcat(0, kw[:values] + 0.5)
elseif any(colorbar_series[attr] != nothing for attr in (:line_z, :fill_z, :marker_z)) elseif any(colorbar_series[attr] !== nothing for attr in (:line_z, :fill_z, :marker_z))
cmin, cmax = get_clims(sp) cmin, cmax = get_clims(sp)
norm = pycolors."Normalize"(vmin = cmin, vmax = cmax) norm = pycolors."Normalize"(vmin = cmin, vmax = cmax)
f = if colorbar_series[:line_z] != nothing f = if colorbar_series[:line_z] !== nothing
py_linecolormap py_linecolormap
elseif colorbar_series[:fill_z] != nothing elseif colorbar_series[:fill_z] !== nothing
py_fillcolormap py_fillcolormap
else else
py_markercolormap py_markercolormap
@ -1186,7 +1186,7 @@ end
# to fit ticks, tick labels, guides, colorbars, etc. # to fit ticks, tick labels, guides, colorbars, etc.
function _update_min_padding!(sp::Subplot{PyPlotBackend}) function _update_min_padding!(sp::Subplot{PyPlotBackend})
ax = sp.o ax = sp.o
ax == nothing && return sp.minpad ax === nothing && return sp.minpad
plotbb = py_bbox(ax) plotbb = py_bbox(ax)
# TODO: this should initialize to the margin from sp.attr # TODO: this should initialize to the margin from sp.attr
@ -1297,7 +1297,7 @@ function py_add_legend(plt::Plot, sp::Subplot, ax)
for series in series_list(sp) for series in series_list(sp)
if should_add_to_legend(series) if should_add_to_legend(series)
# add a line/marker and a label # add a line/marker and a label
push!(handles, if series[:seriestype] == :shape || series[:fillrange] != nothing push!(handles, if series[:seriestype] == :shape || series[:fillrange] !== nothing
pypatches."Patch"( pypatches."Patch"(
edgecolor = py_color(single_color(get_linecolor(series, clims)), get_linealpha(series)), edgecolor = py_color(single_color(get_linecolor(series, clims)), get_linealpha(series)),
facecolor = py_color(single_color(get_fillcolor(series, clims)), get_fillalpha(series)), facecolor = py_color(single_color(get_fillcolor(series, clims)), get_fillalpha(series)),
@ -1335,7 +1335,7 @@ function py_add_legend(plt::Plot, sp::Subplot, ax)
frame = leg."get_frame"() frame = leg."get_frame"()
frame."set_linewidth"(py_thickness_scale(plt, 1)) frame."set_linewidth"(py_thickness_scale(plt, 1))
leg."set_zorder"(1000) leg."set_zorder"(1000)
sp[:legendtitle] != nothing && leg."set_title"(sp[:legendtitle]) sp[:legendtitle] !== nothing && leg."set_title"(sp[:legendtitle])
for txt in leg."get_texts"() for txt in leg."get_texts"()
PyPlot.plt."setp"(txt, color = py_color(sp[:legendfontcolor]), family = sp[:legendfontfamily]) PyPlot.plt."setp"(txt, color = py_color(sp[:legendfontcolor]), family = sp[:legendfontfamily])
@ -1352,7 +1352,7 @@ end
function _update_plot_object(plt::Plot{PyPlotBackend}) function _update_plot_object(plt::Plot{PyPlotBackend})
for sp in plt.subplots for sp in plt.subplots
ax = sp.o ax = sp.o
ax == nothing && return ax === nothing && return
figw, figh = sp.plt[:size] figw, figh = sp.plt[:size]
figw, figh = figw*px, figh*px figw, figh = figw*px, figh*px
pcts = bbox_to_pcts(sp.plotarea, figw, figh) pcts = bbox_to_pcts(sp.plotarea, figw, figh)

View File

@ -529,7 +529,7 @@ function series_annotations_shapes!(series::Series, scaletype::Symbol = :pixels)
# end # end
# @show msw msh # @show msw msh
if anns != nothing && anns.baseshape != nothing if anns !== nothing && anns.baseshape !== nothing
# we use baseshape to overwrite the markershape attribute # we use baseshape to overwrite the markershape attribute
# with a list of custom shapes for each # with a list of custom shapes for each
msw,msh = anns.scalefactor msw,msh = anns.scalefactor
@ -568,7 +568,7 @@ mutable struct EachAnn
end end
function Base.iterate(ea::EachAnn, i = 1) function Base.iterate(ea::EachAnn, i = 1)
if ea.anns == nothing || isempty(ea.anns.strs) || i > length(ea.y) if ea.anns === nothing || isempty(ea.anns.strs) || i > length(ea.y)
return nothing return nothing
end end

View File

@ -496,7 +496,7 @@ function test_examples(pkgname::Symbol; debug = false, disp = true, sleep = noth
Plots._debugMode.on = debug Plots._debugMode.on = debug
plts = Dict() plts = Dict()
for i in 1:length(_examples) for i in 1:length(_examples)
only != nothing && !(i in only) && continue only !== nothing && !(i in only) && continue
i in skip && continue i in skip && continue
try try
plt = test_examples(pkgname, i, debug=debug, disp=disp) plt = test_examples(pkgname, i, debug=debug, disp=disp)
@ -505,7 +505,7 @@ function test_examples(pkgname::Symbol; debug = false, disp = true, sleep = noth
# TODO: put error info into markdown? # TODO: put error info into markdown?
@warn("Example $pkgname:$i:$(_examples[i].header) failed with: $ex") @warn("Example $pkgname:$i:$(_examples[i].header) failed with: $ex")
end end
if sleep != nothing if sleep !== nothing
Base.sleep(sleep) Base.sleep(sleep)
end end
end end

View File

@ -126,7 +126,7 @@ function _preprocess_userrecipe(kw::KW)
end end
# convert a ribbon into a fillrange # convert a ribbon into a fillrange
if get(kw, :ribbon, nothing) != nothing if get(kw, :ribbon, nothing) !== nothing
make_fillrange_from_ribbon(kw) make_fillrange_from_ribbon(kw)
end end
return return
@ -136,7 +136,7 @@ function _add_errorbar_kw(kw_list::Vector{KW}, kw::KW)
# handle error bars by creating new recipedata data... these will have # handle error bars by creating new recipedata data... these will have
# the same recipedata index as the recipedata they are copied from # the same recipedata index as the recipedata they are copied from
for esym in (:xerror, :yerror) for esym in (:xerror, :yerror)
if get(kw, esym, nothing) != nothing if get(kw, esym, nothing) !== nothing
# we make a copy of the KW and apply an errorbar recipe # we make a copy of the KW and apply an errorbar recipe
errkw = copy(kw) errkw = copy(kw)
errkw[:seriestype] = esym errkw[:seriestype] = esym
@ -227,7 +227,7 @@ function _plot_setup(plt::Plot, plotattributes::KW, kw_list::Vector{KW})
# handle inset subplots # handle inset subplots
insets = plt[:inset_subplots] insets = plt[:inset_subplots]
if insets != nothing if insets !== nothing
if !(typeof(insets) <: AVec) if !(typeof(insets) <: AVec)
insets = [insets] insets = [insets]
end end

View File

@ -4,7 +4,7 @@ mutable struct CurrentPlot
end end
const CURRENT_PLOT = CurrentPlot(nothing) const CURRENT_PLOT = CurrentPlot(nothing)
isplotnull() = CURRENT_PLOT.nullableplot == nothing isplotnull() = CURRENT_PLOT.nullableplot === nothing
""" """
current() current()

View File

@ -239,7 +239,7 @@ end
@recipe function f(::Type{Val{:sticks}}, x, y, z) @recipe function f(::Type{Val{:sticks}}, x, y, z)
n = length(x) n = length(x)
fr = plotattributes[:fillrange] fr = plotattributes[:fillrange]
if fr == nothing if fr === nothing
sp = plotattributes[:subplot] sp = plotattributes[:subplot]
yaxis = sp[:yaxis] yaxis = sp[:yaxis]
fr = if yaxis[:scale] == :identity fr = if yaxis[:scale] == :identity
@ -291,13 +291,13 @@ end
# create segmented bezier curves in place of line segments # create segmented bezier curves in place of line segments
@recipe function f(::Type{Val{:curves}}, x, y, z; npoints = 30) @recipe function f(::Type{Val{:curves}}, x, y, z; npoints = 30)
args = z != nothing ? (x,y,z) : (x,y) args = z !== nothing ? (x,y,z) : (x,y)
newx, newy = zeros(0), zeros(0) newx, newy = zeros(0), zeros(0)
fr = plotattributes[:fillrange] fr = plotattributes[:fillrange]
newfr = fr != nothing ? zeros(0) : nothing newfr = fr !== nothing ? zeros(0) : nothing
newz = z != nothing ? zeros(0) : nothing newz = z !== nothing ? zeros(0) : nothing
# lz = plotattributes[:line_z] # lz = plotattributes[:line_z]
# newlz = lz != nothing ? zeros(0) : nothing # newlz = lz !== nothing ? zeros(0) : nothing
# for each line segment (point series with no NaNs), convert it into a bezier curve # for each line segment (point series with no NaNs), convert it into a bezier curve
# where the points are the control points of the curve # where the points are the control points of the curve
@ -306,13 +306,13 @@ end
ts = range(0, stop = 1, length = npoints) ts = range(0, stop = 1, length = npoints)
nanappend!(newx, map(t -> bezier_value(_cycle(x,rng), t), ts)) nanappend!(newx, map(t -> bezier_value(_cycle(x,rng), t), ts))
nanappend!(newy, map(t -> bezier_value(_cycle(y,rng), t), ts)) nanappend!(newy, map(t -> bezier_value(_cycle(y,rng), t), ts))
if z != nothing if z !== nothing
nanappend!(newz, map(t -> bezier_value(_cycle(z,rng), t), ts)) nanappend!(newz, map(t -> bezier_value(_cycle(z,rng), t), ts))
end end
if fr != nothing if fr !== nothing
nanappend!(newfr, map(t -> bezier_value(_cycle(fr,rng), t), ts)) nanappend!(newfr, map(t -> bezier_value(_cycle(fr,rng), t), ts))
end end
# if lz != nothing # if lz !== nothing
# lzrng = _cycle(lz, rng) # the line_z's for this segment # lzrng = _cycle(lz, rng) # the line_z's for this segment
# push!(newlz, 0.0) # push!(newlz, 0.0)
# append!(newlz, map(t -> lzrng[1+floor(Int, t * (length(rng)-1))], ts)) # append!(newlz, map(t -> lzrng[1+floor(Int, t * (length(rng)-1))], ts))
@ -321,16 +321,16 @@ end
x := newx x := newx
y := newy y := newy
if z == nothing if z === nothing
seriestype := :path seriestype := :path
else else
seriestype := :path3d seriestype := :path3d
z := newz z := newz
end end
if fr != nothing if fr !== nothing
fillrange := newfr fillrange := newfr
end end
# if lz != nothing # if lz !== nothing
# # line_z := newlz # # line_z := newlz
# linecolor := (isa(plotattributes[:linecolor], ColorGradient) ? plotattributes[:linecolor] : cgrad()) # linecolor := (isa(plotattributes[:linecolor], ColorGradient) ? plotattributes[:linecolor] : cgrad())
# end # end
@ -357,7 +357,7 @@ end
# compute half-width of bars # compute half-width of bars
bw = plotattributes[:bar_width] bw = plotattributes[:bar_width]
hw = if bw == nothing hw = if bw === nothing
if nx > 1 if nx > 1
0.5*_bar_width*ignorenan_minimum(filter(x->x>0, diff(procx))) 0.5*_bar_width*ignorenan_minimum(filter(x->x>0, diff(procx)))
else else
@ -369,7 +369,7 @@ end
# make fillto a vector... default fills to 0 # make fillto a vector... default fills to 0
fillto = plotattributes[:fillrange] fillto = plotattributes[:fillrange]
if fillto == nothing if fillto === nothing
fillto = 0 fillto = 0
end end
if (yscale in _logScales) && !all(_is_positive, fillto) if (yscale in _logScales) && !all(_is_positive, fillto)
@ -491,7 +491,7 @@ end
@recipe function f(::Type{Val{:barbins}}, x, y, z) @recipe function f(::Type{Val{:barbins}}, x, y, z)
edge, weights, xscale, yscale, baseline = _preprocess_binlike(plotattributes, x, y) edge, weights, xscale, yscale, baseline = _preprocess_binlike(plotattributes, x, y)
if (plotattributes[:bar_width] == nothing) if (plotattributes[:bar_width] === nothing)
bar_width := diff(edge) bar_width := diff(edge)
end end
x := _bin_centers(edge) x := _bin_centers(edge)
@ -533,7 +533,7 @@ function _stepbins_path(edge, weights, baseline::Real, xscale::Symbol, yscale::S
last_w = eltype(weights)(NaN) last_w = eltype(weights)(NaN)
while it_tuple_e != nothing && it_tuple_w != nothing while it_tuple_e !== nothing && it_tuple_w !== nothing
b, it_state_e = it_tuple_e b, it_state_e = it_tuple_e
w, it_state_w = it_tuple_w w, it_state_w = it_tuple_w
@ -667,7 +667,7 @@ end
function _make_hist(vs::NTuple{N,AbstractVector}, binning; normed = false, weights = nothing) where N function _make_hist(vs::NTuple{N,AbstractVector}, binning; normed = false, weights = nothing) where N
localvs = _filternans(vs) localvs = _filternans(vs)
edges = _hist_edges(localvs, binning) edges = _hist_edges(localvs, binning)
h = float( weights == nothing ? h = float( weights === nothing ?
StatsBase.fit(StatsBase.Histogram, localvs, edges, closed = :left) : StatsBase.fit(StatsBase.Histogram, localvs, edges, closed = :left) :
StatsBase.fit(StatsBase.Histogram, localvs, StatsBase.Weights(weights), edges, closed = :left) StatsBase.fit(StatsBase.Histogram, localvs, StatsBase.Weights(weights), edges, closed = :left)
) )

View File

@ -22,7 +22,7 @@ function _get_defaults(s::Symbol)
:fglegend => thm.text, :fglegend => thm.text,
:palette => thm.palette, :palette => thm.palette,
) )
if thm.gradient != nothing if thm.gradient !== nothing
push!(defaults, :gradient => thm.gradient) push!(defaults, :gradient => thm.gradient)
end end
return defaults return defaults

View File

@ -26,7 +26,7 @@ function histogramHack(; kw...)
plotattributes[:x] = midpoints plotattributes[:x] = midpoints
plotattributes[:y] = float(counts) plotattributes[:y] = float(counts)
plotattributes[:seriestype] = :bar plotattributes[:seriestype] = :bar
plotattributes[:fillrange] = plotattributes[:fillrange] == nothing ? 0.0 : plotattributes[:fillrange] plotattributes[:fillrange] = plotattributes[:fillrange] === nothing ? 0.0 : plotattributes[:fillrange]
plotattributes plotattributes
end end
@ -38,7 +38,7 @@ function barHack(; kw...)
plotattributes = KW(kw) plotattributes = KW(kw)
midpoints = plotattributes[:x] midpoints = plotattributes[:x]
heights = plotattributes[:y] heights = plotattributes[:y]
fillrange = plotattributes[:fillrange] == nothing ? 0.0 : plotattributes[:fillrange] fillrange = plotattributes[:fillrange] === nothing ? 0.0 : plotattributes[:fillrange]
# estimate the edges # estimate the edges
dists = diff(midpoints) * 0.5 dists = diff(midpoints) * 0.5
@ -81,7 +81,7 @@ function sticksHack(; kw...)
# these are the line vertices # these are the line vertices
x = Float64[] x = Float64[]
y = Float64[] y = Float64[]
fillrange = plotattributesLine[:fillrange] == nothing ? 0.0 : plotattributesLine[:fillrange] fillrange = plotattributesLine[:fillrange] === nothing ? 0.0 : plotattributesLine[:fillrange]
# calculate the vertices # calculate the vertices
yScatter = plotattributesScatter[:y] yScatter = plotattributesScatter[:y]
@ -194,7 +194,7 @@ end
function iter_segments(series::Series) function iter_segments(series::Series)
x, y, z = series[:x], series[:y], series[:z] x, y, z = series[:x], series[:y], series[:z]
if x == nothing if x === nothing
return UnitRange{Int}[] return UnitRange{Int}[]
elseif has_attribute_segments(series) elseif has_attribute_segments(series)
if series[:seriestype] in (:scatter, :scatter3d) if series[:seriestype] in (:scatter, :scatter3d)
@ -478,7 +478,7 @@ function make_fillrange_from_ribbon(kw::KW)
rib1, rib2 = -first(rib), last(rib) rib1, rib2 = -first(rib), last(rib)
# kw[:ribbon] = nothing # kw[:ribbon] = nothing
kw[:fillrange] = make_fillrange_side(y, rib1), make_fillrange_side(y, rib2) kw[:fillrange] = make_fillrange_side(y, rib1), make_fillrange_side(y, rib2)
(get(kw, :fillalpha, nothing) == nothing) && (kw[:fillalpha] = 0.5) (get(kw, :fillalpha, nothing) === nothing) && (kw[:fillalpha] = 0.5)
end end
#turn tuple of fillranges to one path #turn tuple of fillranges to one path
@ -529,7 +529,7 @@ function get_clims(sp::Subplot)
for vals in (series[:seriestype] in z_colored_series ? series[:z] : nothing, series[:line_z], series[:marker_z], series[:fill_z]) for vals in (series[:seriestype] in z_colored_series ? series[:z] : nothing, series[:line_z], series[:marker_z], series[:fill_z])
if (typeof(vals) <: AbstractSurface) && (eltype(vals.surf) <: Union{Missing, Real}) if (typeof(vals) <: AbstractSurface) && (eltype(vals.surf) <: Union{Missing, Real})
zmin, zmax = _update_clims(zmin, zmax, ignorenan_extrema(vals.surf)...) zmin, zmax = _update_clims(zmin, zmax, ignorenan_extrema(vals.surf)...)
elseif (vals != nothing) && (eltype(vals) <: Union{Missing, Real}) elseif (vals !== nothing) && (eltype(vals) <: Union{Missing, Real})
zmin, zmax = _update_clims(zmin, zmax, ignorenan_extrema(vals)...) zmin, zmax = _update_clims(zmin, zmax, ignorenan_extrema(vals)...)
end end
end end
@ -602,7 +602,7 @@ for comp in (:line, :fill, :marker)
function $get_compcolor(series, cmin::Real, cmax::Real, i::Int = 1) function $get_compcolor(series, cmin::Real, cmax::Real, i::Int = 1)
c = series[$Symbol($compcolor)] c = series[$Symbol($compcolor)]
z = series[$Symbol($comp_z)] z = series[$Symbol($comp_z)]
if z == nothing if z === nothing
isa(c, ColorGradient) ? c : plot_color(_cycle(c, i)) isa(c, ColorGradient) ? c : plot_color(_cycle(c, i))
else else
grad = isa(c, ColorGradient) ? c : cgrad() grad = isa(c, ColorGradient) ? c : cgrad()
@ -613,7 +613,7 @@ for comp in (:line, :fill, :marker)
$get_compcolor(series, clims, i::Int = 1) = $get_compcolor(series, clims[1], clims[2], i) $get_compcolor(series, clims, i::Int = 1) = $get_compcolor(series, clims[1], clims[2], i)
function $get_compcolor(series, i::Int = 1) function $get_compcolor(series, i::Int = 1)
if series[$Symbol($comp_z)] == nothing if series[$Symbol($comp_z)] === nothing
$get_compcolor(series, 0, 1, i) $get_compcolor(series, 0, 1, i)
else else
$get_compcolor(series, get_clims(series[:subplot]), i) $get_compcolor(series, get_clims(series[:subplot]), i)
@ -650,7 +650,7 @@ function has_attribute_segments(series::Series)
for letter in (:x, :y, :z) for letter in (:x, :y, :z)
# If we have NaNs in the data they define the segments and # If we have NaNs in the data they define the segments and
# SegmentsIterator is used # SegmentsIterator is used
series[letter] != nothing && NaN in collect(series[letter]) && return false series[letter] !== nothing && NaN in collect(series[letter]) && return false
end end
series[:seriestype] == :shape && return false series[:seriestype] == :shape && return false
# ... else we check relevant attributes if they have multiple inputs # ... else we check relevant attributes if they have multiple inputs

View File

@ -64,7 +64,7 @@ function image_comparison_tests(pkg::Symbol, idx::Int; debug = false, popup = is
# now we have the fn (if any)... do the comparison # now we have the fn (if any)... do the comparison
# @show reffn # @show reffn
if reffn == nothing if reffn === nothing
reffn = newfn reffn = newfn
end end
# @show reffn # @show reffn
@ -98,7 +98,7 @@ function image_comparison_facts(pkg::Symbol;
tol = 1e-2) # acceptable error (percent) tol = 1e-2) # acceptable error (percent)
for i in 1:length(Plots._examples) for i in 1:length(Plots._examples)
i in skip && continue i in skip && continue
if only == nothing || i in only if only === nothing || i in only
@test image_comparison_tests(pkg, i, debug=debug, sigma=sigma, tol=tol) |> success == true @test image_comparison_tests(pkg, i, debug=debug, sigma=sigma, tol=tol) |> success == true
end end
end end