changed linetype to seriestype
This commit is contained in:
parent
83bd780f2a
commit
54efb48d62
92
src/Plots.jl
92
src/Plots.jl
@ -186,52 +186,52 @@ include("output.jl")
|
|||||||
|
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
|
|
||||||
scatter(args...; kw...) = plot(args...; kw..., linetype = :scatter)
|
scatter(args...; kw...) = plot(args...; kw..., seriestype = :scatter)
|
||||||
scatter!(args...; kw...) = plot!(args...; kw..., linetype = :scatter)
|
scatter!(args...; kw...) = plot!(args...; kw..., seriestype = :scatter)
|
||||||
bar(args...; kw...) = plot(args...; kw..., linetype = :bar)
|
bar(args...; kw...) = plot(args...; kw..., seriestype = :bar)
|
||||||
bar!(args...; kw...) = plot!(args...; kw..., linetype = :bar)
|
bar!(args...; kw...) = plot!(args...; kw..., seriestype = :bar)
|
||||||
barh(args...; kw...) = plot(args...; kw..., linetype = :barh, orientation = :h)
|
barh(args...; kw...) = plot(args...; kw..., seriestype = :barh, orientation = :h)
|
||||||
barh!(args...; kw...) = plot!(args...; kw..., linetype = :barh, orientation = :h)
|
barh!(args...; kw...) = plot!(args...; kw..., seriestype = :barh, orientation = :h)
|
||||||
histogram(args...; kw...) = plot(args...; kw..., linetype = :hist)
|
histogram(args...; kw...) = plot(args...; kw..., seriestype = :hist)
|
||||||
histogram!(args...; kw...) = plot!(args...; kw..., linetype = :hist)
|
histogram!(args...; kw...) = plot!(args...; kw..., seriestype = :hist)
|
||||||
histogram2d(args...; kw...) = plot(args...; kw..., linetype = :hist2d)
|
histogram2d(args...; kw...) = plot(args...; kw..., seriestype = :hist2d)
|
||||||
histogram2d!(args...; kw...) = plot!(args...; kw..., linetype = :hist2d)
|
histogram2d!(args...; kw...) = plot!(args...; kw..., seriestype = :hist2d)
|
||||||
density(args...; kw...) = plot(args...; kw..., linetype = :density)
|
density(args...; kw...) = plot(args...; kw..., seriestype = :density)
|
||||||
density!(args...; kw...) = plot!(args...; kw..., linetype = :density)
|
density!(args...; kw...) = plot!(args...; kw..., seriestype = :density)
|
||||||
heatmap(args...; kw...) = plot(args...; kw..., linetype = :heatmap)
|
heatmap(args...; kw...) = plot(args...; kw..., seriestype = :heatmap)
|
||||||
heatmap!(args...; kw...) = plot!(args...; kw..., linetype = :heatmap)
|
heatmap!(args...; kw...) = plot!(args...; kw..., seriestype = :heatmap)
|
||||||
hexbin(args...; kw...) = plot(args...; kw..., linetype = :hexbin)
|
hexbin(args...; kw...) = plot(args...; kw..., seriestype = :hexbin)
|
||||||
hexbin!(args...; kw...) = plot!(args...; kw..., linetype = :hexbin)
|
hexbin!(args...; kw...) = plot!(args...; kw..., seriestype = :hexbin)
|
||||||
sticks(args...; kw...) = plot(args...; kw..., linetype = :sticks, marker = :ellipse)
|
sticks(args...; kw...) = plot(args...; kw..., seriestype = :sticks, marker = :ellipse)
|
||||||
sticks!(args...; kw...) = plot!(args...; kw..., linetype = :sticks, marker = :ellipse)
|
sticks!(args...; kw...) = plot!(args...; kw..., seriestype = :sticks, marker = :ellipse)
|
||||||
hline(args...; kw...) = plot(args...; kw..., linetype = :hline)
|
hline(args...; kw...) = plot(args...; kw..., seriestype = :hline)
|
||||||
hline!(args...; kw...) = plot!(args...; kw..., linetype = :hline)
|
hline!(args...; kw...) = plot!(args...; kw..., seriestype = :hline)
|
||||||
vline(args...; kw...) = plot(args...; kw..., linetype = :vline)
|
vline(args...; kw...) = plot(args...; kw..., seriestype = :vline)
|
||||||
vline!(args...; kw...) = plot!(args...; kw..., linetype = :vline)
|
vline!(args...; kw...) = plot!(args...; kw..., seriestype = :vline)
|
||||||
ohlc(args...; kw...) = plot(args...; kw..., linetype = :ohlc)
|
ohlc(args...; kw...) = plot(args...; kw..., seriestype = :ohlc)
|
||||||
ohlc!(args...; kw...) = plot!(args...; kw..., linetype = :ohlc)
|
ohlc!(args...; kw...) = plot!(args...; kw..., seriestype = :ohlc)
|
||||||
pie(args...; kw...) = plot(args...; kw..., linetype = :pie, aspect_ratio = :equal, grid=false, xticks=nothing, yticks=nothing)
|
pie(args...; kw...) = plot(args...; kw..., seriestype = :pie, aspect_ratio = :equal, grid=false, xticks=nothing, yticks=nothing)
|
||||||
pie!(args...; kw...) = plot!(args...; kw..., linetype = :pie, aspect_ratio = :equal, grid=false, xticks=nothing, yticks=nothing)
|
pie!(args...; kw...) = plot!(args...; kw..., seriestype = :pie, aspect_ratio = :equal, grid=false, xticks=nothing, yticks=nothing)
|
||||||
contour(args...; kw...) = plot(args...; kw..., linetype = :contour)
|
contour(args...; kw...) = plot(args...; kw..., seriestype = :contour)
|
||||||
contour!(args...; kw...) = plot!(args...; kw..., linetype = :contour)
|
contour!(args...; kw...) = plot!(args...; kw..., seriestype = :contour)
|
||||||
contour3d(args...; kw...) = plot(args...; kw..., linetype = :contour3d)
|
contour3d(args...; kw...) = plot(args...; kw..., seriestype = :contour3d)
|
||||||
contour3d!(args...; kw...) = plot!(args...; kw..., linetype = :contour3d)
|
contour3d!(args...; kw...) = plot!(args...; kw..., seriestype = :contour3d)
|
||||||
surface(args...; kw...) = plot(args...; kw..., linetype = :surface)
|
surface(args...; kw...) = plot(args...; kw..., seriestype = :surface)
|
||||||
surface!(args...; kw...) = plot!(args...; kw..., linetype = :surface)
|
surface!(args...; kw...) = plot!(args...; kw..., seriestype = :surface)
|
||||||
wireframe(args...; kw...) = plot(args...; kw..., linetype = :wireframe)
|
wireframe(args...; kw...) = plot(args...; kw..., seriestype = :wireframe)
|
||||||
wireframe!(args...; kw...) = plot!(args...; kw..., linetype = :wireframe)
|
wireframe!(args...; kw...) = plot!(args...; kw..., seriestype = :wireframe)
|
||||||
path3d(args...; kw...) = plot(args...; kw..., linetype = :path3d)
|
path3d(args...; kw...) = plot(args...; kw..., seriestype = :path3d)
|
||||||
path3d!(args...; kw...) = plot!(args...; kw..., linetype = :path3d)
|
path3d!(args...; kw...) = plot!(args...; kw..., seriestype = :path3d)
|
||||||
plot3d(args...; kw...) = plot(args...; kw..., linetype = :path3d)
|
plot3d(args...; kw...) = plot(args...; kw..., seriestype = :path3d)
|
||||||
plot3d!(args...; kw...) = plot!(args...; kw..., linetype = :path3d)
|
plot3d!(args...; kw...) = plot!(args...; kw..., seriestype = :path3d)
|
||||||
scatter3d(args...; kw...) = plot(args...; kw..., linetype = :scatter3d)
|
scatter3d(args...; kw...) = plot(args...; kw..., seriestype = :scatter3d)
|
||||||
scatter3d!(args...; kw...) = plot!(args...; kw..., linetype = :scatter3d)
|
scatter3d!(args...; kw...) = plot!(args...; kw..., seriestype = :scatter3d)
|
||||||
boxplot(args...; kw...) = plot(args...; kw..., linetype = :boxplot)
|
boxplot(args...; kw...) = plot(args...; kw..., seriestype = :boxplot)
|
||||||
boxplot!(args...; kw...) = plot!(args...; kw..., linetype = :boxplot)
|
boxplot!(args...; kw...) = plot!(args...; kw..., seriestype = :boxplot)
|
||||||
violin(args...; kw...) = plot(args...; kw..., linetype = :violin)
|
violin(args...; kw...) = plot(args...; kw..., seriestype = :violin)
|
||||||
violin!(args...; kw...) = plot!(args...; kw..., linetype = :violin)
|
violin!(args...; kw...) = plot!(args...; kw..., seriestype = :violin)
|
||||||
quiver(args...; kw...) = plot(args...; kw..., linetype = :quiver)
|
quiver(args...; kw...) = plot(args...; kw..., seriestype = :quiver)
|
||||||
quiver!(args...; kw...) = plot!(args...; kw..., linetype = :quiver)
|
quiver!(args...; kw...) = plot!(args...; kw..., seriestype = :quiver)
|
||||||
|
|
||||||
|
|
||||||
title!(s::AbstractString; kw...) = plot!(; title = s, kw...)
|
title!(s::AbstractString; kw...) = plot!(; title = s, kw...)
|
||||||
|
|||||||
41
src/args.jl
41
src/args.jl
@ -46,12 +46,12 @@ const _allTypes = vcat([
|
|||||||
:imagesc => :image,
|
:imagesc => :image,
|
||||||
)
|
)
|
||||||
|
|
||||||
like_histogram(linetype::Symbol) = linetype in (:hist, :density)
|
like_histogram(seriestype::Symbol) = seriestype in (:hist, :density)
|
||||||
like_line(linetype::Symbol) = linetype in (:line, :path, :steppre, :steppost)
|
like_line(seriestype::Symbol) = seriestype in (:line, :path, :steppre, :steppost)
|
||||||
like_surface(linetype::Symbol) = linetype in (:contour, :contour3d, :heatmap, :surface, :wireframe, :image)
|
like_surface(seriestype::Symbol) = seriestype in (:contour, :contour3d, :heatmap, :surface, :wireframe, :image)
|
||||||
|
|
||||||
is3d(linetype::Symbol) = linetype in _3dTypes
|
is3d(seriestype::Symbol) = seriestype in _3dTypes
|
||||||
is3d(d::KW) = trueOrAllTrue(is3d, d[:linetype])
|
is3d(d::KW) = trueOrAllTrue(is3d, d[:seriestype])
|
||||||
|
|
||||||
const _allStyles = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot]
|
const _allStyles = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot]
|
||||||
@compat const _styleAliases = KW(
|
@compat const _styleAliases = KW(
|
||||||
@ -120,7 +120,7 @@ _seriesDefaults[:axis] = :left
|
|||||||
_seriesDefaults[:label] = "AUTO"
|
_seriesDefaults[:label] = "AUTO"
|
||||||
_seriesDefaults[:seriescolor] = :auto
|
_seriesDefaults[:seriescolor] = :auto
|
||||||
_seriesDefaults[:seriesalpha] = nothing
|
_seriesDefaults[:seriesalpha] = nothing
|
||||||
_seriesDefaults[:linetype] = :path
|
_seriesDefaults[:seriestype] = :path
|
||||||
_seriesDefaults[:linestyle] = :solid
|
_seriesDefaults[:linestyle] = :solid
|
||||||
_seriesDefaults[:linewidth] = :auto
|
_seriesDefaults[:linewidth] = :auto
|
||||||
_seriesDefaults[:linecolor] = :match
|
_seriesDefaults[:linecolor] = :match
|
||||||
@ -300,10 +300,11 @@ add_aliases(:makeralpha, :ma, :malpha, :mα, :makeropacity, :mopacity)
|
|||||||
add_aliases(:markerstrokealpha, :msa, :msalpha, :msα, :markerstrokeopacity, :msopacity)
|
add_aliases(:markerstrokealpha, :msa, :msalpha, :msα, :markerstrokeopacity, :msopacity)
|
||||||
add_aliases(:fillalpha, :fa, :falpha, :fα, :fillopacity, :fopacity)
|
add_aliases(:fillalpha, :fa, :falpha, :fα, :fillopacity, :fopacity)
|
||||||
|
|
||||||
|
# series attributes
|
||||||
|
add_aliases(:seriestype, :st, :t, :typ, :linetype, :lt)
|
||||||
add_aliases(:label, :lab)
|
add_aliases(:label, :lab)
|
||||||
add_aliases(:line, :l)
|
add_aliases(:line, :l)
|
||||||
add_aliases(:linewidth, :w, :width, :lw)
|
add_aliases(:linewidth, :w, :width, :lw)
|
||||||
add_aliases(:linetype, :lt, :t, :seriestype)
|
|
||||||
add_aliases(:linestyle, :style, :s, :ls)
|
add_aliases(:linestyle, :style, :s, :ls)
|
||||||
add_aliases(:marker, :m, :mark)
|
add_aliases(:marker, :m, :mark)
|
||||||
add_aliases(:markershape, :shape)
|
add_aliases(:markershape, :shape)
|
||||||
@ -451,9 +452,9 @@ end
|
|||||||
|
|
||||||
|
|
||||||
function processLineArg(d::KW, arg)
|
function processLineArg(d::KW, arg)
|
||||||
# linetype
|
# seriestype
|
||||||
if allLineTypes(arg)
|
if allLineTypes(arg)
|
||||||
d[:linetype] = arg
|
d[:seriestype] = arg
|
||||||
|
|
||||||
# linestyle
|
# linestyle
|
||||||
elseif allStyles(arg)
|
elseif allStyles(arg)
|
||||||
@ -587,8 +588,8 @@ function preprocessArgs!(d::KW)
|
|||||||
processLineArg(d, arg)
|
processLineArg(d, arg)
|
||||||
end
|
end
|
||||||
|
|
||||||
if haskey(d, :linetype) && haskey(_typeAliases, d[:linetype])
|
if haskey(d, :seriestype) && haskey(_typeAliases, d[:seriestype])
|
||||||
d[:linetype] = _typeAliases[d[:linetype]]
|
d[:seriestype] = _typeAliases[d[:seriestype]]
|
||||||
end
|
end
|
||||||
|
|
||||||
# handle marker args... default to ellipse if shape not set
|
# handle marker args... default to ellipse if shape not set
|
||||||
@ -732,9 +733,9 @@ _markershape_supported(pkg::AbstractBackend, shapes::AVec) = all([_markershape_s
|
|||||||
function warnOnUnsupported(pkg::AbstractBackend, d::KW)
|
function warnOnUnsupported(pkg::AbstractBackend, d::KW)
|
||||||
(d[:axis] in supportedAxes(pkg)
|
(d[:axis] in supportedAxes(pkg)
|
||||||
|| warn("axis $(d[:axis]) is unsupported with $pkg. Choose from: $(supportedAxes(pkg))"))
|
|| warn("axis $(d[:axis]) is unsupported with $pkg. Choose from: $(supportedAxes(pkg))"))
|
||||||
(d[:linetype] == :none
|
(d[:seriestype] == :none
|
||||||
|| d[:linetype] in supportedTypes(pkg)
|
|| d[:seriestype] in supportedTypes(pkg)
|
||||||
|| warn("linetype $(d[:linetype]) is unsupported with $pkg. Choose from: $(supportedTypes(pkg))"))
|
|| warn("seriestype $(d[:seriestype]) is unsupported with $pkg. Choose from: $(supportedTypes(pkg))"))
|
||||||
(d[:linestyle] in supportedStyles(pkg)
|
(d[:linestyle] in supportedStyles(pkg)
|
||||||
|| warn("linestyle $(d[:linestyle]) is unsupported with $pkg. Choose from: $(supportedStyles(pkg))"))
|
|| warn("linestyle $(d[:linestyle]) is unsupported with $pkg. Choose from: $(supportedStyles(pkg))"))
|
||||||
(d[:markershape] == :none
|
(d[:markershape] == :none
|
||||||
@ -826,8 +827,8 @@ function getPlotArgs(pkg::AbstractBackend, kw, idx::Int; set_defaults = true)
|
|||||||
d
|
d
|
||||||
end
|
end
|
||||||
|
|
||||||
function has_black_border_for_default(lt::Symbol)
|
function has_black_border_for_default(st::Symbol)
|
||||||
like_histogram(lt) || lt in (:hexbin, :bar)
|
like_histogram(st) || st in (:hexbin, :bar)
|
||||||
end
|
end
|
||||||
#
|
#
|
||||||
# # build the argument dictionary for a series
|
# # build the argument dictionary for a series
|
||||||
@ -847,8 +848,8 @@ end
|
|||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# if haskey(_typeAliases, d[:linetype])
|
# if haskey(_typeAliases, d[:seriestype])
|
||||||
# d[:linetype] = _typeAliases[d[:linetype]]
|
# d[:seriestype] = _typeAliases[d[:seriestype]]
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# aliasesAndAutopick(d, :axis, _axesAliases, supportedAxes(pkg), plotIndex)
|
# aliasesAndAutopick(d, :axis, _axesAliases, supportedAxes(pkg), plotIndex)
|
||||||
@ -876,7 +877,7 @@ end
|
|||||||
# # update colors
|
# # update colors
|
||||||
# for csym in (:linecolor, :markercolor, :fillcolor)
|
# for csym in (:linecolor, :markercolor, :fillcolor)
|
||||||
# d[csym] = if d[csym] == :match
|
# d[csym] = if d[csym] == :match
|
||||||
# if has_black_border_for_default(d[:linetype]) && csym == :linecolor
|
# if has_black_border_for_default(d[:seriestype]) && csym == :linecolor
|
||||||
# :black
|
# :black
|
||||||
# else
|
# else
|
||||||
# d[:seriescolor]
|
# d[:seriescolor]
|
||||||
@ -899,7 +900,7 @@ end
|
|||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# # scatter plots don't have a line, but must have a shape
|
# # scatter plots don't have a line, but must have a shape
|
||||||
# if d[:linetype] in (:scatter, :scatter3d)
|
# if d[:seriestype] in (:scatter, :scatter3d)
|
||||||
# d[:linewidth] = 0
|
# d[:linewidth] = 0
|
||||||
# if d[:markershape] == :none
|
# if d[:markershape] == :none
|
||||||
# d[:markershape] = :ellipse
|
# d[:markershape] = :ellipse
|
||||||
|
|||||||
@ -52,6 +52,9 @@ _update_plot_pos_size{P<:AbstractBackend}(plt::AbstractPlot{P}, d::KW) = nothing
|
|||||||
subplot(pkg::AbstractBackend; kw...) = error("subplot($pkg; kw...) is not implemented")
|
subplot(pkg::AbstractBackend; kw...) = error("subplot($pkg; kw...) is not implemented")
|
||||||
subplot!(pkg::AbstractBackend, subplt::Subplot; kw...) = error("subplot!($pkg, subplt; kw...) is not implemented")
|
subplot!(pkg::AbstractBackend, subplt::Subplot; kw...) = error("subplot!($pkg, subplt; kw...) is not implemented")
|
||||||
|
|
||||||
|
# don't do anything as a default
|
||||||
|
_before_add_series(plt::Plot) = nothing
|
||||||
|
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -18,7 +18,7 @@ supportedArgs(::BokehBackend) = [
|
|||||||
# :legend,
|
# :legend,
|
||||||
:seriescolor, :seriesalpha,
|
:seriescolor, :seriesalpha,
|
||||||
:linestyle,
|
:linestyle,
|
||||||
:linetype,
|
:seriestype,
|
||||||
:linewidth,
|
:linewidth,
|
||||||
# :linealpha,
|
# :linealpha,
|
||||||
:markershape,
|
:markershape,
|
||||||
@ -104,14 +104,14 @@ const _glyphtypes = KW(
|
|||||||
|
|
||||||
|
|
||||||
function bokeh_glyph_type(d::KW)
|
function bokeh_glyph_type(d::KW)
|
||||||
lt = d[:linetype]
|
st = d[:seriestype]
|
||||||
mt = d[:markershape]
|
mt = d[:markershape]
|
||||||
if lt == :scatter && mt == :none
|
if st == :scatter && mt == :none
|
||||||
mt = :ellipse
|
mt = :ellipse
|
||||||
end
|
end
|
||||||
|
|
||||||
# if we have a marker, use that
|
# if we have a marker, use that
|
||||||
if lt == :scatter || mt != :none
|
if st == :scatter || mt != :none
|
||||||
return _glyphtypes[mt]
|
return _glyphtypes[mt]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
supportedArgs(::GadflyBackend) = [
|
supportedArgs(::GadflyBackend) = [
|
||||||
:annotation,
|
:annotation,
|
||||||
:background_color, :foreground_color, :color_palette,
|
:background_color, :foreground_color, :color_palette,
|
||||||
:group, :label, :linetype,
|
:group, :label, :seriestype,
|
||||||
:seriescolor, :seriesalpha,
|
:seriescolor, :seriesalpha,
|
||||||
:linecolor, :linestyle, :linewidth, :linealpha,
|
:linecolor, :linestyle, :linewidth, :linealpha,
|
||||||
:markershape, :markercolor, :markersize, :markeralpha,
|
:markershape, :markercolor, :markersize, :markeralpha,
|
||||||
@ -69,31 +69,31 @@ end
|
|||||||
|
|
||||||
|
|
||||||
function getLineGeom(d::KW)
|
function getLineGeom(d::KW)
|
||||||
lt = d[:linetype]
|
st = d[:seriestype]
|
||||||
xbins, ybins = maketuple(d[:bins])
|
xbins, ybins = maketuple(d[:bins])
|
||||||
if lt == :hexb
|
if st == :hexb
|
||||||
Gadfly.Geom.hexbin(xbincount = xbins, ybincount = ybins)
|
Gadfly.Geom.hexbin(xbincount = xbins, ybincount = ybins)
|
||||||
elseif lt == :hist2d
|
elseif st == :hist2d
|
||||||
Gadfly.Geom.histogram2d(xbincount = xbins, ybincount = ybins)
|
Gadfly.Geom.histogram2d(xbincount = xbins, ybincount = ybins)
|
||||||
elseif lt == :hist
|
elseif st == :hist
|
||||||
Gadfly.Geom.histogram(bincount = xbins,
|
Gadfly.Geom.histogram(bincount = xbins,
|
||||||
orientation = isvertical(d) ? :vertical : :horizontal,
|
orientation = isvertical(d) ? :vertical : :horizontal,
|
||||||
position = d[:bar_position] == :stack ? :stack : :dodge)
|
position = d[:bar_position] == :stack ? :stack : :dodge)
|
||||||
elseif lt == :path
|
elseif st == :path
|
||||||
Gadfly.Geom.path
|
Gadfly.Geom.path
|
||||||
elseif lt in (:bar, :sticks)
|
elseif st in (:bar, :sticks)
|
||||||
Gadfly.Geom.bar
|
Gadfly.Geom.bar
|
||||||
elseif lt == :steppost
|
elseif st == :steppost
|
||||||
Gadfly.Geom.step
|
Gadfly.Geom.step
|
||||||
elseif lt == :steppre
|
elseif st == :steppre
|
||||||
Gadfly.Geom.step(direction = :vh)
|
Gadfly.Geom.step(direction = :vh)
|
||||||
elseif lt == :hline
|
elseif st == :hline
|
||||||
Gadfly.Geom.hline
|
Gadfly.Geom.hline
|
||||||
elseif lt == :vline
|
elseif st == :vline
|
||||||
Gadfly.Geom.vline
|
Gadfly.Geom.vline
|
||||||
elseif lt == :contour
|
elseif st == :contour
|
||||||
Gadfly.Geom.contour(levels = d[:levels])
|
Gadfly.Geom.contour(levels = d[:levels])
|
||||||
# elseif lt == :shape
|
# elseif st == :shape
|
||||||
# Gadfly.Geom.polygon(fill = true, preserve_order = true)
|
# Gadfly.Geom.polygon(fill = true, preserve_order = true)
|
||||||
else
|
else
|
||||||
nothing
|
nothing
|
||||||
@ -116,13 +116,13 @@ function get_extra_theme_args(d::KW, k::Symbol)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function getGadflyLineTheme(d::KW)
|
function getGadflyLineTheme(d::KW)
|
||||||
lt = d[:linetype]
|
st = d[:seriestype]
|
||||||
lc = convertColor(getColor(d[:linecolor]), d[:linealpha])
|
lc = convertColor(getColor(d[:linecolor]), d[:linealpha])
|
||||||
fc = convertColor(getColor(d[:fillcolor]), d[:fillalpha])
|
fc = convertColor(getColor(d[:fillcolor]), d[:fillalpha])
|
||||||
|
|
||||||
Gadfly.Theme(;
|
Gadfly.Theme(;
|
||||||
default_color = (lt in (:hist,:hist2d,:hexbin,:bar,:sticks) ? fc : lc),
|
default_color = (st in (:hist,:hist2d,:hexbin,:bar,:sticks) ? fc : lc),
|
||||||
line_width = (lt == :sticks ? 1 : d[:linewidth]) * Gadfly.px,
|
line_width = (st == :sticks ? 1 : d[:linewidth]) * Gadfly.px,
|
||||||
# line_style = Gadfly.get_stroke_vector(d[:linestyle]),
|
# line_style = Gadfly.get_stroke_vector(d[:linestyle]),
|
||||||
lowlight_color = x->RGB(fc), # fill/ribbon
|
lowlight_color = x->RGB(fc), # fill/ribbon
|
||||||
lowlight_opacity = alpha(fc), # fill/ribbon
|
lowlight_opacity = alpha(fc), # fill/ribbon
|
||||||
@ -136,10 +136,10 @@ function addGadflyLine!(plt::Plot, numlayers::Int, d::KW, geoms...)
|
|||||||
gplt = getGadflyContext(plt)
|
gplt = getGadflyContext(plt)
|
||||||
gfargs = vcat(geoms..., getGadflyLineTheme(d))
|
gfargs = vcat(geoms..., getGadflyLineTheme(d))
|
||||||
kwargs = KW()
|
kwargs = KW()
|
||||||
lt = d[:linetype]
|
st = d[:seriestype]
|
||||||
|
|
||||||
# add a fill?
|
# add a fill?
|
||||||
if d[:fillrange] != nothing && lt != :contour
|
if d[:fillrange] != nothing && st != :contour
|
||||||
fillmin, fillmax = map(makevec, maketuple(d[:fillrange]))
|
fillmin, fillmax = map(makevec, maketuple(d[:fillrange]))
|
||||||
nmin, nmax = length(fillmin), length(fillmax)
|
nmin, nmax = length(fillmin), length(fillmax)
|
||||||
kwargs[:ymin] = Float64[min(y, fillmin[mod1(i, nmin)], fillmax[mod1(i, nmax)]) for (i,y) in enumerate(d[:y])]
|
kwargs[:ymin] = Float64[min(y, fillmin[mod1(i, nmin)], fillmax[mod1(i, nmax)]) for (i,y) in enumerate(d[:y])]
|
||||||
@ -147,20 +147,20 @@ function addGadflyLine!(plt::Plot, numlayers::Int, d::KW, geoms...)
|
|||||||
push!(gfargs, Gadfly.Geom.ribbon)
|
push!(gfargs, Gadfly.Geom.ribbon)
|
||||||
end
|
end
|
||||||
|
|
||||||
if lt in (:hline, :vline)
|
if st in (:hline, :vline)
|
||||||
kwargs[lt == :hline ? :yintercept : :xintercept] = d[:y]
|
kwargs[st == :hline ? :yintercept : :xintercept] = d[:y]
|
||||||
|
|
||||||
else
|
else
|
||||||
if lt == :sticks
|
if st == :sticks
|
||||||
w = 0.01 * mean(diff(d[:x]))
|
w = 0.01 * mean(diff(d[:x]))
|
||||||
kwargs[:xmin] = d[:x] - w
|
kwargs[:xmin] = d[:x] - w
|
||||||
kwargs[:xmax] = d[:x] + w
|
kwargs[:xmax] = d[:x] + w
|
||||||
elseif lt == :contour
|
elseif st == :contour
|
||||||
kwargs[:z] = d[:z].surf
|
kwargs[:z] = d[:z].surf
|
||||||
addGadflyContColorScale(plt, d[:linecolor])
|
addGadflyContColorScale(plt, d[:linecolor])
|
||||||
end
|
end
|
||||||
|
|
||||||
kwargs[:x] = d[lt == :hist ? :y : :x]
|
kwargs[:x] = d[st == :hist ? :y : :x]
|
||||||
kwargs[:y] = d[:y]
|
kwargs[:y] = d[:y]
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -183,7 +183,7 @@ getMarkerGeom(other) = gadflyshape(get_shape(other))
|
|||||||
# getMarkerGeom(shape::Symbol) = gadflyshape(_shapes[shape])
|
# getMarkerGeom(shape::Symbol) = gadflyshape(_shapes[shape])
|
||||||
# getMarkerGeom(shapes::AVec) = gadflyshape(map(gadflyshape, shapes)) # map(getMarkerGeom, shapes)
|
# getMarkerGeom(shapes::AVec) = gadflyshape(map(gadflyshape, shapes)) # map(getMarkerGeom, shapes)
|
||||||
function getMarkerGeom(d::KW)
|
function getMarkerGeom(d::KW)
|
||||||
if d[:linetype] == :shape
|
if d[:seriestype] == :shape
|
||||||
Gadfly.Geom.polygon(fill = true, preserve_order = true)
|
Gadfly.Geom.polygon(fill = true, preserve_order = true)
|
||||||
else
|
else
|
||||||
getMarkerGeom(d[:markershape])
|
getMarkerGeom(d[:markershape])
|
||||||
@ -297,21 +297,21 @@ function addGadflySeries!(plt::Plot, d::KW)
|
|||||||
end
|
end
|
||||||
|
|
||||||
# special handling for ohlc and scatter
|
# special handling for ohlc and scatter
|
||||||
lt = d[:linetype]
|
st = d[:seriestype]
|
||||||
if lt == :ohlc
|
if st == :ohlc
|
||||||
error("Haven't re-implemented after refactoring")
|
error("Haven't re-implemented after refactoring")
|
||||||
elseif lt in (:hist2d, :hexbin) && (isa(d[:fillcolor], ColorGradient) || isa(d[:fillcolor], ColorFunction))
|
elseif st in (:hist2d, :hexbin) && (isa(d[:fillcolor], ColorGradient) || isa(d[:fillcolor], ColorFunction))
|
||||||
push!(gplt.scales, Gadfly.Scale.ContinuousColorScale(p -> RGB(getColorZ(d[:fillcolor], p))))
|
push!(gplt.scales, Gadfly.Scale.ContinuousColorScale(p -> RGB(getColorZ(d[:fillcolor], p))))
|
||||||
elseif lt == :scatter && d[:markershape] == :none
|
elseif st == :scatter && d[:markershape] == :none
|
||||||
d[:markershape] = :ellipse
|
d[:markershape] = :ellipse
|
||||||
end
|
end
|
||||||
|
|
||||||
# markers
|
# markers
|
||||||
if d[:markershape] != :none || lt == :shape
|
if d[:markershape] != :none || st == :shape
|
||||||
prepend!(layers, addGadflyMarker!(plt, length(gplt.layers), d, plt.plotargs, smooth...))
|
prepend!(layers, addGadflyMarker!(plt, length(gplt.layers), d, plt.plotargs, smooth...))
|
||||||
end
|
end
|
||||||
|
|
||||||
lt in (:hist2d, :hexbin, :contour) || addToGadflyLegend(plt, d)
|
st in (:hist2d, :hexbin, :contour) || addToGadflyLegend(plt, d)
|
||||||
|
|
||||||
# now save the layers that apply to this series
|
# now save the layers that apply to this series
|
||||||
d[:gadflylayers] = layers
|
d[:gadflylayers] = layers
|
||||||
|
|||||||
@ -17,7 +17,7 @@ supportedArgs(::GLVisualizeBackend) = [
|
|||||||
# :legend,
|
# :legend,
|
||||||
# :linecolor,
|
# :linecolor,
|
||||||
# :linestyle,
|
# :linestyle,
|
||||||
:linetype
|
:seriestype
|
||||||
# :seriescolor, :seriesalpha,
|
# :seriescolor, :seriesalpha,
|
||||||
# :linewidth,
|
# :linewidth,
|
||||||
# :linealpha,
|
# :linealpha,
|
||||||
|
|||||||
@ -10,7 +10,7 @@ supportedArgs(::GRBackend) = [
|
|||||||
:foreground_color_text, :foreground_color_border,
|
:foreground_color_text, :foreground_color_border,
|
||||||
:group,
|
:group,
|
||||||
:label,
|
:label,
|
||||||
:linetype,
|
:seriestype,
|
||||||
:seriescolor, :seriesalpha,
|
:seriescolor, :seriesalpha,
|
||||||
:linecolor, :linestyle, :linewidth, :linealpha,
|
:linecolor, :linestyle, :linewidth, :linealpha,
|
||||||
:markershape, :markercolor, :markersize, :markeralpha,
|
:markershape, :markercolor, :markersize, :markeralpha,
|
||||||
@ -56,7 +56,7 @@ function _initialize_backend(::GRBackend; kw...)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
const gr_linetype = KW(
|
const gr_seriestype = KW(
|
||||||
:auto => 1, :solid => 1, :dash => 2, :dot => 3, :dashdot => 4,
|
:auto => 1, :solid => 1, :dash => 2, :dot => 3, :dashdot => 4,
|
||||||
:dashdotdot => -1 )
|
:dashdotdot => -1 )
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ end
|
|||||||
|
|
||||||
function gr_polaraxes(rmin, rmax)
|
function gr_polaraxes(rmin, rmax)
|
||||||
GR.savestate()
|
GR.savestate()
|
||||||
GR.setlinetype(GR.LINETYPE_SOLID)
|
GR.setseriestype(GR.LINETYPE_SOLID)
|
||||||
GR.setlinecolorind(88)
|
GR.setlinecolorind(88)
|
||||||
tick = 0.5 * GR.tick(rmin, rmax)
|
tick = 0.5 * GR.tick(rmin, rmax)
|
||||||
n = round(Int, (rmax - rmin) / tick + 0.5)
|
n = round(Int, (rmax - rmin) / tick + 0.5)
|
||||||
@ -246,21 +246,21 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true,
|
|||||||
xmin = ymin = typemax(Float64)
|
xmin = ymin = typemax(Float64)
|
||||||
xmax = ymax = typemin(Float64)
|
xmax = ymax = typemin(Float64)
|
||||||
for p in plt.seriesargs
|
for p in plt.seriesargs
|
||||||
lt = p[:linetype]
|
st = p[:seriestype]
|
||||||
if get(d, :polar, false)
|
if get(d, :polar, false)
|
||||||
lt = :polar
|
st = :polar
|
||||||
end
|
end
|
||||||
if axis == gr_getaxisind(p)
|
if axis == gr_getaxisind(p)
|
||||||
if axis == 2
|
if axis == 2
|
||||||
num_axes = 2
|
num_axes = 2
|
||||||
end
|
end
|
||||||
if lt == :bar
|
if st == :bar
|
||||||
x, y = 1:length(p[:y]), p[:y]
|
x, y = 1:length(p[:y]), p[:y]
|
||||||
elseif lt == :ohlc
|
elseif st == :ohlc
|
||||||
x, y = 1:size(p[:y], 1), p[:y]
|
x, y = 1:size(p[:y], 1), p[:y]
|
||||||
elseif lt in [:hist, :density]
|
elseif st in [:hist, :density]
|
||||||
x, y = Base.hist(p[:y], p[:bins])
|
x, y = Base.hist(p[:y], p[:bins])
|
||||||
elseif lt in [:hist2d, :hexbin]
|
elseif st in [:hist2d, :hexbin]
|
||||||
E = zeros(length(p[:x]),2)
|
E = zeros(length(p[:x]),2)
|
||||||
E[:,1] = p[:x]
|
E[:,1] = p[:x]
|
||||||
E[:,2] = p[:y]
|
E[:,2] = p[:y]
|
||||||
@ -271,26 +271,26 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true,
|
|||||||
end
|
end
|
||||||
cmap = true
|
cmap = true
|
||||||
x, y, H = Base.hist2d(E, xbins, ybins)
|
x, y, H = Base.hist2d(E, xbins, ybins)
|
||||||
elseif lt in [:pie, :polar]
|
elseif st in [:pie, :polar]
|
||||||
axes_2d = false
|
axes_2d = false
|
||||||
xmin, xmax, ymin, ymax = 0, 1, 0, 1
|
xmin, xmax, ymin, ymax = 0, 1, 0, 1
|
||||||
x, y = p[:x], p[:y]
|
x, y = p[:x], p[:y]
|
||||||
else
|
else
|
||||||
if lt in [:contour, :surface, :heatmap]
|
if st in [:contour, :surface, :heatmap]
|
||||||
cmap = true
|
cmap = true
|
||||||
end
|
end
|
||||||
if lt in [:surface, :wireframe, :path3d, :scatter3d]
|
if st in [:surface, :wireframe, :path3d, :scatter3d]
|
||||||
axes_2d = false
|
axes_2d = false
|
||||||
end
|
end
|
||||||
if lt == :heatmap
|
if st == :heatmap
|
||||||
outside_ticks = true
|
outside_ticks = true
|
||||||
end
|
end
|
||||||
x, y = p[:x], p[:y]
|
x, y = p[:x], p[:y]
|
||||||
end
|
end
|
||||||
if !(lt in [:pie, :polar])
|
if !(st in [:pie, :polar])
|
||||||
xmin = min(minimum(x), xmin)
|
xmin = min(minimum(x), xmin)
|
||||||
xmax = max(maximum(x), xmax)
|
xmax = max(maximum(x), xmax)
|
||||||
if lt == :ohlc
|
if st == :ohlc
|
||||||
for val in y
|
for val in y
|
||||||
ymin = min(val.open, val.high, val.low, val.close, ymin)
|
ymin = min(val.open, val.high, val.low, val.close, ymin)
|
||||||
ymax = max(val.open, val.high, val.low, val.close, ymax)
|
ymax = max(val.open, val.high, val.low, val.close, ymax)
|
||||||
@ -437,8 +437,8 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true,
|
|||||||
legend = false
|
legend = false
|
||||||
|
|
||||||
for p in plt.seriesargs
|
for p in plt.seriesargs
|
||||||
lt = p[:linetype]
|
st = p[:seriestype]
|
||||||
if lt in (:hist2d, :hexbin, :contour, :surface, :wireframe, :heatmap)
|
if st in (:hist2d, :hexbin, :contour, :surface, :wireframe, :heatmap)
|
||||||
if isa(p[:fillcolor], ColorGradient)
|
if isa(p[:fillcolor], ColorGradient)
|
||||||
grad = p[:fillcolor]
|
grad = p[:fillcolor]
|
||||||
else
|
else
|
||||||
@ -450,17 +450,17 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true,
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if get(d, :polar, false)
|
if get(d, :polar, false)
|
||||||
lt = :polar
|
st = :polar
|
||||||
end
|
end
|
||||||
GR.savestate()
|
GR.savestate()
|
||||||
xmin, xmax, ymin, ymax = extrema[gr_getaxisind(p),:]
|
xmin, xmax, ymin, ymax = extrema[gr_getaxisind(p),:]
|
||||||
GR.setwindow(xmin, xmax, ymin, ymax)
|
GR.setwindow(xmin, xmax, ymin, ymax)
|
||||||
if lt in [:path, :line, :steppre, :steppost, :sticks, :hline, :vline, :ohlc, :polar]
|
if st in [:path, :line, :steppre, :steppost, :sticks, :hline, :vline, :ohlc, :polar]
|
||||||
GR.setlinetype(gr_linetype[p[:linestyle]])
|
GR.setseriestype(gr_seriestype[p[:linestyle]])
|
||||||
GR.setlinewidth(p[:linewidth])
|
GR.setlinewidth(p[:linewidth])
|
||||||
GR.setlinecolorind(gr_getcolorind(p[:linecolor]))
|
GR.setlinecolorind(gr_getcolorind(p[:linecolor]))
|
||||||
end
|
end
|
||||||
if lt == :path
|
if st == :path
|
||||||
if length(p[:x]) > 1
|
if length(p[:x]) > 1
|
||||||
if p[:fillrange] != nothing
|
if p[:fillrange] != nothing
|
||||||
GR.setfillcolorind(gr_getcolorind(p[:fillcolor]))
|
GR.setfillcolorind(gr_getcolorind(p[:fillcolor]))
|
||||||
@ -471,19 +471,19 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true,
|
|||||||
end
|
end
|
||||||
legend = true
|
legend = true
|
||||||
end
|
end
|
||||||
if lt == :line
|
if st == :line
|
||||||
if length(p[:x]) > 1
|
if length(p[:x]) > 1
|
||||||
gr_polyline(p[:x], p[:y])
|
gr_polyline(p[:x], p[:y])
|
||||||
end
|
end
|
||||||
legend = true
|
legend = true
|
||||||
elseif lt in [:steppre, :steppost]
|
elseif st in [:steppre, :steppost]
|
||||||
n = length(p[:x])
|
n = length(p[:x])
|
||||||
x = zeros(2*n + 1)
|
x = zeros(2*n + 1)
|
||||||
y = zeros(2*n + 1)
|
y = zeros(2*n + 1)
|
||||||
x[1], y[1] = p[:x][1], p[:y][1]
|
x[1], y[1] = p[:x][1], p[:y][1]
|
||||||
j = 2
|
j = 2
|
||||||
for i = 2:n
|
for i = 2:n
|
||||||
if lt == :steppre
|
if st == :steppre
|
||||||
x[j], x[j+1] = p[:x][i-1], p[:x][i]
|
x[j], x[j+1] = p[:x][i-1], p[:x][i]
|
||||||
y[j], y[j+1] = p[:y][i], p[:y][i]
|
y[j], y[j+1] = p[:y][i], p[:y][i]
|
||||||
else
|
else
|
||||||
@ -496,13 +496,13 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true,
|
|||||||
GR.polyline(x, y)
|
GR.polyline(x, y)
|
||||||
end
|
end
|
||||||
legend = true
|
legend = true
|
||||||
elseif lt == :sticks
|
elseif st == :sticks
|
||||||
x, y = p[:x], p[:y]
|
x, y = p[:x], p[:y]
|
||||||
for i = 1:length(y)
|
for i = 1:length(y)
|
||||||
GR.polyline([x[i], x[i]], [ymin, y[i]])
|
GR.polyline([x[i], x[i]], [ymin, y[i]])
|
||||||
end
|
end
|
||||||
legend = true
|
legend = true
|
||||||
elseif lt == :scatter || (p[:markershape] != :none && axes_2d)
|
elseif st == :scatter || (p[:markershape] != :none && axes_2d)
|
||||||
GR.setmarkercolorind(gr_getcolorind(p[:markercolor]))
|
GR.setmarkercolorind(gr_getcolorind(p[:markercolor]))
|
||||||
gr_setmarkershape(p)
|
gr_setmarkershape(p)
|
||||||
if typeof(p[:markersize]) <: Number
|
if typeof(p[:markersize]) <: Number
|
||||||
@ -523,7 +523,7 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true,
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
legend = true
|
legend = true
|
||||||
elseif lt == :bar
|
elseif st == :bar
|
||||||
y = p[:y]
|
y = p[:y]
|
||||||
for i = 1:length(y)
|
for i = 1:length(y)
|
||||||
GR.setfillcolorind(gr_getcolorind(p[:fillcolor]))
|
GR.setfillcolorind(gr_getcolorind(p[:fillcolor]))
|
||||||
@ -533,7 +533,7 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true,
|
|||||||
GR.setfillintstyle(GR.INTSTYLE_HOLLOW)
|
GR.setfillintstyle(GR.INTSTYLE_HOLLOW)
|
||||||
GR.fillrect(i-0.4, i+0.4, max(0, ymin), y[i])
|
GR.fillrect(i-0.4, i+0.4, max(0, ymin), y[i])
|
||||||
end
|
end
|
||||||
elseif lt in [:hist, :density]
|
elseif st in [:hist, :density]
|
||||||
h = Base.hist(p[:y], p[:bins])
|
h = Base.hist(p[:y], p[:bins])
|
||||||
x, y = float(collect(h[1])), float(h[2])
|
x, y = float(collect(h[1])), float(h[2])
|
||||||
for i = 2:length(y)
|
for i = 2:length(y)
|
||||||
@ -544,15 +544,15 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true,
|
|||||||
GR.setfillintstyle(GR.INTSTYLE_HOLLOW)
|
GR.setfillintstyle(GR.INTSTYLE_HOLLOW)
|
||||||
GR.fillrect(x[i-1], x[i], ymin, y[i])
|
GR.fillrect(x[i-1], x[i], ymin, y[i])
|
||||||
end
|
end
|
||||||
elseif lt in [:hline, :vline]
|
elseif st in [:hline, :vline]
|
||||||
for xy in p[:y]
|
for xy in p[:y]
|
||||||
if lt == :hline
|
if st == :hline
|
||||||
GR.polyline([xmin, xmax], [xy, xy])
|
GR.polyline([xmin, xmax], [xy, xy])
|
||||||
else
|
else
|
||||||
GR.polyline([xy, xy], [ymin, ymax])
|
GR.polyline([xy, xy], [ymin, ymax])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif lt in [:hist2d, :hexbin]
|
elseif st in [:hist2d, :hexbin]
|
||||||
E = zeros(length(p[:x]),2)
|
E = zeros(length(p[:x]),2)
|
||||||
E[:,1] = p[:x]
|
E[:,1] = p[:x]
|
||||||
E[:,2] = p[:y]
|
E[:,2] = p[:y]
|
||||||
@ -573,7 +573,7 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true,
|
|||||||
charheight = max(0.016 * diag, 0.01)
|
charheight = max(0.016 * diag, 0.01)
|
||||||
GR.setcharheight(charheight)
|
GR.setcharheight(charheight)
|
||||||
GR.colormap()
|
GR.colormap()
|
||||||
elseif lt == :contour
|
elseif st == :contour
|
||||||
x, y, z = p[:x], p[:y], transpose_z(p, p[:z].surf, false)
|
x, y, z = p[:x], p[:y], transpose_z(p, p[:z].surf, false)
|
||||||
zmin, zmax = gr_getzlims(d, minimum(z), maximum(z), false)
|
zmin, zmax = gr_getzlims(d, minimum(z), maximum(z), false)
|
||||||
GR.setspace(zmin, zmax, 0, 90)
|
GR.setspace(zmin, zmax, 0, 90)
|
||||||
@ -593,7 +593,7 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true,
|
|||||||
charheight = max(0.016 * diag, 0.01)
|
charheight = max(0.016 * diag, 0.01)
|
||||||
GR.setcharheight(charheight)
|
GR.setcharheight(charheight)
|
||||||
GR.axes(0, ztick, xmax, zmin, 0, 1, 0.005)
|
GR.axes(0, ztick, xmax, zmin, 0, 1, 0.005)
|
||||||
elseif lt in [:surface, :wireframe]
|
elseif st in [:surface, :wireframe]
|
||||||
x, y, z = p[:x], p[:y], transpose_z(p, p[:z].surf, false)
|
x, y, z = p[:x], p[:y], transpose_z(p, p[:z].surf, false)
|
||||||
zmin, zmax = gr_getzlims(d, minimum(z), maximum(z), true)
|
zmin, zmax = gr_getzlims(d, minimum(z), maximum(z), true)
|
||||||
GR.setspace(zmin, zmax, 40, 70)
|
GR.setspace(zmin, zmax, 40, 70)
|
||||||
@ -609,7 +609,7 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true,
|
|||||||
GR.grid3d(0, ytick, 0, xmax, ymin, zmin, 0, 2, 0)
|
GR.grid3d(0, ytick, 0, xmax, ymin, zmin, 0, 2, 0)
|
||||||
end
|
end
|
||||||
z = reshape(z, length(x) * length(y))
|
z = reshape(z, length(x) * length(y))
|
||||||
if lt == :surface
|
if st == :surface
|
||||||
GR.gr3.surface(x, y, z, GR.OPTION_COLORED_MESH)
|
GR.gr3.surface(x, y, z, GR.OPTION_COLORED_MESH)
|
||||||
else
|
else
|
||||||
GR.setfillcolorind(0)
|
GR.setfillcolorind(0)
|
||||||
@ -624,7 +624,7 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true,
|
|||||||
viewport[3], viewport[4])
|
viewport[3], viewport[4])
|
||||||
GR.colormap()
|
GR.colormap()
|
||||||
end
|
end
|
||||||
elseif lt == :heatmap
|
elseif st == :heatmap
|
||||||
x, y, z = p[:x], p[:y], transpose_z(p, p[:z].surf, false)
|
x, y, z = p[:x], p[:y], transpose_z(p, p[:z].surf, false)
|
||||||
zmin, zmax = gr_getzlims(d, minimum(z), maximum(z), true)
|
zmin, zmax = gr_getzlims(d, minimum(z), maximum(z), true)
|
||||||
GR.setspace(zmin, zmax, 0, 90)
|
GR.setspace(zmin, zmax, 0, 90)
|
||||||
@ -635,7 +635,7 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true,
|
|||||||
viewport[3], viewport[4])
|
viewport[3], viewport[4])
|
||||||
GR.colormap()
|
GR.colormap()
|
||||||
end
|
end
|
||||||
elseif lt in [:path3d, :scatter3d]
|
elseif st in [:path3d, :scatter3d]
|
||||||
x, y, z = p[:x], p[:y], p[:z]
|
x, y, z = p[:x], p[:y], p[:z]
|
||||||
zmin, zmax = gr_getzlims(d, minimum(z), maximum(z), true)
|
zmin, zmax = gr_getzlims(d, minimum(z), maximum(z), true)
|
||||||
GR.setspace(zmin, zmax, 40, 70)
|
GR.setspace(zmin, zmax, 40, 70)
|
||||||
@ -646,11 +646,11 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true,
|
|||||||
charheight = max(0.018 * diag, 0.01)
|
charheight = max(0.018 * diag, 0.01)
|
||||||
ticksize = 0.01 * (viewport[2] - viewport[1])
|
ticksize = 0.01 * (viewport[2] - viewport[1])
|
||||||
GR.setlinewidth(1)
|
GR.setlinewidth(1)
|
||||||
if grid_flag && lt == :path3d
|
if grid_flag && st == :path3d
|
||||||
GR.grid3d(xtick, 0, ztick, xmin, ymin, zmin, 2, 0, 2)
|
GR.grid3d(xtick, 0, ztick, xmin, ymin, zmin, 2, 0, 2)
|
||||||
GR.grid3d(0, ytick, 0, xmax, ymin, zmin, 0, 2, 0)
|
GR.grid3d(0, ytick, 0, xmax, ymin, zmin, 0, 2, 0)
|
||||||
end
|
end
|
||||||
if lt == :scatter3d
|
if st == :scatter3d
|
||||||
GR.setmarkercolorind(gr_getcolorind(p[:markercolor]))
|
GR.setmarkercolorind(gr_getcolorind(p[:markercolor]))
|
||||||
gr_setmarkershape(p)
|
gr_setmarkershape(p)
|
||||||
for i = 1:length(z)
|
for i = 1:length(z)
|
||||||
@ -667,7 +667,7 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true,
|
|||||||
GR.setcharheight(charheight)
|
GR.setcharheight(charheight)
|
||||||
GR.axes3d(xtick, 0, ztick, xmin, ymin, zmin, 2, 0, 2, -ticksize)
|
GR.axes3d(xtick, 0, ztick, xmin, ymin, zmin, 2, 0, 2, -ticksize)
|
||||||
GR.axes3d(0, ytick, 0, xmax, ymin, zmin, 0, 2, 0, ticksize)
|
GR.axes3d(0, ytick, 0, xmax, ymin, zmin, 0, 2, 0, ticksize)
|
||||||
elseif lt == :ohlc
|
elseif st == :ohlc
|
||||||
y = p[:y]
|
y = p[:y]
|
||||||
n = size(y, 1)
|
n = size(y, 1)
|
||||||
ticksize = 0.5 * (xmax - xmin) / n
|
ticksize = 0.5 * (xmax - xmin) / n
|
||||||
@ -676,7 +676,7 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true,
|
|||||||
GR.polyline([i, i], [y[i].low, y[i].high])
|
GR.polyline([i, i], [y[i].low, y[i].high])
|
||||||
GR.polyline([i, i+ticksize], [y[i].close, y[i].close])
|
GR.polyline([i, i+ticksize], [y[i].close, y[i].close])
|
||||||
end
|
end
|
||||||
elseif lt == :pie
|
elseif st == :pie
|
||||||
GR.selntran(0)
|
GR.selntran(0)
|
||||||
GR.setfillintstyle(GR.INTSTYLE_SOLID)
|
GR.setfillintstyle(GR.INTSTYLE_SOLID)
|
||||||
xmin, xmax, ymin, ymax = viewport
|
xmin, xmax, ymin, ymax = viewport
|
||||||
@ -721,7 +721,7 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true,
|
|||||||
a1 = a2
|
a1 = a2
|
||||||
end
|
end
|
||||||
GR.selntran(1)
|
GR.selntran(1)
|
||||||
elseif lt == :polar
|
elseif st == :polar
|
||||||
xmin, xmax, ymin, ymax = viewport
|
xmin, xmax, ymin, ymax = viewport
|
||||||
ymax -= 0.05 * (xmax - xmin)
|
ymax -= 0.05 * (xmax - xmin)
|
||||||
xcenter = 0.5 * (xmin + xmax)
|
xcenter = 0.5 * (xmin + xmax)
|
||||||
@ -772,7 +772,7 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true,
|
|||||||
GR.setfillintstyle(GR.INTSTYLE_SOLID)
|
GR.setfillintstyle(GR.INTSTYLE_SOLID)
|
||||||
GR.setfillcolorind(gr_getcolorind(d[:background_color_legend]))
|
GR.setfillcolorind(gr_getcolorind(d[:background_color_legend]))
|
||||||
GR.fillrect(px - 0.08, px + w + 0.02, py + dy, py - dy * n)
|
GR.fillrect(px - 0.08, px + w + 0.02, py + dy, py - dy * n)
|
||||||
GR.setlinetype(1)
|
GR.setseriestype(1)
|
||||||
GR.setlinewidth(1)
|
GR.setlinewidth(1)
|
||||||
GR.drawrect(px - 0.08, px + w + 0.02, py + dy, py - dy * n)
|
GR.drawrect(px - 0.08, px + w + 0.02, py + dy, py - dy * n)
|
||||||
i = 0
|
i = 0
|
||||||
@ -781,15 +781,15 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true,
|
|||||||
continue
|
continue
|
||||||
end
|
end
|
||||||
GR.setlinewidth(p[:linewidth])
|
GR.setlinewidth(p[:linewidth])
|
||||||
if p[:linetype] in [:path, :line, :steppre, :steppost, :sticks]
|
if p[:seriestype] in [:path, :line, :steppre, :steppost, :sticks]
|
||||||
GR.setlinecolorind(gr_getcolorind(p[:linecolor]))
|
GR.setlinecolorind(gr_getcolorind(p[:linecolor]))
|
||||||
GR.setlinetype(gr_linetype[p[:linestyle]])
|
GR.setseriestype(gr_seriestype[p[:linestyle]])
|
||||||
GR.polyline([px - 0.07, px - 0.01], [py, py])
|
GR.polyline([px - 0.07, px - 0.01], [py, py])
|
||||||
end
|
end
|
||||||
if p[:linetype] == :scatter || p[:markershape] != :none
|
if p[:seriestype] == :scatter || p[:markershape] != :none
|
||||||
GR.setmarkercolorind(gr_getcolorind(p[:markercolor]))
|
GR.setmarkercolorind(gr_getcolorind(p[:markercolor]))
|
||||||
gr_setmarkershape(p)
|
gr_setmarkershape(p)
|
||||||
if p[:linetype] in [:path, :line, :steppre, :steppost, :sticks]
|
if p[:seriestype] in [:path, :line, :steppre, :steppost, :sticks]
|
||||||
gr_polymarker(p, [px - 0.06, px - 0.02], [py, py])
|
gr_polymarker(p, [px - 0.06, px - 0.02], [py, py])
|
||||||
else
|
else
|
||||||
gr_polymarker(p, [px - 0.06, px - 0.04, px - 0.02], [py, py, py])
|
gr_polymarker(p, [px - 0.06, px - 0.04, px - 0.02], [py, py, py])
|
||||||
|
|||||||
@ -17,7 +17,7 @@ supportedArgs(::PGFPlotsBackend) = [
|
|||||||
:seriescolor, :seriesalpha,
|
:seriescolor, :seriesalpha,
|
||||||
:linecolor,
|
:linecolor,
|
||||||
:linestyle,
|
:linestyle,
|
||||||
:linetype,
|
:seriestype,
|
||||||
:linewidth,
|
:linewidth,
|
||||||
:linealpha,
|
:linealpha,
|
||||||
:markershape,
|
:markershape,
|
||||||
@ -184,7 +184,7 @@ function _pgfplots_get_plot_kwargs(plt)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function _pgfplots_axis(plt_series)
|
function _pgfplots_axis(plt_series)
|
||||||
line_type = plt_series[:linetype]
|
line_type = plt_series[:seriestype]
|
||||||
plt_kwargs = _pgfplots_get_plot_kwargs(plt_series)
|
plt_kwargs = _pgfplots_get_plot_kwargs(plt_series)
|
||||||
if line_type == :path
|
if line_type == :path
|
||||||
PGFPlots.Linear(plt_series[:x], plt_series[:y]; plt_kwargs...)
|
PGFPlots.Linear(plt_series[:x], plt_series[:y]; plt_kwargs...)
|
||||||
|
|||||||
@ -9,7 +9,7 @@ supportedArgs(::PlotlyBackend) = [
|
|||||||
# :foreground_color_text, :foreground_color_border,
|
# :foreground_color_text, :foreground_color_border,
|
||||||
:group,
|
:group,
|
||||||
:label,
|
:label,
|
||||||
:linetype,
|
:seriestype,
|
||||||
:seriescolor, :seriesalpha,
|
:seriescolor, :seriesalpha,
|
||||||
:linecolor, :linestyle, :linewidth, :linealpha,
|
:linecolor, :linestyle, :linewidth, :linealpha,
|
||||||
:markershape, :markercolor, :markersize, :markeralpha,
|
:markershape, :markercolor, :markersize, :markeralpha,
|
||||||
@ -323,7 +323,7 @@ function plotly_layout(d::KW, seriesargs::AVec{KW})
|
|||||||
# # arrows
|
# # arrows
|
||||||
# for sargs in seriesargs
|
# for sargs in seriesargs
|
||||||
# a = sargs[:arrow]
|
# a = sargs[:arrow]
|
||||||
# if sargs[:linetype] in (:path, :line) && typeof(a) <: Arrow
|
# if sargs[:seriestype] in (:path, :line) && typeof(a) <: Arrow
|
||||||
# add_arrows(sargs[:x], sargs[:y]) do xyprev, xy
|
# add_arrows(sargs[:x], sargs[:y]) do xyprev, xy
|
||||||
# push!(d_out[:annotations], get_annotation_dict_for_arrow(sargs, xyprev, xy, a))
|
# push!(d_out[:annotations], get_annotation_dict_for_arrow(sargs, xyprev, xy, a))
|
||||||
# end
|
# end
|
||||||
@ -367,13 +367,13 @@ function plotly_series(d::KW, plotargs::KW; plot_index = nothing)
|
|||||||
x, y = collect(d[:x]), collect(d[:y])
|
x, y = collect(d[:x]), collect(d[:y])
|
||||||
d_out[:name] = d[:label]
|
d_out[:name] = d[:label]
|
||||||
|
|
||||||
lt = d[:linetype]
|
st = d[:seriestype]
|
||||||
isscatter = lt in (:scatter, :scatter3d)
|
isscatter = st in (:scatter, :scatter3d)
|
||||||
hasmarker = isscatter || d[:markershape] != :none
|
hasmarker = isscatter || d[:markershape] != :none
|
||||||
hasline = !isscatter
|
hasline = !isscatter
|
||||||
|
|
||||||
# set the "type"
|
# set the "type"
|
||||||
if lt in (:line, :path, :scatter, :steppre, :steppost)
|
if st in (:line, :path, :scatter, :steppre, :steppost)
|
||||||
d_out[:type] = "scatter"
|
d_out[:type] = "scatter"
|
||||||
d_out[:mode] = if hasmarker
|
d_out[:mode] = if hasmarker
|
||||||
hasline ? "lines+markers" : "markers"
|
hasline ? "lines+markers" : "markers"
|
||||||
@ -388,11 +388,11 @@ function plotly_series(d::KW, plotargs::KW; plot_index = nothing)
|
|||||||
end
|
end
|
||||||
d_out[:x], d_out[:y] = x, y
|
d_out[:x], d_out[:y] = x, y
|
||||||
|
|
||||||
elseif lt == :bar
|
elseif st == :bar
|
||||||
d_out[:type] = "bar"
|
d_out[:type] = "bar"
|
||||||
d_out[:x], d_out[:y] = x, y
|
d_out[:x], d_out[:y] = x, y
|
||||||
|
|
||||||
elseif lt == :hist2d
|
elseif st == :hist2d
|
||||||
d_out[:type] = "histogram2d"
|
d_out[:type] = "histogram2d"
|
||||||
d_out[:x], d_out[:y] = x, y
|
d_out[:x], d_out[:y] = x, y
|
||||||
if isa(d[:bins], Tuple)
|
if isa(d[:bins], Tuple)
|
||||||
@ -403,22 +403,22 @@ function plotly_series(d::KW, plotargs::KW; plot_index = nothing)
|
|||||||
d_out[:nbinsx] = xbins
|
d_out[:nbinsx] = xbins
|
||||||
d_out[:nbinsy] = ybins
|
d_out[:nbinsy] = ybins
|
||||||
|
|
||||||
elseif lt in (:hist, :density)
|
elseif st in (:hist, :density)
|
||||||
d_out[:type] = "histogram"
|
d_out[:type] = "histogram"
|
||||||
isvert = isvertical(d)
|
isvert = isvertical(d)
|
||||||
d_out[isvert ? :x : :y] = y
|
d_out[isvert ? :x : :y] = y
|
||||||
d_out[isvert ? :nbinsx : :nbinsy] = d[:bins]
|
d_out[isvert ? :nbinsx : :nbinsy] = d[:bins]
|
||||||
if lt == :density
|
if st == :density
|
||||||
d_out[:histnorm] = "probability density"
|
d_out[:histnorm] = "probability density"
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif lt == :heatmap
|
elseif st == :heatmap
|
||||||
d_out[:type] = "heatmap"
|
d_out[:type] = "heatmap"
|
||||||
d_out[:x], d_out[:y] = x, y
|
d_out[:x], d_out[:y] = x, y
|
||||||
d_out[:z] = d[:z].surf
|
d_out[:z] = d[:z].surf
|
||||||
d_out[:colorscale] = plotly_colorscale(d[:fillcolor], d[:fillalpha])
|
d_out[:colorscale] = plotly_colorscale(d[:fillcolor], d[:fillalpha])
|
||||||
|
|
||||||
elseif lt == :contour
|
elseif st == :contour
|
||||||
d_out[:type] = "contour"
|
d_out[:type] = "contour"
|
||||||
d_out[:x], d_out[:y] = x, y
|
d_out[:x], d_out[:y] = x, y
|
||||||
d_out[:z] = d[:z].surf
|
d_out[:z] = d[:z].surf
|
||||||
@ -427,19 +427,19 @@ function plotly_series(d::KW, plotargs::KW; plot_index = nothing)
|
|||||||
d_out[:contours] = KW(:coloring => d[:fillrange] != nothing ? "fill" : "lines")
|
d_out[:contours] = KW(:coloring => d[:fillrange] != nothing ? "fill" : "lines")
|
||||||
d_out[:colorscale] = plotly_colorscale(d[:linecolor], d[:linealpha])
|
d_out[:colorscale] = plotly_colorscale(d[:linecolor], d[:linealpha])
|
||||||
|
|
||||||
elseif lt in (:surface, :wireframe)
|
elseif st in (:surface, :wireframe)
|
||||||
d_out[:type] = "surface"
|
d_out[:type] = "surface"
|
||||||
d_out[:x], d_out[:y] = x, y
|
d_out[:x], d_out[:y] = x, y
|
||||||
d_out[:z] = d[:z].surf
|
d_out[:z] = d[:z].surf
|
||||||
d_out[:colorscale] = plotly_colorscale(d[:fillcolor], d[:fillalpha])
|
d_out[:colorscale] = plotly_colorscale(d[:fillcolor], d[:fillalpha])
|
||||||
|
|
||||||
elseif lt == :pie
|
elseif st == :pie
|
||||||
d_out[:type] = "pie"
|
d_out[:type] = "pie"
|
||||||
d_out[:labels] = x
|
d_out[:labels] = x
|
||||||
d_out[:values] = y
|
d_out[:values] = y
|
||||||
d_out[:hoverinfo] = "label+percent+name"
|
d_out[:hoverinfo] = "label+percent+name"
|
||||||
|
|
||||||
elseif lt in (:path3d, :scatter3d)
|
elseif st in (:path3d, :scatter3d)
|
||||||
d_out[:type] = "scatter3d"
|
d_out[:type] = "scatter3d"
|
||||||
d_out[:mode] = if hasmarker
|
d_out[:mode] = if hasmarker
|
||||||
hasline ? "lines+markers" : "markers"
|
hasline ? "lines+markers" : "markers"
|
||||||
@ -450,7 +450,7 @@ function plotly_series(d::KW, plotargs::KW; plot_index = nothing)
|
|||||||
d_out[:z] = collect(d[:z])
|
d_out[:z] = collect(d[:z])
|
||||||
|
|
||||||
else
|
else
|
||||||
warn("Plotly: linetype $lt isn't supported.")
|
warn("Plotly: seriestype $st isn't supported.")
|
||||||
return KW()
|
return KW()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -484,9 +484,9 @@ function plotly_series(d::KW, plotargs::KW; plot_index = nothing)
|
|||||||
d_out[:line] = KW(
|
d_out[:line] = KW(
|
||||||
:color => webcolor(d[:linecolor], d[:linealpha]),
|
:color => webcolor(d[:linecolor], d[:linealpha]),
|
||||||
:width => d[:linewidth],
|
:width => d[:linewidth],
|
||||||
:shape => if lt == :steppre
|
:shape => if st == :steppre
|
||||||
"vh"
|
"vh"
|
||||||
elseif lt == :steppost
|
elseif st == :steppost
|
||||||
"hv"
|
"hv"
|
||||||
else
|
else
|
||||||
"linear"
|
"linear"
|
||||||
|
|||||||
@ -17,7 +17,7 @@ supportedArgs(::PlotlyJSBackend) = [
|
|||||||
:seriescolor, :seriesalpha,
|
:seriescolor, :seriesalpha,
|
||||||
:linecolor,
|
:linecolor,
|
||||||
:linestyle,
|
:linestyle,
|
||||||
:linetype,
|
:seriestype,
|
||||||
:linewidth,
|
:linewidth,
|
||||||
:linealpha,
|
:linealpha,
|
||||||
:markershape,
|
:markershape,
|
||||||
|
|||||||
@ -10,7 +10,7 @@ supportedArgs(::PyPlotBackend) = [
|
|||||||
:foreground_color_text, :foreground_color_border,
|
:foreground_color_text, :foreground_color_border,
|
||||||
:group,
|
:group,
|
||||||
:label,
|
:label,
|
||||||
:linetype,
|
:seriestype,
|
||||||
:seriescolor, :seriesalpha,
|
:seriescolor, :seriesalpha,
|
||||||
:linecolor, :linestyle, :linewidth, :linealpha,
|
:linecolor, :linestyle, :linewidth, :linealpha,
|
||||||
:markershape, :markercolor, :markersize, :markeralpha,
|
:markershape, :markercolor, :markersize, :markeralpha,
|
||||||
@ -117,8 +117,8 @@ function getPyPlotCustomShading(c, z, α=nothing)
|
|||||||
end
|
end
|
||||||
|
|
||||||
# get the style (solid, dashed, etc)
|
# get the style (solid, dashed, etc)
|
||||||
function getPyPlotLineStyle(linetype::Symbol, linestyle::Symbol)
|
function getPyPlotLineStyle(seriestype::Symbol, linestyle::Symbol)
|
||||||
linetype == :none && return " "
|
seriestype == :none && return " "
|
||||||
linestyle == :solid && return "-"
|
linestyle == :solid && return "-"
|
||||||
linestyle == :dash && return "--"
|
linestyle == :dash && return "--"
|
||||||
linestyle == :dot && return ":"
|
linestyle == :dot && return ":"
|
||||||
@ -197,9 +197,9 @@ function getPyPlotMarker(marker::AbstractString)
|
|||||||
marker
|
marker
|
||||||
end
|
end
|
||||||
|
|
||||||
function getPyPlotStepStyle(linetype::Symbol)
|
function getPyPlotStepStyle(seriestype::Symbol)
|
||||||
linetype == :steppost && return "steps-post"
|
seriestype == :steppost && return "steps-post"
|
||||||
linetype == :steppre && return "steps-pre"
|
seriestype == :steppre && return "steps-pre"
|
||||||
return "default"
|
return "default"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -308,7 +308,7 @@ function pyplot_figure(plotargs::KW)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function pyplot_3d_setup!(wrap, d)
|
function pyplot_3d_setup!(wrap, d)
|
||||||
if trueOrAllTrue(lt -> lt in _3dTypes, get(d, :linetype, :none))
|
if trueOrAllTrue(st -> st in _3dTypes, get(d, :seriestype, :none))
|
||||||
push!(wrap.kwargs, (:projection, "3d"))
|
push!(wrap.kwargs, (:projection, "3d"))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -369,13 +369,13 @@ pymarkercolormap(d::KW) = getPyPlotColorMap(d[:markercolor], d[:markeralpha]
|
|||||||
pyfillcolormap(d::KW) = getPyPlotColorMap(d[:fillcolor], d[:fillalpha])
|
pyfillcolormap(d::KW) = getPyPlotColorMap(d[:fillcolor], d[:fillalpha])
|
||||||
|
|
||||||
function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW)
|
function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW)
|
||||||
lt = d[:linetype]
|
st = d[:seriestype]
|
||||||
if !(lt in supportedTypes(pkg))
|
if !(st in supportedTypes(pkg))
|
||||||
error("linetype $(lt) is unsupported in PyPlot. Choose from: $(supportedTypes(pkg))")
|
error("seriestype $(st) is unsupported in PyPlot. Choose from: $(supportedTypes(pkg))")
|
||||||
end
|
end
|
||||||
|
|
||||||
# 3D plots have a different underlying Axes object in PyPlot
|
# 3D plots have a different underlying Axes object in PyPlot
|
||||||
if lt in _3dTypes && isempty(plt.o.kwargs)
|
if st in _3dTypes && isempty(plt.o.kwargs)
|
||||||
push!(plt.o.kwargs, (:projection, "3d"))
|
push!(plt.o.kwargs, (:projection, "3d"))
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -385,7 +385,7 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW)
|
|||||||
ax = getAxis(plt, d[:axis])
|
ax = getAxis(plt, d[:axis])
|
||||||
x, y, z = d[:x], d[:y], d[:z]
|
x, y, z = d[:x], d[:y], d[:z]
|
||||||
@show typeof((x,y,z))
|
@show typeof((x,y,z))
|
||||||
xyargs = (lt in _3dTypes ? (x,y,z) : (x,y))
|
xyargs = (st in _3dTypes ? (x,y,z) : (x,y))
|
||||||
|
|
||||||
# handle zcolor and get c/cmap
|
# handle zcolor and get c/cmap
|
||||||
extrakw = KW()
|
extrakw = KW()
|
||||||
@ -410,17 +410,17 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW)
|
|||||||
# 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 lt in (:path, :line, :scatter, :path3d, :scatter3d, :steppre, :steppost)
|
if st in (:path, :line, :scatter, :path3d, :scatter3d, :steppre, :steppost)
|
||||||
if d[:linewidth] > 0
|
if d[:linewidth] > 0
|
||||||
handle = ax[:plot](xyargs...;
|
handle = ax[:plot](xyargs...;
|
||||||
label = d[:label],
|
label = d[:label],
|
||||||
zorder = plt.n,
|
zorder = plt.n,
|
||||||
color = pylinecolor(d),
|
color = pylinecolor(d),
|
||||||
linewidth = d[:linewidth],
|
linewidth = d[:linewidth],
|
||||||
linestyle = getPyPlotLineStyle(lt, d[:linestyle]),
|
linestyle = getPyPlotLineStyle(st, d[:linestyle]),
|
||||||
solid_capstyle = "round",
|
solid_capstyle = "round",
|
||||||
# dash_capstyle = "round",
|
# dash_capstyle = "round",
|
||||||
drawstyle = getPyPlotStepStyle(lt)
|
drawstyle = getPyPlotStepStyle(st)
|
||||||
)[1]
|
)[1]
|
||||||
push!(handles, handle)
|
push!(handles, handle)
|
||||||
|
|
||||||
@ -436,7 +436,7 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW)
|
|||||||
:edgecolor => pylinecolor(d),
|
:edgecolor => pylinecolor(d),
|
||||||
:facecolor => pylinecolor(d),
|
:facecolor => pylinecolor(d),
|
||||||
:linewidth => d[:linewidth],
|
:linewidth => d[:linewidth],
|
||||||
:linestyle => getPyPlotLineStyle(lt, d[:linestyle]),
|
:linestyle => getPyPlotLineStyle(st, d[:linestyle]),
|
||||||
)
|
)
|
||||||
add_arrows(x, y) do xyprev, xy
|
add_arrows(x, y) do xyprev, xy
|
||||||
ax[:annotate]("",
|
ax[:annotate]("",
|
||||||
@ -450,7 +450,7 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if lt == :bar
|
if st == :bar
|
||||||
extrakw[isvertical(d) ? :width : :height] = 0.9
|
extrakw[isvertical(d) ? :width : :height] = 0.9
|
||||||
handle = ax[isvertical(d) ? :bar : :barh](x, y;
|
handle = ax[isvertical(d) ? :bar : :barh](x, y;
|
||||||
label = d[:label],
|
label = d[:label],
|
||||||
@ -464,7 +464,7 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW)
|
|||||||
push!(handles, handle)
|
push!(handles, handle)
|
||||||
end
|
end
|
||||||
|
|
||||||
if lt == :sticks
|
if st == :sticks
|
||||||
extrakw[isvertical(d) ? :width : :height] = 0.0
|
extrakw[isvertical(d) ? :width : :height] = 0.0
|
||||||
handle = ax[isvertical(d) ? :bar : :barh](x, y;
|
handle = ax[isvertical(d) ? :bar : :barh](x, y;
|
||||||
label = d[:label],
|
label = d[:label],
|
||||||
@ -479,7 +479,7 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW)
|
|||||||
end
|
end
|
||||||
|
|
||||||
# add markers?
|
# add markers?
|
||||||
if d[:markershape] != :none && lt in (:path, :line, :scatter, :path3d,
|
if d[:markershape] != :none && st in (:path, :line, :scatter, :path3d,
|
||||||
:scatter3d, :steppre, :steppost,
|
:scatter3d, :steppre, :steppost,
|
||||||
:bar, :sticks)
|
:bar, :sticks)
|
||||||
extrakw = KW()
|
extrakw = KW()
|
||||||
@ -490,7 +490,7 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW)
|
|||||||
extrakw[:cmap] = pymarkercolormap(d)
|
extrakw[:cmap] = pymarkercolormap(d)
|
||||||
needs_colorbar = true
|
needs_colorbar = true
|
||||||
end
|
end
|
||||||
xyargs = if lt in (:bar, :sticks) && !isvertical(d)
|
xyargs = if st in (:bar, :sticks) && !isvertical(d)
|
||||||
(y, x)
|
(y, x)
|
||||||
else
|
else
|
||||||
xyargs
|
xyargs
|
||||||
@ -507,7 +507,7 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW)
|
|||||||
push!(handles, handle)
|
push!(handles, handle)
|
||||||
end
|
end
|
||||||
|
|
||||||
if lt == :hist
|
if st == :hist
|
||||||
handle = ax[:hist](y;
|
handle = ax[:hist](y;
|
||||||
label = d[:label],
|
label = d[:label],
|
||||||
zorder = plt.n,
|
zorder = plt.n,
|
||||||
@ -523,7 +523,7 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW)
|
|||||||
push!(handles, handle)
|
push!(handles, handle)
|
||||||
end
|
end
|
||||||
|
|
||||||
if lt == :hist2d
|
if st == :hist2d
|
||||||
handle = ax[:hist2d](x, y;
|
handle = ax[:hist2d](x, y;
|
||||||
label = d[:label],
|
label = d[:label],
|
||||||
zorder = plt.n,
|
zorder = plt.n,
|
||||||
@ -536,7 +536,7 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW)
|
|||||||
needs_colorbar = true
|
needs_colorbar = true
|
||||||
end
|
end
|
||||||
|
|
||||||
if lt == :hexbin
|
if st == :hexbin
|
||||||
handle = ax[:hexbin](x, y;
|
handle = ax[:hexbin](x, y;
|
||||||
label = d[:label],
|
label = d[:label],
|
||||||
zorder = plt.n,
|
zorder = plt.n,
|
||||||
@ -549,25 +549,25 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW)
|
|||||||
needs_colorbar = true
|
needs_colorbar = true
|
||||||
end
|
end
|
||||||
|
|
||||||
if lt in (:hline,:vline)
|
if st in (:hline,:vline)
|
||||||
for yi in d[:y]
|
for yi in d[:y]
|
||||||
func = ax[lt == :hline ? :axhline : :axvline]
|
func = ax[st == :hline ? :axhline : :axvline]
|
||||||
handle = func(yi;
|
handle = func(yi;
|
||||||
linewidth=d[:linewidth],
|
linewidth=d[:linewidth],
|
||||||
color=pylinecolor(d),
|
color=pylinecolor(d),
|
||||||
linestyle=getPyPlotLineStyle(lt, d[:linestyle])
|
linestyle=getPyPlotLineStyle(st, d[:linestyle])
|
||||||
)
|
)
|
||||||
push!(handles, handle)
|
push!(handles, handle)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if lt in (:contour, :contour3d)
|
if st in (:contour, :contour3d)
|
||||||
# z = z.surf'
|
# z = z.surf'
|
||||||
z = transpose_z(d, z.surf)
|
z = transpose_z(d, z.surf)
|
||||||
needs_colorbar = true
|
needs_colorbar = true
|
||||||
|
|
||||||
|
|
||||||
if lt == :contour3d
|
if st == :contour3d
|
||||||
extrakw[:extend3d] = true
|
extrakw[:extend3d] = true
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -576,14 +576,14 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW)
|
|||||||
label = d[:label],
|
label = d[:label],
|
||||||
zorder = plt.n,
|
zorder = plt.n,
|
||||||
linewidths = d[:linewidth],
|
linewidths = d[:linewidth],
|
||||||
linestyles = getPyPlotLineStyle(lt, d[:linestyle]),
|
linestyles = getPyPlotLineStyle(st, d[:linestyle]),
|
||||||
cmap = pylinecolormap(d),
|
cmap = pylinecolormap(d),
|
||||||
extrakw...
|
extrakw...
|
||||||
)
|
)
|
||||||
push!(handles, handle)
|
push!(handles, handle)
|
||||||
|
|
||||||
# contour fills
|
# contour fills
|
||||||
# if lt == :contour
|
# if st == :contour
|
||||||
handle = ax[:contourf](x, y, z, levelargs...;
|
handle = ax[:contourf](x, y, z, levelargs...;
|
||||||
label = d[:label],
|
label = d[:label],
|
||||||
zorder = plt.n + 0.5,
|
zorder = plt.n + 0.5,
|
||||||
@ -594,7 +594,7 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW)
|
|||||||
# end
|
# end
|
||||||
end
|
end
|
||||||
|
|
||||||
if lt in (:surface, :wireframe)
|
if st in (:surface, :wireframe)
|
||||||
if typeof(z) <: AbstractMatrix || typeof(z) <: Surface
|
if typeof(z) <: AbstractMatrix || typeof(z) <: Surface
|
||||||
x, y, z = map(Array, (x,y,z))
|
x, y, z = map(Array, (x,y,z))
|
||||||
if !ismatrix(x) || !ismatrix(y)
|
if !ismatrix(x) || !ismatrix(y)
|
||||||
@ -603,7 +603,7 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW)
|
|||||||
end
|
end
|
||||||
# z = z'
|
# z = z'
|
||||||
z = transpose_z(d, z)
|
z = transpose_z(d, z)
|
||||||
if lt == :surface
|
if st == :surface
|
||||||
if d[:marker_z] != nothing
|
if d[:marker_z] != nothing
|
||||||
extrakw[:facecolors] = getPyPlotCustomShading(d[:fillcolor], d[:marker_z], d[:fillalpha])
|
extrakw[:facecolors] = getPyPlotCustomShading(d[:fillcolor], d[:marker_z], d[:fillalpha])
|
||||||
extrakw[:shade] = false
|
extrakw[:shade] = false
|
||||||
@ -612,7 +612,7 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW)
|
|||||||
needs_colorbar = true
|
needs_colorbar = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
handle = ax[lt == :surface ? :plot_surface : :plot_wireframe](x, y, z;
|
handle = ax[st == :surface ? :plot_surface : :plot_wireframe](x, y, z;
|
||||||
label = d[:label],
|
label = d[:label],
|
||||||
zorder = plt.n,
|
zorder = plt.n,
|
||||||
rstride = 1,
|
rstride = 1,
|
||||||
@ -654,11 +654,11 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW)
|
|||||||
push!(handles, handle)
|
push!(handles, handle)
|
||||||
needs_colorbar = true
|
needs_colorbar = true
|
||||||
else
|
else
|
||||||
error("Unsupported z type $(typeof(z)) for linetype=$lt")
|
error("Unsupported z type $(typeof(z)) for seriestype=$st")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if lt == :image
|
if st == :image
|
||||||
img = Array(transpose_z(d, z.surf))
|
img = Array(transpose_z(d, z.surf))
|
||||||
z = if eltype(img) <: Colors.AbstractGray
|
z = if eltype(img) <: Colors.AbstractGray
|
||||||
float(img)
|
float(img)
|
||||||
@ -673,7 +673,7 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW)
|
|||||||
push!(handles, handle)
|
push!(handles, handle)
|
||||||
end
|
end
|
||||||
|
|
||||||
if lt == :heatmap
|
if st == :heatmap
|
||||||
x, y, z = heatmap_edges(x), heatmap_edges(y), transpose_z(d, z.surf)
|
x, y, z = heatmap_edges(x), heatmap_edges(y), transpose_z(d, z.surf)
|
||||||
if !(eltype(z) <: Number)
|
if !(eltype(z) <: Number)
|
||||||
z, discrete_colorbar_values = indices_and_unique_values(z)
|
z, discrete_colorbar_values = indices_and_unique_values(z)
|
||||||
@ -688,7 +688,7 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW)
|
|||||||
needs_colorbar = true
|
needs_colorbar = true
|
||||||
end
|
end
|
||||||
|
|
||||||
if lt == :shape
|
if st == :shape
|
||||||
path = buildPyPlotPath(x, y)
|
path = buildPyPlotPath(x, y)
|
||||||
patches = pypatches.pymember("PathPatch")(path;
|
patches = pypatches.pymember("PathPatch")(path;
|
||||||
label = d[:label],
|
label = d[:label],
|
||||||
@ -702,7 +702,7 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW)
|
|||||||
push!(handles, handle)
|
push!(handles, handle)
|
||||||
end
|
end
|
||||||
|
|
||||||
if lt == :pie
|
if st == :pie
|
||||||
handle = ax[:pie](y;
|
handle = ax[:pie](y;
|
||||||
# label = d[:label],
|
# label = d[:label],
|
||||||
# colors = # a vector of colors?
|
# colors = # a vector of colors?
|
||||||
@ -742,7 +742,7 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW)
|
|||||||
|
|
||||||
# handle area filling
|
# handle area filling
|
||||||
fillrange = d[:fillrange]
|
fillrange = d[:fillrange]
|
||||||
if fillrange != nothing && lt != :contour
|
if fillrange != nothing && st != :contour
|
||||||
f, dim1, dim2 = if isvertical(d)
|
f, dim1, dim2 = if isvertical(d)
|
||||||
:fill_between, x, y
|
:fill_between, x, y
|
||||||
else
|
else
|
||||||
@ -1106,7 +1106,7 @@ function addPyPlotLegend(plt::Plot, ax)
|
|||||||
leg = plt.plotargs[:legend]
|
leg = plt.plotargs[:legend]
|
||||||
if leg != :none
|
if leg != :none
|
||||||
# gotta do this to ensure both axes are included
|
# gotta do this to ensure both axes are included
|
||||||
args = filter(x -> !(x[:linetype] in (
|
args = filter(x -> !(x[:seriestype] in (
|
||||||
:hist,:density,:hexbin,:hist2d,:hline,:vline,
|
:hist,:density,:hexbin,:hist2d,:hline,:vline,
|
||||||
:contour,:contour3d,:surface,:wireframe,
|
:contour,:contour3d,:surface,:wireframe,
|
||||||
:heatmap,:path3d,:scatter3d, :pie, :image
|
:heatmap,:path3d,:scatter3d, :pie, :image
|
||||||
|
|||||||
@ -17,7 +17,7 @@ supportedArgs(::QwtBackend) = [
|
|||||||
:legend,
|
:legend,
|
||||||
:seriescolor, :seriesalpha,
|
:seriescolor, :seriesalpha,
|
||||||
:linestyle,
|
:linestyle,
|
||||||
:linetype,
|
:seriestype,
|
||||||
:linewidth,
|
:linewidth,
|
||||||
:markershape,
|
:markershape,
|
||||||
:markercolor,
|
:markercolor,
|
||||||
@ -91,29 +91,29 @@ end
|
|||||||
|
|
||||||
function adjustQwtKeywords(plt::Plot{QwtBackend}, iscreating::Bool; kw...)
|
function adjustQwtKeywords(plt::Plot{QwtBackend}, iscreating::Bool; kw...)
|
||||||
d = KW(kw)
|
d = KW(kw)
|
||||||
lt = d[:linetype]
|
st = d[:seriestype]
|
||||||
if lt == :scatter
|
if st == :scatter
|
||||||
d[:linetype] = :none
|
d[:seriestype] = :none
|
||||||
if d[:markershape] == :none
|
if d[:markershape] == :none
|
||||||
d[:markershape] = :ellipse
|
d[:markershape] = :ellipse
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif lt in (:hline, :vline)
|
elseif st in (:hline, :vline)
|
||||||
addLineMarker(plt, d)
|
addLineMarker(plt, d)
|
||||||
d[:linetype] = :none
|
d[:seriestype] = :none
|
||||||
d[:markershape] = :ellipse
|
d[:markershape] = :ellipse
|
||||||
d[:markersize] = 1
|
d[:markersize] = 1
|
||||||
if lt == :vline
|
if st == :vline
|
||||||
d[:x], d[:y] = d[:y], d[:x]
|
d[:x], d[:y] = d[:y], d[:x]
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif !iscreating && lt == :bar
|
elseif !iscreating && st == :bar
|
||||||
d = barHack(; kw...)
|
d = barHack(; kw...)
|
||||||
elseif !iscreating && lt == :hist
|
elseif !iscreating && st == :hist
|
||||||
d = barHack(; histogramHack(; kw...)...)
|
d = barHack(; histogramHack(; kw...)...)
|
||||||
end
|
end
|
||||||
|
|
||||||
replaceQwtAliases(d, :linetype)
|
replaceQwtAliases(d, :seriestype)
|
||||||
replaceQwtAliases(d, :markershape)
|
replaceQwtAliases(d, :markershape)
|
||||||
|
|
||||||
for k in keys(d)
|
for k in keys(d)
|
||||||
@ -208,7 +208,7 @@ end
|
|||||||
function addLineMarker(plt::Plot{QwtBackend}, d::KW)
|
function addLineMarker(plt::Plot{QwtBackend}, d::KW)
|
||||||
for yi in d[:y]
|
for yi in d[:y]
|
||||||
marker = Qwt.QWT.QwtPlotMarker()
|
marker = Qwt.QWT.QwtPlotMarker()
|
||||||
ishorizontal = (d[:linetype] == :hline)
|
ishorizontal = (d[:seriestype] == :hline)
|
||||||
marker[:setLineStyle](ishorizontal ? 1 : 2)
|
marker[:setLineStyle](ishorizontal ? 1 : 2)
|
||||||
marker[ishorizontal ? :setYValue : :setXValue](yi)
|
marker[ishorizontal ? :setYValue : :setXValue](yi)
|
||||||
qcolor = Qwt.convertRGBToQColor(getColor(d[:linecolor]))
|
qcolor = Qwt.convertRGBToQColor(getColor(d[:linecolor]))
|
||||||
|
|||||||
@ -24,7 +24,7 @@
|
|||||||
# :background_color, :foreground_color, :color_palette,
|
# :background_color, :foreground_color, :color_palette,
|
||||||
# :group,
|
# :group,
|
||||||
# :label,
|
# :label,
|
||||||
# :linetype,
|
# :seriestype,
|
||||||
# :seriescolor, :seriesalpha,
|
# :seriescolor, :seriesalpha,
|
||||||
# :linecolor, :linestyle, :linewidth, :linealpha,
|
# :linecolor, :linestyle, :linewidth, :linealpha,
|
||||||
# :markershape, :markercolor, :markersize, :markeralpha,
|
# :markershape, :markercolor, :markersize, :markeralpha,
|
||||||
@ -81,7 +81,7 @@
|
|||||||
# :foreground_color_text, :foreground_color_border,
|
# :foreground_color_text, :foreground_color_border,
|
||||||
# :group,
|
# :group,
|
||||||
# :label,
|
# :label,
|
||||||
# :linetype,
|
# :seriestype,
|
||||||
# :seriescolor, :seriesalpha,
|
# :seriescolor, :seriesalpha,
|
||||||
# :linecolor, :linestyle, :linewidth, :linealpha,
|
# :linecolor, :linestyle, :linewidth, :linealpha,
|
||||||
# :markershape, :markercolor, :markersize, :markeralpha,
|
# :markershape, :markercolor, :markersize, :markeralpha,
|
||||||
@ -129,7 +129,7 @@
|
|||||||
# :background_color, :foreground_color, :color_palette,
|
# :background_color, :foreground_color, :color_palette,
|
||||||
# :group,
|
# :group,
|
||||||
# :label,
|
# :label,
|
||||||
# :linetype,
|
# :seriestype,
|
||||||
# :seriescolor, :seriesalpha,
|
# :seriescolor, :seriesalpha,
|
||||||
# :linecolor, :linestyle, :linewidth, :linealpha,
|
# :linecolor, :linestyle, :linewidth, :linealpha,
|
||||||
# :markershape, :markercolor, :markersize, :markeralpha,
|
# :markershape, :markercolor, :markersize, :markeralpha,
|
||||||
@ -183,7 +183,7 @@
|
|||||||
# :legend,
|
# :legend,
|
||||||
# :seriescolor, :seriesalpha,
|
# :seriescolor, :seriesalpha,
|
||||||
# :linestyle,
|
# :linestyle,
|
||||||
# :linetype,
|
# :seriestype,
|
||||||
# :linewidth,
|
# :linewidth,
|
||||||
# :markershape,
|
# :markershape,
|
||||||
# :markercolor,
|
# :markercolor,
|
||||||
@ -235,7 +235,7 @@
|
|||||||
# :legend,
|
# :legend,
|
||||||
# :seriescolor, :seriesalpha,
|
# :seriescolor, :seriesalpha,
|
||||||
# :linestyle,
|
# :linestyle,
|
||||||
# :linetype,
|
# :seriestype,
|
||||||
# # :linewidth,
|
# # :linewidth,
|
||||||
# :markershape,
|
# :markershape,
|
||||||
# # :markercolor,
|
# # :markercolor,
|
||||||
@ -300,7 +300,7 @@
|
|||||||
# :legend,
|
# :legend,
|
||||||
# :seriescolor, :seriesalpha,
|
# :seriescolor, :seriesalpha,
|
||||||
# :linestyle,
|
# :linestyle,
|
||||||
# :linetype,
|
# :seriestype,
|
||||||
# :linewidth,
|
# :linewidth,
|
||||||
# :markershape,
|
# :markershape,
|
||||||
# :markercolor,
|
# :markercolor,
|
||||||
@ -362,7 +362,7 @@
|
|||||||
# # :legend,
|
# # :legend,
|
||||||
# :seriescolor, :seriesalpha,
|
# :seriescolor, :seriesalpha,
|
||||||
# :linestyle,
|
# :linestyle,
|
||||||
# :linetype,
|
# :seriestype,
|
||||||
# :linewidth,
|
# :linewidth,
|
||||||
# # :linealpha,
|
# # :linealpha,
|
||||||
# :markershape,
|
# :markershape,
|
||||||
@ -429,7 +429,7 @@
|
|||||||
# :seriescolor, :seriesalpha,
|
# :seriescolor, :seriesalpha,
|
||||||
# :linecolor,
|
# :linecolor,
|
||||||
# :linestyle,
|
# :linestyle,
|
||||||
# :linetype,
|
# :seriestype,
|
||||||
# :linewidth,
|
# :linewidth,
|
||||||
# :linealpha,
|
# :linealpha,
|
||||||
# :markershape,
|
# :markershape,
|
||||||
@ -506,7 +506,7 @@
|
|||||||
# :seriescolor, :seriesalpha,
|
# :seriescolor, :seriesalpha,
|
||||||
# :linecolor,
|
# :linecolor,
|
||||||
# :linestyle,
|
# :linestyle,
|
||||||
# :linetype,
|
# :seriestype,
|
||||||
# :linewidth,
|
# :linewidth,
|
||||||
# :linealpha,
|
# :linealpha,
|
||||||
# :markershape,
|
# :markershape,
|
||||||
@ -581,7 +581,7 @@
|
|||||||
# # :legend,
|
# # :legend,
|
||||||
# # :linecolor,
|
# # :linecolor,
|
||||||
# # :linestyle,
|
# # :linestyle,
|
||||||
# :linetype
|
# :seriestype
|
||||||
# # :seriescolor, :seriesalpha,
|
# # :seriescolor, :seriesalpha,
|
||||||
# # :linewidth,
|
# # :linewidth,
|
||||||
# # :linealpha,
|
# # :linealpha,
|
||||||
@ -648,7 +648,7 @@
|
|||||||
# :seriescolor, :seriesalpha,
|
# :seriescolor, :seriesalpha,
|
||||||
# :linecolor,
|
# :linecolor,
|
||||||
# :linestyle,
|
# :linestyle,
|
||||||
# :linetype,
|
# :seriestype,
|
||||||
# :linewidth,
|
# :linewidth,
|
||||||
# :linealpha,
|
# :linealpha,
|
||||||
# :markershape,
|
# :markershape,
|
||||||
|
|||||||
@ -17,7 +17,7 @@ supportedArgs(::UnicodePlotsBackend) = [
|
|||||||
:legend,
|
:legend,
|
||||||
:seriescolor, :seriesalpha,
|
:seriescolor, :seriesalpha,
|
||||||
:linestyle,
|
:linestyle,
|
||||||
:linetype,
|
:seriestype,
|
||||||
# :linewidth,
|
# :linewidth,
|
||||||
:markershape,
|
:markershape,
|
||||||
# :markercolor,
|
# :markercolor,
|
||||||
@ -133,12 +133,12 @@ end
|
|||||||
function addUnicodeSeries!(o, d::KW, addlegend::Bool, xlim, ylim)
|
function addUnicodeSeries!(o, d::KW, addlegend::Bool, xlim, ylim)
|
||||||
|
|
||||||
# get the function, or special handling for step/bar/hist
|
# get the function, or special handling for step/bar/hist
|
||||||
lt = d[:linetype]
|
st = d[:seriestype]
|
||||||
|
|
||||||
# handle hline/vline separately
|
# handle hline/vline separately
|
||||||
if lt in (:hline,:vline)
|
if st in (:hline,:vline)
|
||||||
for yi in d[:y]
|
for yi in d[:y]
|
||||||
if lt == :hline
|
if st == :hline
|
||||||
UnicodePlots.lineplot!(o, xlim, [yi,yi])
|
UnicodePlots.lineplot!(o, xlim, [yi,yi])
|
||||||
else
|
else
|
||||||
UnicodePlots.lineplot!(o, [yi,yi], ylim)
|
UnicodePlots.lineplot!(o, [yi,yi], ylim)
|
||||||
@ -148,17 +148,17 @@ function addUnicodeSeries!(o, d::KW, addlegend::Bool, xlim, ylim)
|
|||||||
end
|
end
|
||||||
|
|
||||||
stepstyle = :post
|
stepstyle = :post
|
||||||
if lt == :path
|
if st == :path
|
||||||
func = UnicodePlots.lineplot!
|
func = UnicodePlots.lineplot!
|
||||||
elseif lt == :scatter || d[:markershape] != :none
|
elseif st == :scatter || d[:markershape] != :none
|
||||||
func = UnicodePlots.scatterplot!
|
func = UnicodePlots.scatterplot!
|
||||||
elseif lt == :steppost
|
elseif st == :steppost
|
||||||
func = UnicodePlots.stairs!
|
func = UnicodePlots.stairs!
|
||||||
elseif lt == :steppre
|
elseif st == :steppre
|
||||||
func = UnicodePlots.stairs!
|
func = UnicodePlots.stairs!
|
||||||
stepstyle = :pre
|
stepstyle = :pre
|
||||||
else
|
else
|
||||||
error("Linestyle $lt not supported by UnicodePlots")
|
error("Linestyle $st not supported by UnicodePlots")
|
||||||
end
|
end
|
||||||
|
|
||||||
# get the series data and label
|
# get the series data and label
|
||||||
@ -193,9 +193,9 @@ function _create_plot(pkg::UnicodePlotsBackend, d::KW)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function _add_series(::UnicodePlotsBackend, plt::Plot, d::KW)
|
function _add_series(::UnicodePlotsBackend, plt::Plot, d::KW)
|
||||||
if d[:linetype] in (:sticks, :bar)
|
if d[:seriestype] in (:sticks, :bar)
|
||||||
d = barHack(; d...)
|
d = barHack(; d...)
|
||||||
elseif d[:linetype] == :hist
|
elseif d[:seriestype] == :hist
|
||||||
d = barHack(; histogramHack(; d...)...)
|
d = barHack(; histogramHack(; d...)...)
|
||||||
end
|
end
|
||||||
push!(plt.seriesargs, d)
|
push!(plt.seriesargs, d)
|
||||||
|
|||||||
@ -21,7 +21,7 @@ supportedArgs(::WinstonBackend) = [
|
|||||||
:legend,
|
:legend,
|
||||||
:seriescolor, :seriesalpha,
|
:seriescolor, :seriesalpha,
|
||||||
:linestyle,
|
:linestyle,
|
||||||
:linetype,
|
:seriestype,
|
||||||
:linewidth,
|
:linewidth,
|
||||||
:markershape,
|
:markershape,
|
||||||
:markercolor,
|
:markercolor,
|
||||||
@ -130,7 +130,7 @@ function _add_series(::WinstonBackend, plt::Plot, d::KW)
|
|||||||
window, canvas, wplt = getWinstonItems(plt)
|
window, canvas, wplt = getWinstonItems(plt)
|
||||||
|
|
||||||
# until we call it normally, do the hack
|
# until we call it normally, do the hack
|
||||||
if d[:linetype] == :bar
|
if d[:seriestype] == :bar
|
||||||
d = barHack(;d...)
|
d = barHack(;d...)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -149,10 +149,10 @@ function _add_series(::WinstonBackend, plt::Plot, d::KW)
|
|||||||
|
|
||||||
|
|
||||||
## lintype :path, :step, :stepinverted, :sticks, :dots, :none, :hist2d, :hexbin, :hist, :bar
|
## lintype :path, :step, :stepinverted, :sticks, :dots, :none, :hist2d, :hexbin, :hist, :bar
|
||||||
if d[:linetype] == :none
|
if d[:seriestype] == :none
|
||||||
Winston.add(wplt, Winston.Points(d[:x], d[:y]; copy_remove(e, :kind)..., color=getColor(d[:markercolor])))
|
Winston.add(wplt, Winston.Points(d[:x], d[:y]; copy_remove(e, :kind)..., color=getColor(d[:markercolor])))
|
||||||
|
|
||||||
elseif d[:linetype] == :path
|
elseif d[:seriestype] == :path
|
||||||
x, y = d[:x], d[:y]
|
x, y = d[:x], d[:y]
|
||||||
Winston.add(wplt, Winston.Curve(x, y; e...))
|
Winston.add(wplt, Winston.Curve(x, y; e...))
|
||||||
|
|
||||||
@ -166,38 +166,38 @@ function _add_series(::WinstonBackend, plt::Plot, d::KW)
|
|||||||
Winston.add(wplt, Winston.FillBetween(x, y, x, y2, fillcolor=getColor(d[:fillcolor])))
|
Winston.add(wplt, Winston.FillBetween(x, y, x, y2, fillcolor=getColor(d[:fillcolor])))
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif d[:linetype] == :scatter
|
elseif d[:seriestype] == :scatter
|
||||||
if d[:markershape] == :none
|
if d[:markershape] == :none
|
||||||
d[:markershape] = :ellipse
|
d[:markershape] = :ellipse
|
||||||
end
|
end
|
||||||
|
|
||||||
# elseif d[:linetype] == :step
|
# elseif d[:seriestype] == :step
|
||||||
# fn = Winston.XXX
|
# fn = Winston.XXX
|
||||||
|
|
||||||
# elseif d[:linetype] == :stepinverted
|
# elseif d[:seriestype] == :stepinverted
|
||||||
# fn = Winston.XXX
|
# fn = Winston.XXX
|
||||||
|
|
||||||
elseif d[:linetype] == :sticks
|
elseif d[:seriestype] == :sticks
|
||||||
Winston.add(wplt, Winston.Stems(d[:x], d[:y]; e...))
|
Winston.add(wplt, Winston.Stems(d[:x], d[:y]; e...))
|
||||||
|
|
||||||
# elseif d[:linetype] == :dots
|
# elseif d[:seriestype] == :dots
|
||||||
# fn = Winston.XXX
|
# fn = Winston.XXX
|
||||||
|
|
||||||
# elseif d[:linetype] == :hist2d
|
# elseif d[:seriestype] == :hist2d
|
||||||
# fn = Winston.XXX
|
# fn = Winston.XXX
|
||||||
|
|
||||||
# elseif d[:linetype] == :hexbin
|
# elseif d[:seriestype] == :hexbin
|
||||||
# fn = Winston.XXX
|
# fn = Winston.XXX
|
||||||
|
|
||||||
elseif d[:linetype] == :hist
|
elseif d[:seriestype] == :hist
|
||||||
hst = hist(d[:y], d[:bins])
|
hst = hist(d[:y], d[:bins])
|
||||||
Winston.add(wplt, Winston.Histogram(hst...; copy_remove(e, :bins)...))
|
Winston.add(wplt, Winston.Histogram(hst...; copy_remove(e, :bins)...))
|
||||||
|
|
||||||
# elseif d[:linetype] == :bar
|
# elseif d[:seriestype] == :bar
|
||||||
# # fn = Winston.XXX
|
# # fn = Winston.XXX
|
||||||
|
|
||||||
else
|
else
|
||||||
error("linetype $(d[:linetype]) not supported by Winston.")
|
error("seriestype $(d[:seriestype]) not supported by Winston.")
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -209,7 +209,7 @@ function _add_series(::WinstonBackend, plt::Plot, d::KW)
|
|||||||
|
|
||||||
|
|
||||||
# optionally add a regression line
|
# optionally add a regression line
|
||||||
d[:smooth] && d[:linetype] != :hist && addRegressionLineWinston(d, wplt)
|
d[:smooth] && d[:seriestype] != :hist && addRegressionLineWinston(d, wplt)
|
||||||
|
|
||||||
push!(plt.seriesargs, d)
|
push!(plt.seriesargs, d)
|
||||||
plt
|
plt
|
||||||
|
|||||||
190
src/plot.jl
190
src/plot.jl
@ -126,21 +126,21 @@ function _add_plotargs!(plt::Plot, d::KW)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# this method recursively applies series recipes when the linetype is not supported
|
# this method recursively applies series recipes when the seriestype is not supported
|
||||||
# natively by the backend
|
# natively by the backend
|
||||||
function _apply_series_recipe(plt::Plot, d::KW)
|
function _apply_series_recipe(plt::Plot, d::KW)
|
||||||
lt = d[:linetype]
|
st = d[:seriestype]
|
||||||
# dumpdict(d, "apply_series_recipe", true)
|
# dumpdict(d, "apply_series_recipe", true)
|
||||||
if lt in supportedTypes()
|
if st in supportedTypes()
|
||||||
# println("adding series!!")
|
# println("adding series!!")
|
||||||
warnOnUnsupported(plt.backend, d)
|
warnOnUnsupported(plt.backend, d)
|
||||||
_add_series(plt.backend, plt, d)
|
_add_series(plt.backend, plt, d)
|
||||||
else
|
else
|
||||||
# get a sub list of series for this linetype
|
# get a sub list of series for this seriestype
|
||||||
series_list = try
|
series_list = try
|
||||||
RecipesBase.apply_recipe(d, Val{lt}, d[:x], d[:y], d[:z])
|
RecipesBase.apply_recipe(d, Val{st}, d[:x], d[:y], d[:z])
|
||||||
catch
|
catch
|
||||||
warn("Exception during apply_recipe(Val{$lt}, ...) with types ($(typeof(d[:x])), $(typeof(d[:y])), $(typeof(d[:z])))")
|
warn("Exception during apply_recipe(Val{$st}, ...) with types ($(typeof(d[:x])), $(typeof(d[:y])), $(typeof(d[:z])))")
|
||||||
rethrow()
|
rethrow()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -159,7 +159,7 @@ function _plot!(plt::Plot, d::KW, args...)
|
|||||||
# just in case the backend needs to set up the plot (make it current or something)
|
# just in case the backend needs to set up the plot (make it current or something)
|
||||||
_before_add_series(plt)
|
_before_add_series(plt)
|
||||||
|
|
||||||
# TODO: the grouping mechanism will be a recipe on a GroupBy object
|
# the grouping mechanism is a recipe on a GroupBy object
|
||||||
# we simply add the GroupBy object to the front of the args list to allow
|
# we simply add the GroupBy object to the front of the args list to allow
|
||||||
# the recipe to be applied
|
# the recipe to be applied
|
||||||
if haskey(d, :group)
|
if haskey(d, :group)
|
||||||
@ -174,7 +174,6 @@ function _plot!(plt::Plot, d::KW, args...)
|
|||||||
else
|
else
|
||||||
delete!(d, :annotation)
|
delete!(d, :annotation)
|
||||||
end
|
end
|
||||||
# anns = annotations(pop!(d, :annotation, [])
|
|
||||||
|
|
||||||
|
|
||||||
# for plotting recipes, swap out the args and update the parameter dictionary
|
# for plotting recipes, swap out the args and update the parameter dictionary
|
||||||
@ -186,41 +185,52 @@ function _plot!(plt::Plot, d::KW, args...)
|
|||||||
kw_list = KW[]
|
kw_list = KW[]
|
||||||
still_to_process = isempty(args) ? [] : [RecipeData(copy(d), args)]
|
still_to_process = isempty(args) ? [] : [RecipeData(copy(d), args)]
|
||||||
while !isempty(still_to_process)
|
while !isempty(still_to_process)
|
||||||
|
|
||||||
|
# grab the first in line to be processed and pass it through apply_recipe
|
||||||
|
# to generate a list of RecipeData objects (data + attributes)
|
||||||
next_series = pop!(still_to_process)
|
next_series = pop!(still_to_process)
|
||||||
series_list = RecipesBase.apply_recipe(next_series.d, next_series.args...)
|
series_list = RecipesBase.apply_recipe(next_series.d, next_series.args...)
|
||||||
for series in series_list
|
for series in series_list
|
||||||
# @show series
|
# @show series
|
||||||
if isempty(series.args)
|
if isempty(series.args)
|
||||||
# finish processing and add to the kw_list
|
# when the arg tuple is empty, that means there's nothing left to recursively
|
||||||
|
# process... finish up and add to the kw_list
|
||||||
kw = series.d
|
kw = series.d
|
||||||
_add_markershape(kw)
|
_add_markershape(kw)
|
||||||
|
|
||||||
|
# if there was a grouping, filter the data here
|
||||||
_filter_input_data!(kw)
|
_filter_input_data!(kw)
|
||||||
|
|
||||||
|
# map marker_z if it's a Function
|
||||||
if isa(get(kw, :marker_z, nothing), Function)
|
if isa(get(kw, :marker_z, nothing), Function)
|
||||||
# TODO: should this take y and/or z as arguments?
|
# TODO: should this take y and/or z as arguments?
|
||||||
kw[:marker_z] = map(kw[:marker_z], kw[:x])
|
kw[:marker_z] = map(kw[:marker_z], kw[:x])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# convert a ribbon into a fillrange
|
||||||
if get(kw, :ribbon, nothing) != nothing
|
if get(kw, :ribbon, nothing) != nothing
|
||||||
rib = kw[:ribbon]
|
rib = kw[:ribbon]
|
||||||
kw[:fillrange] = (kw[:y] - rib, kw[:y] + rib)
|
kw[:fillrange] = (kw[:y] - rib, kw[:y] + rib)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# check that the backend will support the command and add it to the list
|
||||||
warnOnUnsupportedArgs(plt.backend, kw)
|
warnOnUnsupportedArgs(plt.backend, kw)
|
||||||
warnOnUnsupportedScales(plt.backend, kw)
|
warnOnUnsupportedScales(plt.backend, kw)
|
||||||
push!(kw_list, kw)
|
push!(kw_list, kw)
|
||||||
|
|
||||||
# handle error bars
|
# handle error bars by creating new series data... these will have
|
||||||
|
# the same series index as the series they are copied from
|
||||||
for esym in (:xerror, :yerror)
|
for esym in (:xerror, :yerror)
|
||||||
if get(d, esym, nothing) != nothing
|
if get(d, 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[:linetype] = esym
|
errkw[:seriestype] = esym
|
||||||
push!(kw_list, errkw)
|
push!(kw_list, errkw)
|
||||||
# append!(ret, apply_series_recipe(copy(d), Val{esym}))
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
|
# args are non-empty, so there's still processing to do... add it back to the queue
|
||||||
push!(still_to_process, series)
|
push!(still_to_process, series)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -229,93 +239,77 @@ function _plot!(plt::Plot, d::KW, args...)
|
|||||||
# !!! note: at this point, kw_list is fully decomposed into individual series... one KW per series !!!
|
# !!! note: at this point, kw_list is fully decomposed into individual series... one KW per series !!!
|
||||||
|
|
||||||
|
|
||||||
# # # grouping
|
|
||||||
# groupby = if haskey(d, :group)
|
|
||||||
# extractGroupArgs(d[:group], args...)
|
|
||||||
# else
|
|
||||||
# nothing
|
|
||||||
# end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# now include any annotations which were added during recipes
|
# now include any annotations which were added during recipes
|
||||||
# anns = NTuple{3,Any}[]
|
|
||||||
for kw in kw_list
|
for kw in kw_list
|
||||||
append!(anns, annotations(pop!(kw, :annotation, [])))
|
append!(anns, annotations(pop!(kw, :annotation, [])))
|
||||||
end
|
end
|
||||||
# @show anns
|
# @show anns
|
||||||
|
|
||||||
|
|
||||||
|
# merge plot args... this is where we combine all the plot args from the user and
|
||||||
|
# from the recipes... axis info, colors, etc
|
||||||
# TODO: why do i need to check for the subplot key?
|
# TODO: why do i need to check for the subplot key?
|
||||||
|
|
||||||
# merge plot args
|
|
||||||
if !haskey(d, :subplot)
|
if !haskey(d, :subplot)
|
||||||
# merge the plot args from the recipes, then update the plot colors
|
|
||||||
for kw in vcat(kw_list, d)
|
for kw in vcat(kw_list, d)
|
||||||
# @show kw
|
|
||||||
# append!(anns, annotations(pop!(kw, :annotation, [])))
|
|
||||||
_add_plotargs!(plt, kw)
|
_add_plotargs!(plt, kw)
|
||||||
end
|
end
|
||||||
handlePlotColors(plt.backend, plt.plotargs)
|
handlePlotColors(plt.backend, plt.plotargs)
|
||||||
end
|
end
|
||||||
|
|
||||||
# _add_series(plt, d, args...)
|
|
||||||
|
|
||||||
# this is it folks!
|
# this is it folks!
|
||||||
# TODO: we probably shouldn't use i for tracking series index, but rather explicitly track it in recipes
|
# TODO: we probably shouldn't use i for tracking series index, but rather explicitly track it in recipes
|
||||||
for (i,kw) in enumerate(kw_list)
|
for (i,kw) in enumerate(kw_list)
|
||||||
if !(get(kw, :linetype, :none) in (:xerror, :yerror))
|
if !(get(kw, :seriestype, :none) in (:xerror, :yerror))
|
||||||
plt.n += 1
|
plt.n += 1
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: can this be handled as a recipe??
|
# TODO: can this be handled as a recipe?? (yes... need to remove)
|
||||||
# note: this could probably be handled using a recipe signature f{S<:Union{AbstractString,Symbol}}(v::AVec{S}, letter::AbstractString)
|
# note: this could probably be handled using a recipe signature f{S<:Union{AbstractString,Symbol}}(v::AVec{S}, letter::AbstractString)
|
||||||
# that gets called from within the SliceIt section
|
# that gets called from within the SliceIt section
|
||||||
# if !stringsSupported() && di[:linetype] != :pie
|
# if !stringsSupported() && di[:seriestype] != :pie
|
||||||
# setTicksFromStringVector(plt, d, di, "x")
|
# setTicksFromStringVector(plt, d, di, "x")
|
||||||
# setTicksFromStringVector(plt, d, di, "y")
|
# setTicksFromStringVector(plt, d, di, "y")
|
||||||
# setTicksFromStringVector(plt, d, di, "z")
|
# setTicksFromStringVector(plt, d, di, "z")
|
||||||
# end
|
# end
|
||||||
|
|
||||||
# TODO: unnecessary??
|
# TODO: unnecessary?? (yes... deleted as part of _add_plotargs... remove this)
|
||||||
# # remove plot args
|
# # remove plot args
|
||||||
# for k in keys(_plotDefaults)
|
# for k in keys(_plotDefaults)
|
||||||
# delete!(di, k)
|
# delete!(di, k)
|
||||||
# end
|
# end
|
||||||
|
|
||||||
# TODO: why??
|
# TODO: why?? (I think we can remove??)
|
||||||
# # merge in plotarg_overrides
|
# # merge in plotarg_overrides
|
||||||
# plotarg_overrides = pop!(di, :plotarg_overrides, nothing)
|
# plotarg_overrides = pop!(di, :plotarg_overrides, nothing)
|
||||||
# if plotarg_overrides != nothing
|
# if plotarg_overrides != nothing
|
||||||
# merge!(plt.plotargs, plotarg_overrides)
|
# merge!(plt.plotargs, plotarg_overrides)
|
||||||
# end
|
# end
|
||||||
|
|
||||||
# dumpdict(kw, "before add defaults", true)
|
# set default values, select from attribute cycles, and generally set the final attributes
|
||||||
_add_defaults!(kw, plt, i)
|
_add_defaults!(kw, plt, i)
|
||||||
# dumpdict(kw, "after add defaults", true)
|
|
||||||
# getSeriesArgs(plt.backend, getplotargs(plt, n), d, commandIndex, convertSeriesIndex(plt, n), n)
|
|
||||||
|
|
||||||
_replace_linewidth(kw)
|
_replace_linewidth(kw)
|
||||||
|
|
||||||
# todo: while the linetype is not supported, try to apply a recipe of f(Val{lt}, x,y,z) recursively
|
# now we have a fully specified series, with colors chosen. we must recursively handle
|
||||||
# the default should throw an error because we can't handle that linetype
|
# series recipes, which dispatch on seriestype. If a backend does not natively support a seriestype,
|
||||||
|
# we check for a recipe that will convert that series type into one made up of lower-level components.
|
||||||
|
# For example, a histogram is just a bar plot with binned data, a bar plot is really a filled step plot,
|
||||||
|
# and a step plot is really just a path. So any backend that supports drawing a path will implicitly
|
||||||
|
# be able to support step, bar, and histogram plots (and any recipes that use those components).
|
||||||
_apply_series_recipe(plt, kw)
|
_apply_series_recipe(plt, kw)
|
||||||
|
|
||||||
|
|
||||||
# _add_series(plt.backend, plt, kw)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# now that we're done adding all the series, add the annotations
|
||||||
_add_annotations(plt, anns)
|
_add_annotations(plt, anns)
|
||||||
|
|
||||||
# add title, axis labels, ticks, etc
|
# add title, axis labels, ticks, etc
|
||||||
|
# TODO: do we really need this subplot check?
|
||||||
if !haskey(d, :subplot)
|
if !haskey(d, :subplot)
|
||||||
# merge!(plt.plotargs, d) # this shouldn't be needed since we merged the keys earlier
|
# merge!(plt.plotargs, d) # this shouldn't be needed since we merged the keys earlier
|
||||||
_update_plot(plt, plt.plotargs)
|
_update_plot(plt, plt.plotargs)
|
||||||
end
|
end
|
||||||
|
|
||||||
# _update_plot_pos_size(plt, d) # this is only used for Qwt... can we remove?
|
|
||||||
|
|
||||||
current(plt)
|
current(plt)
|
||||||
|
|
||||||
# note: lets ignore the show param and effectively use the semicolon at the end of the REPL statement
|
# note: lets ignore the show param and effectively use the semicolon at the end of the REPL statement
|
||||||
@ -343,7 +337,7 @@ end
|
|||||||
function _replace_linewidth(d::KW)
|
function _replace_linewidth(d::KW)
|
||||||
# get a good default linewidth... 0 for surface and heatmaps
|
# get a good default linewidth... 0 for surface and heatmaps
|
||||||
if get(d, :linewidth, :auto) == :auto
|
if get(d, :linewidth, :auto) == :auto
|
||||||
d[:linewidth] = (get(d, :linetype, :path) in (:surface,:heatmap,:image) ? 0 : 1)
|
d[:linewidth] = (get(d, :seriestype, :path) in (:surface,:heatmap,:image) ? 0 : 1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -379,7 +373,7 @@ end
|
|||||||
# for (i,di) in enumerate(seriesArgList)
|
# for (i,di) in enumerate(seriesArgList)
|
||||||
# plt.n += 1
|
# plt.n += 1
|
||||||
#
|
#
|
||||||
# if !stringsSupported() && di[:linetype] != :pie
|
# if !stringsSupported() && di[:seriestype] != :pie
|
||||||
# setTicksFromStringVector(plt, d, di, "x")
|
# setTicksFromStringVector(plt, d, di, "x")
|
||||||
# setTicksFromStringVector(plt, d, di, "y")
|
# setTicksFromStringVector(plt, d, di, "y")
|
||||||
# setTicksFromStringVector(plt, d, di, "z")
|
# setTicksFromStringVector(plt, d, di, "z")
|
||||||
@ -407,63 +401,63 @@ end
|
|||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
|
|
||||||
function get_indices(orig, labels)
|
# function get_indices(orig, labels)
|
||||||
Int[findnext(labels, l, 1) for l in orig]
|
# Int[findnext(labels, l, 1) for l in orig]
|
||||||
end
|
# end
|
||||||
|
|
||||||
function setTicksFromStringVector(plt::Plot, d::KW, di::KW, letter)
|
# # TODO: remove?? this is the old way of handling discrete data... should be
|
||||||
sym = symbol(letter)
|
# # replaced by the Axis type and logic
|
||||||
ticksym = symbol(letter * "ticks")
|
# function setTicksFromStringVector(plt::Plot, d::KW, di::KW, letter)
|
||||||
pargs = plt.plotargs
|
# sym = symbol(letter)
|
||||||
v = di[sym]
|
# ticksym = symbol(letter * "ticks")
|
||||||
|
# pargs = plt.plotargs
|
||||||
|
# v = di[sym]
|
||||||
|
#
|
||||||
|
# # do we really want to do this?
|
||||||
|
# typeof(v) <: AbstractArray || return
|
||||||
|
# isempty(v) && return
|
||||||
|
# trueOrAllTrue(_ -> typeof(_) <: AbstractString, v) || return
|
||||||
|
#
|
||||||
|
# # compute the ticks and labels
|
||||||
|
# ticks, labels = if ticksType(pargs[ticksym]) == :ticks_and_labels
|
||||||
|
# # extend the existing ticks and labels. only add to labels if they're new!
|
||||||
|
# ticks, labels = pargs[ticksym]
|
||||||
|
# newlabels = filter(_ -> !(_ in labels), unique(v))
|
||||||
|
# newticks = if isempty(ticks)
|
||||||
|
# collect(1:length(newlabels))
|
||||||
|
# else
|
||||||
|
# maximum(ticks) + collect(1:length(newlabels))
|
||||||
|
# end
|
||||||
|
# ticks = vcat(ticks, newticks)
|
||||||
|
# labels = vcat(labels, newlabels)
|
||||||
|
# ticks, labels
|
||||||
|
# else
|
||||||
|
# # create new ticks and labels
|
||||||
|
# newlabels = unique(v)
|
||||||
|
# collect(1:length(newlabels)), newlabels
|
||||||
|
# end
|
||||||
|
#
|
||||||
|
# d[ticksym] = ticks, labels
|
||||||
|
# plt.plotargs[ticksym] = ticks, labels
|
||||||
|
#
|
||||||
|
# # add an origsym field so that later on we can re-compute the x vector if ticks change
|
||||||
|
# origsym = symbol(letter * "orig")
|
||||||
|
# di[origsym] = v
|
||||||
|
# di[sym] = get_indices(v, labels)
|
||||||
|
#
|
||||||
|
# # loop through existing plt.seriesargs and adjust indices if there is an origsym key
|
||||||
|
# for sargs in plt.seriesargs
|
||||||
|
# if haskey(sargs, origsym)
|
||||||
|
# # TODO: might need to call the setindex function instead to trigger a plot update for some backends??
|
||||||
|
# sargs[sym] = get_indices(sargs[origsym], labels)
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
|
||||||
# do we really want to do this?
|
|
||||||
typeof(v) <: AbstractArray || return
|
|
||||||
isempty(v) && return
|
|
||||||
trueOrAllTrue(_ -> typeof(_) <: AbstractString, v) || return
|
|
||||||
|
|
||||||
# compute the ticks and labels
|
|
||||||
ticks, labels = if ticksType(pargs[ticksym]) == :ticks_and_labels
|
|
||||||
# extend the existing ticks and labels. only add to labels if they're new!
|
|
||||||
ticks, labels = pargs[ticksym]
|
|
||||||
newlabels = filter(_ -> !(_ in labels), unique(v))
|
|
||||||
newticks = if isempty(ticks)
|
|
||||||
collect(1:length(newlabels))
|
|
||||||
else
|
|
||||||
maximum(ticks) + collect(1:length(newlabels))
|
|
||||||
end
|
|
||||||
ticks = vcat(ticks, newticks)
|
|
||||||
labels = vcat(labels, newlabels)
|
|
||||||
ticks, labels
|
|
||||||
else
|
|
||||||
# create new ticks and labels
|
|
||||||
newlabels = unique(v)
|
|
||||||
collect(1:length(newlabels)), newlabels
|
|
||||||
end
|
|
||||||
|
|
||||||
d[ticksym] = ticks, labels
|
|
||||||
plt.plotargs[ticksym] = ticks, labels
|
|
||||||
|
|
||||||
# add an origsym field so that later on we can re-compute the x vector if ticks change
|
|
||||||
origsym = symbol(letter * "orig")
|
|
||||||
di[origsym] = v
|
|
||||||
di[sym] = get_indices(v, labels)
|
|
||||||
|
|
||||||
# loop through existing plt.seriesargs and adjust indices if there is an origsym key
|
|
||||||
for sargs in plt.seriesargs
|
|
||||||
if haskey(sargs, origsym)
|
|
||||||
# TODO: might need to call the setindex function instead to trigger a plot update for some backends??
|
|
||||||
sargs[sym] = get_indices(sargs[origsym], labels)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
|
||||||
|
|
||||||
_before_add_series(plt::Plot) = nothing
|
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
|
|
||||||
|
# TODO: remove
|
||||||
# # should we update the x/y label given the meta info during input slicing?
|
# # should we update the x/y label given the meta info during input slicing?
|
||||||
# function updateDictWithMeta(d::KW, plotargs::KW, meta::Symbol, isx::Bool)
|
# function updateDictWithMeta(d::KW, plotargs::KW, meta::Symbol, isx::Bool)
|
||||||
# lsym = isx ? :xlabel : :ylabel
|
# lsym = isx ? :xlabel : :ylabel
|
||||||
|
|||||||
@ -211,10 +211,10 @@ end
|
|||||||
#
|
#
|
||||||
# Returns a Vector{KW}.
|
# Returns a Vector{KW}.
|
||||||
# """
|
# """
|
||||||
# apply_series_recipe(d::KW, lt) = KW[d]
|
# apply_series_recipe(d::KW, st) = KW[d]
|
||||||
|
|
||||||
|
|
||||||
# for linetype `line`, need to sort by x values
|
# for seriestype `line`, need to sort by x values
|
||||||
@recipe function f(::Type{Val{:line}}, x, y, z)
|
@recipe function f(::Type{Val{:line}}, x, y, z)
|
||||||
# order by x
|
# order by x
|
||||||
indices = sortperm(d[:x])
|
indices = sortperm(d[:x])
|
||||||
@ -223,7 +223,7 @@ end
|
|||||||
if typeof(d[:z]) <: AVec
|
if typeof(d[:z]) <: AVec
|
||||||
d[:z] = d[:z][indices]
|
d[:z] = d[:z][indices]
|
||||||
end
|
end
|
||||||
d[:linetype] = :path
|
d[:seriestype] = :path
|
||||||
()
|
()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -266,7 +266,7 @@ const _box_halfwidth = 0.4
|
|||||||
|
|
||||||
# d[:plotarg_overrides] = KW(:xticks => (1:length(shapes), groupby.groupLabels))
|
# d[:plotarg_overrides] = KW(:xticks => (1:length(shapes), groupby.groupLabels))
|
||||||
|
|
||||||
d[:linetype] = :shape
|
d[:seriestype] = :shape
|
||||||
n = length(groupby.groupLabels)
|
n = length(groupby.groupLabels)
|
||||||
xticks --> (linspace(0.5,n-0.5,n), groupby.groupLabels)
|
xticks --> (linspace(0.5,n-0.5,n), groupby.groupLabels)
|
||||||
|
|
||||||
@ -323,7 +323,7 @@ end
|
|||||||
end
|
end
|
||||||
|
|
||||||
# d[:plotarg_overrides] = KW(:xticks => (1:length(shapes), groupby.groupLabels))
|
# d[:plotarg_overrides] = KW(:xticks => (1:length(shapes), groupby.groupLabels))
|
||||||
d[:linetype] = :shape
|
d[:seriestype] = :shape
|
||||||
n = length(groupby.groupLabels)
|
n = length(groupby.groupLabels)
|
||||||
xticks --> (linspace(0.5,n-0.5,n), groupby.groupLabels)
|
xticks --> (linspace(0.5,n-0.5,n), groupby.groupLabels)
|
||||||
|
|
||||||
@ -337,7 +337,7 @@ end
|
|||||||
# Error Bars
|
# Error Bars
|
||||||
|
|
||||||
function error_style!(d::KW)
|
function error_style!(d::KW)
|
||||||
d[:linetype] = :path
|
d[:seriestype] = :path
|
||||||
d[:linecolor] = d[:markerstrokecolor]
|
d[:linecolor] = d[:markerstrokecolor]
|
||||||
d[:linewidth] = d[:markerstrokewidth]
|
d[:linewidth] = d[:markerstrokewidth]
|
||||||
d[:label] = ""
|
d[:label] = ""
|
||||||
@ -401,7 +401,7 @@ end
|
|||||||
# function apply_series_recipe(d::KW, ::Type{Val{:quiver}})
|
# function apply_series_recipe(d::KW, ::Type{Val{:quiver}})
|
||||||
function quiver_using_arrows(d::KW)
|
function quiver_using_arrows(d::KW)
|
||||||
d[:label] = ""
|
d[:label] = ""
|
||||||
d[:linetype] = :path
|
d[:seriestype] = :path
|
||||||
if !isa(d[:arrow], Arrow)
|
if !isa(d[:arrow], Arrow)
|
||||||
d[:arrow] = arrow()
|
d[:arrow] = arrow()
|
||||||
end
|
end
|
||||||
@ -440,7 +440,7 @@ end
|
|||||||
# function apply_series_recipe(d::KW, ::Type{Val{:quiver}})
|
# function apply_series_recipe(d::KW, ::Type{Val{:quiver}})
|
||||||
function quiver_using_hack(d::KW)
|
function quiver_using_hack(d::KW)
|
||||||
d[:label] = ""
|
d[:label] = ""
|
||||||
d[:linetype] = :shape
|
d[:seriestype] = :shape
|
||||||
|
|
||||||
velocity = error_zipit(d[:quiver])
|
velocity = error_zipit(d[:quiver])
|
||||||
xorig, yorig = d[:x], d[:y]
|
xorig, yorig = d[:x], d[:y]
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
typealias FuncOrFuncs @compat(Union{Function, AVec{Function}})
|
typealias FuncOrFuncs @compat(Union{Function, AVec{Function}})
|
||||||
|
|
||||||
all3D(d::KW) = trueOrAllTrue(lt -> lt in (:contour, :heatmap, :surface, :wireframe, :contour3d), get(d, :linetype, :none))
|
all3D(d::KW) = trueOrAllTrue(st -> st in (:contour, :heatmap, :surface, :wireframe, :contour3d), get(d, :seriestype, :none))
|
||||||
|
|
||||||
# missing
|
# missing
|
||||||
convertToAnyVector(v::@compat(Void), d::KW) = Any[nothing], nothing
|
convertToAnyVector(v::@compat(Void), d::KW) = Any[nothing], nothing
|
||||||
@ -142,19 +142,19 @@ compute_xyz(x::Void, y::Void, z::Void) = error("x/y/z are all nothing!")
|
|||||||
# dumpdict(d, "after getSeriesArgs")
|
# dumpdict(d, "after getSeriesArgs")
|
||||||
#
|
#
|
||||||
# d[:x], d[:y], d[:z] = compute_xyz(xs[mod1(i,mx)], ys[mod1(i,my)], zs[mod1(i,mz)])
|
# d[:x], d[:y], d[:z] = compute_xyz(xs[mod1(i,mx)], ys[mod1(i,my)], zs[mod1(i,mz)])
|
||||||
# lt = d[:linetype]
|
# st = d[:seriestype]
|
||||||
#
|
#
|
||||||
# # for linetype `line`, need to sort by x values
|
# # for seriestype `line`, need to sort by x values
|
||||||
# if lt == :line
|
# if st == :line
|
||||||
# # order by x
|
# # order by x
|
||||||
# indices = sortperm(d[:x])
|
# indices = sortperm(d[:x])
|
||||||
# d[:x] = d[:x][indices]
|
# d[:x] = d[:x][indices]
|
||||||
# d[:y] = d[:y][indices]
|
# d[:y] = d[:y][indices]
|
||||||
# d[:linetype] = :path
|
# d[:seriestype] = :path
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# # special handling for missing x in box plot... all the same category
|
# # special handling for missing x in box plot... all the same category
|
||||||
# if lt == :box && xs[mod1(i,mx)] == nothing
|
# if st == :box && xs[mod1(i,mx)] == nothing
|
||||||
# d[:x] = ones(Int, length(d[:y]))
|
# d[:x] = ones(Int, length(d[:y]))
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
@ -187,22 +187,22 @@ compute_xyz(x::Void, y::Void, z::Void) = error("x/y/z are all nothing!")
|
|||||||
# # either a series of velocity vectors are passed in (`:quiver` keyword),
|
# # either a series of velocity vectors are passed in (`:quiver` keyword),
|
||||||
# # or we just add arrows to the path
|
# # or we just add arrows to the path
|
||||||
#
|
#
|
||||||
# # if lt == :quiver
|
# # if st == :quiver
|
||||||
# # d[:linetype] = lt = :path
|
# # d[:seriestype] = st = :path
|
||||||
# # d[:linewidth] = 0
|
# # d[:linewidth] = 0
|
||||||
# # end
|
# # end
|
||||||
# if get(d, :quiver, nothing) != nothing
|
# if get(d, :quiver, nothing) != nothing
|
||||||
# append!(ret, apply_series_recipe(copy(d), Val{:quiver}))
|
# append!(ret, apply_series_recipe(copy(d), Val{:quiver}))
|
||||||
# elseif lt == :quiver
|
# elseif st == :quiver
|
||||||
# d[:linetype] = lt = :path
|
# d[:seriestype] = st = :path
|
||||||
# d[:arrow] = arrow()
|
# d[:arrow] = arrow()
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# # now that we've processed a given series... optionally split into
|
# # now that we've processed a given series... optionally split into
|
||||||
# # multiple dicts through a recipe (for example, a box plot is split into component
|
# # multiple dicts through a recipe (for example, a box plot is split into component
|
||||||
# # parts... polygons, lines, and scatters)
|
# # parts... polygons, lines, and scatters)
|
||||||
# # note: we pass in a Val type (i.e. Val{:box}) so that we can dispatch on the linetype
|
# # note: we pass in a Val type (i.e. Val{:box}) so that we can dispatch on the seriestype
|
||||||
# kwlist = apply_series_recipe(d, Val{lt})
|
# kwlist = apply_series_recipe(d, Val{st})
|
||||||
# append!(ret, kwlist)
|
# append!(ret, kwlist)
|
||||||
#
|
#
|
||||||
# # # add it to our series list
|
# # # add it to our series list
|
||||||
@ -254,12 +254,12 @@ compute_xyz(x::Void, y::Void, z::Void) = error("x/y/z are all nothing!")
|
|||||||
#
|
#
|
||||||
# # images - grays
|
# # images - grays
|
||||||
# function process_inputs{T<:Gray}(plt::AbstractPlot, d::KW, mat::AMat{T})
|
# function process_inputs{T<:Gray}(plt::AbstractPlot, d::KW, mat::AMat{T})
|
||||||
# d[:linetype] = :image
|
# d[:seriestype] = :image
|
||||||
# n,m = size(mat)
|
# n,m = size(mat)
|
||||||
# d[:x], d[:y], d[:z] = 1:n, 1:m, Surface(mat)
|
# d[:x], d[:y], d[:z] = 1:n, 1:m, Surface(mat)
|
||||||
# # handle images... when not supported natively, do a hack to use heatmap machinery
|
# # handle images... when not supported natively, do a hack to use heatmap machinery
|
||||||
# if !nativeImagesSupported()
|
# if !nativeImagesSupported()
|
||||||
# d[:linetype] = :heatmap
|
# d[:seriestype] = :heatmap
|
||||||
# d[:yflip] = true
|
# d[:yflip] = true
|
||||||
# d[:z] = Surface(convert(Matrix{Float64}, mat.surf))
|
# d[:z] = Surface(convert(Matrix{Float64}, mat.surf))
|
||||||
# d[:fillcolor] = ColorGradient([:black, :white])
|
# d[:fillcolor] = ColorGradient([:black, :white])
|
||||||
@ -268,7 +268,7 @@ compute_xyz(x::Void, y::Void, z::Void) = error("x/y/z are all nothing!")
|
|||||||
#
|
#
|
||||||
# # images - colors
|
# # images - colors
|
||||||
# function process_inputs{T<:Colorant}(plt::AbstractPlot, d::KW, mat::AMat{T})
|
# function process_inputs{T<:Colorant}(plt::AbstractPlot, d::KW, mat::AMat{T})
|
||||||
# d[:linetype] = :image
|
# d[:seriestype] = :image
|
||||||
# n,m = size(mat)
|
# n,m = size(mat)
|
||||||
# d[:x], d[:y], d[:z] = 1:n, 1:m, Surface(mat)
|
# d[:x], d[:y], d[:z] = 1:n, 1:m, Surface(mat)
|
||||||
# # handle images... when not supported natively, do a hack to use heatmap machinery
|
# # handle images... when not supported natively, do a hack to use heatmap machinery
|
||||||
@ -282,11 +282,11 @@ compute_xyz(x::Void, y::Void, z::Void) = error("x/y/z are all nothing!")
|
|||||||
# # plotting arbitrary shapes/polygons
|
# # plotting arbitrary shapes/polygons
|
||||||
# function process_inputs(plt::AbstractPlot, d::KW, shape::Shape)
|
# function process_inputs(plt::AbstractPlot, d::KW, shape::Shape)
|
||||||
# d[:x], d[:y] = shape_coords(shape)
|
# d[:x], d[:y] = shape_coords(shape)
|
||||||
# d[:linetype] = :shape
|
# d[:seriestype] = :shape
|
||||||
# end
|
# end
|
||||||
# function process_inputs(plt::AbstractPlot, d::KW, shapes::AVec{Shape})
|
# function process_inputs(plt::AbstractPlot, d::KW, shapes::AVec{Shape})
|
||||||
# d[:x], d[:y] = shape_coords(shapes)
|
# d[:x], d[:y] = shape_coords(shapes)
|
||||||
# d[:linetype] = :shape
|
# d[:seriestype] = :shape
|
||||||
# end
|
# end
|
||||||
# function process_inputs(plt::AbstractPlot, d::KW, shapes::AMat{Shape})
|
# function process_inputs(plt::AbstractPlot, d::KW, shapes::AMat{Shape})
|
||||||
# x, y = [], []
|
# x, y = [], []
|
||||||
@ -296,7 +296,7 @@ compute_xyz(x::Void, y::Void, z::Void) = error("x/y/z are all nothing!")
|
|||||||
# push!(y, tmpy)
|
# push!(y, tmpy)
|
||||||
# end
|
# end
|
||||||
# d[:x], d[:y] = x, y
|
# d[:x], d[:y] = x, y
|
||||||
# d[:linetype] = :shape
|
# d[:seriestype] = :shape
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@ -331,12 +331,12 @@ compute_xyz(x::Void, y::Void, z::Void) = error("x/y/z are all nothing!")
|
|||||||
#
|
#
|
||||||
# # 3d line or scatter
|
# # 3d line or scatter
|
||||||
# function process_inputs(plt::AbstractPlot, d::KW, x::AVec, y::AVec, zvec::AVec)
|
# function process_inputs(plt::AbstractPlot, d::KW, x::AVec, y::AVec, zvec::AVec)
|
||||||
# # default to path3d if we haven't set a 3d linetype
|
# # default to path3d if we haven't set a 3d seriestype
|
||||||
# lt = get(d, :linetype, :none)
|
# st = get(d, :seriestype, :none)
|
||||||
# if lt == :scatter
|
# if st == :scatter
|
||||||
# d[:linetype] = :scatter3d
|
# d[:seriestype] = :scatter3d
|
||||||
# elseif !(lt in _3dTypes)
|
# elseif !(st in _3dTypes)
|
||||||
# d[:linetype] = :path3d
|
# d[:seriestype] = :path3d
|
||||||
# end
|
# end
|
||||||
# d[:x], d[:y], d[:z] = x, y, zvec
|
# d[:x], d[:y], d[:z] = x, y, zvec
|
||||||
# end
|
# end
|
||||||
@ -362,8 +362,8 @@ compute_xyz(x::Void, y::Void, z::Void) = error("x/y/z are all nothing!")
|
|||||||
# # y, zmat = y[idx], zmat[:, idx]
|
# # y, zmat = y[idx], zmat[:, idx]
|
||||||
# # end
|
# # end
|
||||||
# d[:x], d[:y], d[:z] = x, y, Surface{Matrix{TZ}}(zmat)
|
# d[:x], d[:y], d[:z] = x, y, Surface{Matrix{TZ}}(zmat)
|
||||||
# if !like_surface(get(d, :linetype, :none))
|
# if !like_surface(get(d, :seriestype, :none))
|
||||||
# d[:linetype] = :contour
|
# d[:seriestype] = :contour
|
||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
@ -372,8 +372,8 @@ compute_xyz(x::Void, y::Void, z::Void) = error("x/y/z are all nothing!")
|
|||||||
# @assert size(zmat) == size(x) == size(y)
|
# @assert size(zmat) == size(x) == size(y)
|
||||||
# # d[:x], d[:y], d[:z] = Any[x], Any[y], Surface{Matrix{Float64}}(zmat)
|
# # d[:x], d[:y], d[:z] = Any[x], Any[y], Surface{Matrix{Float64}}(zmat)
|
||||||
# d[:x], d[:y], d[:z] = map(Surface{Matrix{Float64}}, (x, y, zmat))
|
# d[:x], d[:y], d[:z] = map(Surface{Matrix{Float64}}, (x, y, zmat))
|
||||||
# if !like_surface(get(d, :linetype, :none))
|
# if !like_surface(get(d, :seriestype, :none))
|
||||||
# d[:linetype] = :contour
|
# d[:seriestype] = :contour
|
||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
|
|||||||
@ -25,8 +25,8 @@ function _add_defaults!(d::KW, plt::Plot, commandIndex::Int)
|
|||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
|
|
||||||
# if haskey(_typeAliases, d[:linetype])
|
# if haskey(_typeAliases, d[:seriestype])
|
||||||
# d[:linetype] = _typeAliases[d[:linetype]]
|
# d[:seriestype] = _typeAliases[d[:seriestype]]
|
||||||
# end
|
# end
|
||||||
|
|
||||||
aliasesAndAutopick(d, :axis, _axesAliases, supportedAxes(pkg), plotIndex)
|
aliasesAndAutopick(d, :axis, _axesAliases, supportedAxes(pkg), plotIndex)
|
||||||
@ -39,7 +39,7 @@ function _add_defaults!(d::KW, plt::Plot, commandIndex::Int)
|
|||||||
# update colors
|
# update colors
|
||||||
for csym in (:linecolor, :markercolor, :fillcolor)
|
for csym in (:linecolor, :markercolor, :fillcolor)
|
||||||
d[csym] = if d[csym] == :match
|
d[csym] = if d[csym] == :match
|
||||||
if has_black_border_for_default(d[:linetype]) && csym == :linecolor
|
if has_black_border_for_default(d[:seriestype]) && csym == :linecolor
|
||||||
:black
|
:black
|
||||||
else
|
else
|
||||||
d[:seriescolor]
|
d[:seriescolor]
|
||||||
@ -62,7 +62,7 @@ function _add_defaults!(d::KW, plt::Plot, commandIndex::Int)
|
|||||||
end
|
end
|
||||||
|
|
||||||
# scatter plots don't have a line, but must have a shape
|
# scatter plots don't have a line, but must have a shape
|
||||||
if d[:linetype] in (:scatter, :scatter3d)
|
if d[:seriestype] in (:scatter, :scatter3d)
|
||||||
d[:linewidth] = 0
|
d[:linewidth] = 0
|
||||||
if d[:markershape] == :none
|
if d[:markershape] == :none
|
||||||
d[:markershape] = :ellipse
|
d[:markershape] = :ellipse
|
||||||
@ -171,12 +171,12 @@ end
|
|||||||
#
|
#
|
||||||
# # images - grays
|
# # images - grays
|
||||||
# function process_inputs{T<:Gray}(plt::AbstractPlot, d::KW, mat::AMat{T})
|
# function process_inputs{T<:Gray}(plt::AbstractPlot, d::KW, mat::AMat{T})
|
||||||
# d[:linetype] = :image
|
# d[:seriestype] = :image
|
||||||
# n,m = size(mat)
|
# n,m = size(mat)
|
||||||
# d[:x], d[:y], d[:z] = 1:n, 1:m, Surface(mat)
|
# d[:x], d[:y], d[:z] = 1:n, 1:m, Surface(mat)
|
||||||
# # handle images... when not supported natively, do a hack to use heatmap machinery
|
# # handle images... when not supported natively, do a hack to use heatmap machinery
|
||||||
# if !nativeImagesSupported()
|
# if !nativeImagesSupported()
|
||||||
# d[:linetype] = :heatmap
|
# d[:seriestype] = :heatmap
|
||||||
# d[:yflip] = true
|
# d[:yflip] = true
|
||||||
# d[:z] = Surface(convert(Matrix{Float64}, mat.surf))
|
# d[:z] = Surface(convert(Matrix{Float64}, mat.surf))
|
||||||
# d[:fillcolor] = ColorGradient([:black, :white])
|
# d[:fillcolor] = ColorGradient([:black, :white])
|
||||||
@ -185,11 +185,11 @@ end
|
|||||||
|
|
||||||
@recipe function f{T<:Gray}(mat::AMat{T})
|
@recipe function f{T<:Gray}(mat::AMat{T})
|
||||||
if nativeImagesSupported()
|
if nativeImagesSupported()
|
||||||
linetype --> :image, force
|
seriestype --> :image, force
|
||||||
n, m = size(mat)
|
n, m = size(mat)
|
||||||
1:n, 1:m, Surface(mat)
|
1:n, 1:m, Surface(mat)
|
||||||
else
|
else
|
||||||
linetype --> :heatmap, force
|
seriestype --> :heatmap, force
|
||||||
yflip --> true
|
yflip --> true
|
||||||
fillcolor --> ColorGradient([:black, :white])
|
fillcolor --> ColorGradient([:black, :white])
|
||||||
1:n, 1:m, Surface(convert(Matrix{Float64}, mat))
|
1:n, 1:m, Surface(convert(Matrix{Float64}, mat))
|
||||||
@ -199,7 +199,7 @@ end
|
|||||||
#
|
#
|
||||||
# # images - colors
|
# # images - colors
|
||||||
# function process_inputs{T<:Colorant}(plt::AbstractPlot, d::KW, mat::AMat{T})
|
# function process_inputs{T<:Colorant}(plt::AbstractPlot, d::KW, mat::AMat{T})
|
||||||
# d[:linetype] = :image
|
# d[:seriestype] = :image
|
||||||
# n,m = size(mat)
|
# n,m = size(mat)
|
||||||
# d[:x], d[:y], d[:z] = 1:n, 1:m, Surface(mat)
|
# d[:x], d[:y], d[:z] = 1:n, 1:m, Surface(mat)
|
||||||
# # handle images... when not supported natively, do a hack to use heatmap machinery
|
# # handle images... when not supported natively, do a hack to use heatmap machinery
|
||||||
@ -212,11 +212,11 @@ end
|
|||||||
|
|
||||||
@recipe function f{T<:Colorant}(mat::AMat{T})
|
@recipe function f{T<:Colorant}(mat::AMat{T})
|
||||||
if nativeImagesSupported()
|
if nativeImagesSupported()
|
||||||
linetype --> :image, force
|
seriestype --> :image, force
|
||||||
n, m = size(mat)
|
n, m = size(mat)
|
||||||
1:n, 1:m, Surface(mat)
|
1:n, 1:m, Surface(mat)
|
||||||
else
|
else
|
||||||
linetype --> :heatmap, force
|
seriestype --> :heatmap, force
|
||||||
yflip --> true
|
yflip --> true
|
||||||
z, d[:fillcolor] = replace_image_with_heatmap(mat)
|
z, d[:fillcolor] = replace_image_with_heatmap(mat)
|
||||||
1:n, 1:m, Surface(z)
|
1:n, 1:m, Surface(z)
|
||||||
@ -227,21 +227,21 @@ end
|
|||||||
# # plotting arbitrary shapes/polygons
|
# # plotting arbitrary shapes/polygons
|
||||||
# function process_inputs(plt::AbstractPlot, d::KW, shape::Shape)
|
# function process_inputs(plt::AbstractPlot, d::KW, shape::Shape)
|
||||||
# d[:x], d[:y] = shape_coords(shape)
|
# d[:x], d[:y] = shape_coords(shape)
|
||||||
# d[:linetype] = :shape
|
# d[:seriestype] = :shape
|
||||||
# end
|
# end
|
||||||
|
|
||||||
@recipe function f(shape::Shape)
|
@recipe function f(shape::Shape)
|
||||||
linetype --> :shape, force
|
seriestype --> :shape, force
|
||||||
shape_coords(shape)
|
shape_coords(shape)
|
||||||
end
|
end
|
||||||
|
|
||||||
# function process_inputs(plt::AbstractPlot, d::KW, shapes::AVec{Shape})
|
# function process_inputs(plt::AbstractPlot, d::KW, shapes::AVec{Shape})
|
||||||
# d[:x], d[:y] = shape_coords(shapes)
|
# d[:x], d[:y] = shape_coords(shapes)
|
||||||
# d[:linetype] = :shape
|
# d[:seriestype] = :shape
|
||||||
# end
|
# end
|
||||||
|
|
||||||
@recipe function f(shapes::AVec{Shape})
|
@recipe function f(shapes::AVec{Shape})
|
||||||
linetype --> :shape, force
|
seriestype --> :shape, force
|
||||||
shape_coords(shapes)
|
shape_coords(shapes)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -253,7 +253,7 @@ end
|
|||||||
# push!(y, tmpy)
|
# push!(y, tmpy)
|
||||||
# end
|
# end
|
||||||
# d[:x], d[:y] = x, y
|
# d[:x], d[:y] = x, y
|
||||||
# d[:linetype] = :shape
|
# d[:seriestype] = :shape
|
||||||
# end
|
# end
|
||||||
|
|
||||||
@recipe function f(shapes::AMat{Shape})
|
@recipe function f(shapes::AMat{Shape})
|
||||||
@ -301,22 +301,22 @@ end
|
|||||||
#
|
#
|
||||||
# # 3d line or scatter
|
# # 3d line or scatter
|
||||||
# function process_inputs(plt::AbstractPlot, d::KW, x::AVec, y::AVec, zvec::AVec)
|
# function process_inputs(plt::AbstractPlot, d::KW, x::AVec, y::AVec, zvec::AVec)
|
||||||
# # default to path3d if we haven't set a 3d linetype
|
# # default to path3d if we haven't set a 3d seriestype
|
||||||
# lt = get(d, :linetype, :none)
|
# st = get(d, :seriestype, :none)
|
||||||
# if lt == :scatter
|
# if st == :scatter
|
||||||
# d[:linetype] = :scatter3d
|
# d[:seriestype] = :scatter3d
|
||||||
# elseif !(lt in _3dTypes)
|
# elseif !(st in _3dTypes)
|
||||||
# d[:linetype] = :path3d
|
# d[:seriestype] = :path3d
|
||||||
# end
|
# end
|
||||||
# d[:x], d[:y], d[:z] = x, y, zvec
|
# d[:x], d[:y], d[:z] = x, y, zvec
|
||||||
# end
|
# end
|
||||||
|
|
||||||
@recipe function f(x::AVec, y::AVec, z::AVec)
|
@recipe function f(x::AVec, y::AVec, z::AVec)
|
||||||
lt = get(d, :linetype, :none)
|
st = get(d, :seriestype, :none)
|
||||||
if lt == :scatter
|
if st == :scatter
|
||||||
d[:linetype] = :scatter3d
|
d[:seriestype] = :scatter3d
|
||||||
elseif !(lt in _3dTypes)
|
elseif !(st in _3dTypes)
|
||||||
d[:linetype] = :path3d
|
d[:seriestype] = :path3d
|
||||||
end
|
end
|
||||||
SliceIt, x, y, z
|
SliceIt, x, y, z
|
||||||
end
|
end
|
||||||
@ -350,14 +350,14 @@ end
|
|||||||
# # y, zmat = y[idx], zmat[:, idx]
|
# # y, zmat = y[idx], zmat[:, idx]
|
||||||
# # end
|
# # end
|
||||||
# d[:x], d[:y], d[:z] = x, y, Surface{Matrix{TZ}}(zmat)
|
# d[:x], d[:y], d[:z] = x, y, Surface{Matrix{TZ}}(zmat)
|
||||||
# if !like_surface(get(d, :linetype, :none))
|
# if !like_surface(get(d, :seriestype, :none))
|
||||||
# d[:linetype] = :contour
|
# d[:seriestype] = :contour
|
||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
|
|
||||||
@recipe function f{X,Y,Z}(x::AVec{X}, y::AVec{Y}, z::AMat{Z})
|
@recipe function f{X,Y,Z}(x::AVec{X}, y::AVec{Y}, z::AMat{Z})
|
||||||
if !like_surface(get(d, :linetype, :none))
|
if !like_surface(get(d, :seriestype, :none))
|
||||||
d[:linetype] = :contour
|
d[:seriestype] = :contour
|
||||||
end
|
end
|
||||||
SliceIt, x, y, Surface{Matrix{Z}}(z)
|
SliceIt, x, y, Surface{Matrix{Z}}(z)
|
||||||
end
|
end
|
||||||
@ -368,8 +368,8 @@ end
|
|||||||
# @assert size(zmat) == size(x) == size(y)
|
# @assert size(zmat) == size(x) == size(y)
|
||||||
# # d[:x], d[:y], d[:z] = Any[x], Any[y], Surface{Matrix{Float64}}(zmat)
|
# # d[:x], d[:y], d[:z] = Any[x], Any[y], Surface{Matrix{Float64}}(zmat)
|
||||||
# d[:x], d[:y], d[:z] = map(Surface{Matrix{Float64}}, (x, y, zmat))
|
# d[:x], d[:y], d[:z] = map(Surface{Matrix{Float64}}, (x, y, zmat))
|
||||||
# if !like_surface(get(d, :linetype, :none))
|
# if !like_surface(get(d, :seriestype, :none))
|
||||||
# d[:linetype] = :contour
|
# d[:seriestype] = :contour
|
||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
|
|
||||||
|
|||||||
12
src/utils.jl
12
src/utils.jl
@ -25,7 +25,7 @@ function histogramHack(; kw...)
|
|||||||
edges, midpoints, buckets, counts = binData(d[:y], d[:bins])
|
edges, midpoints, buckets, counts = binData(d[:y], d[:bins])
|
||||||
d[:x] = midpoints
|
d[:x] = midpoints
|
||||||
d[:y] = float(counts)
|
d[:y] = float(counts)
|
||||||
d[:linetype] = :bar
|
d[:seriestype] = :bar
|
||||||
d[:fillrange] = d[:fillrange] == nothing ? 0.0 : d[:fillrange]
|
d[:fillrange] = d[:fillrange] == nothing ? 0.0 : d[:fillrange]
|
||||||
d
|
d
|
||||||
end
|
end
|
||||||
@ -64,7 +64,7 @@ function barHack(; kw...)
|
|||||||
|
|
||||||
d[:x] = x
|
d[:x] = x
|
||||||
d[:y] = y
|
d[:y] = y
|
||||||
d[:linetype] = :path
|
d[:seriestype] = :path
|
||||||
d[:fillrange] = fillrange
|
d[:fillrange] = fillrange
|
||||||
d
|
d
|
||||||
end
|
end
|
||||||
@ -94,12 +94,12 @@ function sticksHack(; kw...)
|
|||||||
# change the line args
|
# change the line args
|
||||||
dLine[:x] = x
|
dLine[:x] = x
|
||||||
dLine[:y] = y
|
dLine[:y] = y
|
||||||
dLine[:linetype] = :path
|
dLine[:seriestype] = :path
|
||||||
dLine[:markershape] = :none
|
dLine[:markershape] = :none
|
||||||
dLine[:fillrange] = nothing
|
dLine[:fillrange] = nothing
|
||||||
|
|
||||||
# change the scatter args
|
# change the scatter args
|
||||||
dScatter[:linetype] = :none
|
dScatter[:seriestype] = :none
|
||||||
|
|
||||||
dLine, dScatter
|
dLine, dScatter
|
||||||
end
|
end
|
||||||
@ -132,7 +132,7 @@ end
|
|||||||
|
|
||||||
function imageHack(d::KW)
|
function imageHack(d::KW)
|
||||||
:heatmap in supportedTypes() || error("Neither :image or :heatmap are supported!")
|
:heatmap in supportedTypes() || error("Neither :image or :heatmap are supported!")
|
||||||
d[:linetype] = :heatmap
|
d[:seriestype] = :heatmap
|
||||||
d[:z], d[:fillcolor] = replace_image_with_heatmap(d[:z].surf)
|
d[:z], d[:fillcolor] = replace_image_with_heatmap(d[:z].surf)
|
||||||
end
|
end
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
@ -369,7 +369,7 @@ function with(f::Function, args...; kw...)
|
|||||||
# # as in: with(:gadfly, :scatter, :legend, :grid) do; ...; end
|
# # as in: with(:gadfly, :scatter, :legend, :grid) do; ...; end
|
||||||
# # TODO: can we generalize this enough to also do something similar in the plot commands??
|
# # TODO: can we generalize this enough to also do something similar in the plot commands??
|
||||||
|
|
||||||
# k = :linetype
|
# k = :seriestype
|
||||||
# if arg in _allTypes
|
# if arg in _allTypes
|
||||||
# olddefs[k] = default(k)
|
# olddefs[k] = default(k)
|
||||||
# newdefs[k] = arg
|
# newdefs[k] = arg
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user