z axis args; pyplot z axis; major pyplot cleanup; other cleanup/fixes
This commit is contained in:
parent
0a636b5899
commit
d70f462899
60
src/args.jl
60
src/args.jl
@ -159,6 +159,7 @@ const _plotDefaults = KW()
|
|||||||
_plotDefaults[:title] = ""
|
_plotDefaults[:title] = ""
|
||||||
_plotDefaults[:xlabel] = ""
|
_plotDefaults[:xlabel] = ""
|
||||||
_plotDefaults[:ylabel] = ""
|
_plotDefaults[:ylabel] = ""
|
||||||
|
_plotDefaults[:zlabel] = ""
|
||||||
_plotDefaults[:yrightlabel] = ""
|
_plotDefaults[:yrightlabel] = ""
|
||||||
_plotDefaults[:legend] = :best
|
_plotDefaults[:legend] = :best
|
||||||
_plotDefaults[:colorbar] = :legend
|
_plotDefaults[:colorbar] = :legend
|
||||||
@ -169,10 +170,13 @@ _plotDefaults[:ylims] = :auto
|
|||||||
_plotDefaults[:zlims] = :auto
|
_plotDefaults[:zlims] = :auto
|
||||||
_plotDefaults[:xticks] = :auto
|
_plotDefaults[:xticks] = :auto
|
||||||
_plotDefaults[:yticks] = :auto
|
_plotDefaults[:yticks] = :auto
|
||||||
|
_plotDefaults[:zticks] = :auto
|
||||||
_plotDefaults[:xscale] = :identity
|
_plotDefaults[:xscale] = :identity
|
||||||
_plotDefaults[:yscale] = :identity
|
_plotDefaults[:yscale] = :identity
|
||||||
|
_plotDefaults[:zscale] = :identity
|
||||||
_plotDefaults[:xflip] = false
|
_plotDefaults[:xflip] = false
|
||||||
_plotDefaults[:yflip] = false
|
_plotDefaults[:yflip] = false
|
||||||
|
_plotDefaults[:zflip] = false
|
||||||
_plotDefaults[:size] = (600,400)
|
_plotDefaults[:size] = (600,400)
|
||||||
_plotDefaults[:pos] = (0,0)
|
_plotDefaults[:pos] = (0,0)
|
||||||
_plotDefaults[:windowtitle] = "Plots.jl"
|
_plotDefaults[:windowtitle] = "Plots.jl"
|
||||||
@ -222,7 +226,6 @@ function aliasesAndAutopick(d::KW, sym::Symbol, aliases::KW, options::AVec, plot
|
|||||||
end
|
end
|
||||||
|
|
||||||
function aliases(aliasMap::KW, val)
|
function aliases(aliasMap::KW, val)
|
||||||
# sort(vcat(val, collect(keys(filter((k,v)-> v==val, aliasMap)))))
|
|
||||||
sortedkeys(filter((k,v)-> v==val, aliasMap))
|
sortedkeys(filter((k,v)-> v==val, aliasMap))
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -278,6 +281,7 @@ end
|
|||||||
:annotations => :annotation,
|
:annotations => :annotation,
|
||||||
:xlab => :xlabel,
|
:xlab => :xlabel,
|
||||||
:ylab => :ylabel,
|
:ylab => :ylabel,
|
||||||
|
:zlab => :zlabel,
|
||||||
:yrlab => :yrightlabel,
|
:yrlab => :yrightlabel,
|
||||||
:ylabr => :yrightlabel,
|
:ylabr => :yrightlabel,
|
||||||
:y2lab => :yrightlabel,
|
:y2lab => :yrightlabel,
|
||||||
@ -404,48 +408,47 @@ end
|
|||||||
|
|
||||||
# given one value (:log, or :flip, or (-1,1), etc), set the appropriate arg
|
# given one value (:log, or :flip, or (-1,1), etc), set the appropriate arg
|
||||||
# TODO: use trueOrAllTrue for subplots which can pass vectors for these
|
# TODO: use trueOrAllTrue for subplots which can pass vectors for these
|
||||||
function processAxisArg(d::KW, axisletter::@compat(AbstractString), arg)
|
function processAxisArg(d::KW, letter::AbstractString, arg)
|
||||||
T = typeof(arg)
|
T = typeof(arg)
|
||||||
# if T <: Symbol
|
|
||||||
|
|
||||||
arg = get(_scaleAliases, arg, arg)
|
arg = get(_scaleAliases, arg, arg)
|
||||||
|
scale, flip, label, lim, tick = axis_symbols(letter, "scale", "flip", "label", "lims", "ticks")
|
||||||
|
|
||||||
if arg in _allScales
|
if typeof(arg) <: Font
|
||||||
d[symbol(axisletter * "scale")] = arg
|
d[:tickfont] = arg
|
||||||
|
|
||||||
|
elseif arg in _allScales
|
||||||
|
d[scale] = arg
|
||||||
|
|
||||||
elseif arg in (:flip, :invert, :inverted)
|
elseif arg in (:flip, :invert, :inverted)
|
||||||
d[symbol(axisletter * "flip")] = true
|
d[flip] = true
|
||||||
|
|
||||||
elseif T <: @compat(AbstractString)
|
elseif T <: @compat(AbstractString)
|
||||||
d[symbol(axisletter * "label")] = arg
|
d[label] = arg
|
||||||
|
|
||||||
# xlims/ylims
|
# xlims/ylims
|
||||||
elseif (T <: Tuple || T <: AVec) && length(arg) == 2
|
elseif (T <: Tuple || T <: AVec) && length(arg) == 2
|
||||||
d[symbol(axisletter * "lims")] = arg
|
d[typeof(arg[1]) <: Number ? lim : tick] = arg
|
||||||
|
|
||||||
# xticks/yticks
|
# xticks/yticks
|
||||||
elseif T <: AVec
|
elseif T <: AVec
|
||||||
d[symbol(axisletter * "ticks")] = arg
|
d[tick] = arg
|
||||||
|
|
||||||
elseif arg == nothing
|
elseif arg == nothing
|
||||||
d[symbol(axisletter * "ticks")] = []
|
d[tick] = []
|
||||||
|
|
||||||
else
|
else
|
||||||
warn("Skipped $(axisletter)axis arg $arg")
|
warn("Skipped $(letter)axis arg $arg")
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function processLineArg(d::KW, arg)
|
function processLineArg(d::KW, arg)
|
||||||
|
|
||||||
# linetype
|
# linetype
|
||||||
# if trueOrAllTrue(a -> get(_typeAliases, a, a) in _allTypes, arg)
|
|
||||||
if allLineTypes(arg)
|
if allLineTypes(arg)
|
||||||
d[:linetype] = arg
|
d[:linetype] = arg
|
||||||
|
|
||||||
# linestyle
|
# linestyle
|
||||||
# elseif trueOrAllTrue(a -> get(_styleAliases, a, a) in _allStyles, arg)
|
|
||||||
elseif allStyles(arg)
|
elseif allStyles(arg)
|
||||||
d[:linestyle] = arg
|
d[:linestyle] = arg
|
||||||
|
|
||||||
@ -461,12 +464,10 @@ function processLineArg(d::KW, arg)
|
|||||||
arg.alpha == nothing || (d[:fillalpha] = arg.alpha)
|
arg.alpha == nothing || (d[:fillalpha] = arg.alpha)
|
||||||
|
|
||||||
# linealpha
|
# linealpha
|
||||||
# elseif trueOrAllTrue(a -> typeof(a) <: Real && a > 0 && a < 1, arg)
|
|
||||||
elseif allAlphas(arg)
|
elseif allAlphas(arg)
|
||||||
d[:linealpha] = arg
|
d[:linealpha] = arg
|
||||||
|
|
||||||
# linewidth
|
# linewidth
|
||||||
# elseif trueOrAllTrue(a -> typeof(a) <: Real, arg)
|
|
||||||
elseif allReals(arg)
|
elseif allReals(arg)
|
||||||
d[:linewidth] = arg
|
d[:linewidth] = arg
|
||||||
|
|
||||||
@ -479,17 +480,11 @@ end
|
|||||||
|
|
||||||
|
|
||||||
function processMarkerArg(d::KW, arg)
|
function processMarkerArg(d::KW, arg)
|
||||||
|
|
||||||
# markershape
|
# markershape
|
||||||
# if trueOrAllTrue(a -> get(_markerAliases, a, a) in _allMarkers, arg)
|
|
||||||
# d[:markershape] = arg
|
|
||||||
|
|
||||||
# elseif trueOrAllTrue(a -> isa(a, Shape), arg)
|
|
||||||
if allShapes(arg)
|
if allShapes(arg)
|
||||||
d[:markershape] = arg
|
d[:markershape] = arg
|
||||||
|
|
||||||
# stroke style
|
# stroke style
|
||||||
# elseif trueOrAllTrue(a -> get(_styleAliases, a, a) in _allStyles, arg)
|
|
||||||
elseif allStyles(arg)
|
elseif allStyles(arg)
|
||||||
d[:markerstrokestyle] = arg
|
d[:markerstrokestyle] = arg
|
||||||
|
|
||||||
@ -505,12 +500,10 @@ function processMarkerArg(d::KW, arg)
|
|||||||
arg.alpha == nothing || (d[:markeralpha] = arg.alpha)
|
arg.alpha == nothing || (d[:markeralpha] = arg.alpha)
|
||||||
|
|
||||||
# linealpha
|
# linealpha
|
||||||
# elseif trueOrAllTrue(a -> typeof(a) <: Real && a > 0 && a < 1, arg)
|
|
||||||
elseif allAlphas(arg)
|
elseif allAlphas(arg)
|
||||||
d[:markeralpha] = arg
|
d[:markeralpha] = arg
|
||||||
|
|
||||||
# markersize
|
# markersize
|
||||||
# elseif trueOrAllTrue(a -> typeof(a) <: Real, arg)
|
|
||||||
elseif allReals(arg)
|
elseif allReals(arg)
|
||||||
d[:markersize] = arg
|
d[:markersize] = arg
|
||||||
|
|
||||||
@ -523,19 +516,16 @@ end
|
|||||||
|
|
||||||
|
|
||||||
function processFillArg(d::KW, arg)
|
function processFillArg(d::KW, arg)
|
||||||
|
|
||||||
if typeof(arg) <: Brush
|
if typeof(arg) <: Brush
|
||||||
arg.size == nothing || (d[:fillrange] = arg.size)
|
arg.size == nothing || (d[:fillrange] = arg.size)
|
||||||
arg.color == nothing || (d[:fillcolor] = arg.color == :auto ? :auto : colorscheme(arg.color))
|
arg.color == nothing || (d[:fillcolor] = arg.color == :auto ? :auto : colorscheme(arg.color))
|
||||||
arg.alpha == nothing || (d[:fillalpha] = arg.alpha)
|
arg.alpha == nothing || (d[:fillalpha] = arg.alpha)
|
||||||
|
|
||||||
# fillrange function
|
# fillrange function
|
||||||
# elseif trueOrAllTrue(a -> isa(a, Function), arg)
|
|
||||||
elseif allFunctions(arg)
|
elseif allFunctions(arg)
|
||||||
d[:fillrange] = arg
|
d[:fillrange] = arg
|
||||||
|
|
||||||
# fillalpha
|
# fillalpha
|
||||||
# elseif trueOrAllTrue(a -> typeof(a) <: Real && a > 0 && a < 1, arg)
|
|
||||||
elseif allAlphas(arg)
|
elseif allAlphas(arg)
|
||||||
d[:fillalpha] = arg
|
d[:fillalpha] = arg
|
||||||
|
|
||||||
@ -555,15 +545,15 @@ function preprocessArgs!(d::KW)
|
|||||||
replaceAliases!(d, _keyAliases)
|
replaceAliases!(d, _keyAliases)
|
||||||
|
|
||||||
# handle axis args
|
# handle axis args
|
||||||
for axisletter in ("x", "y")
|
for letter in ("x", "y", "z")
|
||||||
asym = symbol(axisletter * "axis")
|
asym = symbol(letter * "axis")
|
||||||
for arg in wraptuple(get(d, asym, ()))
|
for arg in wraptuple(get(d, asym, ()))
|
||||||
processAxisArg(d, axisletter, arg)
|
processAxisArg(d, letter, arg)
|
||||||
end
|
end
|
||||||
delete!(d, asym)
|
delete!(d, asym)
|
||||||
|
|
||||||
# turn :labels into :ticks_and_labels
|
# turn :labels into :ticks_and_labels
|
||||||
tsym = symbol(axisletter * "ticks")
|
tsym = symbol(letter * "ticks")
|
||||||
if haskey(d, tsym) && ticksType(d[tsym]) == :labels
|
if haskey(d, tsym) && ticksType(d[tsym]) == :labels
|
||||||
d[tsym] = (1:length(d[tsym]), d[tsym])
|
d[tsym] = (1:length(d[tsym]), d[tsym])
|
||||||
end
|
end
|
||||||
@ -582,9 +572,6 @@ function preprocessArgs!(d::KW)
|
|||||||
anymarker = true
|
anymarker = true
|
||||||
end
|
end
|
||||||
delete!(d, :marker)
|
delete!(d, :marker)
|
||||||
# if anymarker && !haskey(d, :markershape)
|
|
||||||
# d[:markershape] = :ellipse
|
|
||||||
# end
|
|
||||||
if haskey(d, :markershape)
|
if haskey(d, :markershape)
|
||||||
d[:markershape] = _replace_markershape(d[:markershape])
|
d[:markershape] = _replace_markershape(d[:markershape])
|
||||||
elseif anymarker
|
elseif anymarker
|
||||||
@ -681,8 +668,6 @@ function warnOnUnsupported(pkg::AbstractBackend, d::KW)
|
|||||||
|| 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
|
||||||
|| _markershape_supported(pkg, d[:markershape])
|
|| _markershape_supported(pkg, d[:markershape])
|
||||||
# || d[:markershape] in supportedMarkers(pkg)
|
|
||||||
# || (Shape in supportedMarkers(pkg) && typeof(d[:markershape]) <: Shape)
|
|
||||||
|| warn("markershape $(d[:markershape]) is unsupported with $pkg. Choose from: $(supportedMarkers(pkg))"))
|
|| warn("markershape $(d[:markershape]) is unsupported with $pkg. Choose from: $(supportedMarkers(pkg))"))
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -823,6 +808,5 @@ function getSeriesArgs(pkg::AbstractBackend, plotargs::KW, kw, commandIndex::Int
|
|||||||
|
|
||||||
warnOnUnsupported(pkg, d)
|
warnOnUnsupported(pkg, d)
|
||||||
|
|
||||||
|
|
||||||
d
|
d
|
||||||
end
|
end
|
||||||
|
|||||||
@ -35,14 +35,9 @@ getPyPlotColor(c::Colorant, α=nothing) = map(f->float(f(convertColor(c,α))), (
|
|||||||
getPyPlotColor(cvec::ColorVector, α=nothing) = map(getPyPlotColor, convertColor(cvec, α).v)
|
getPyPlotColor(cvec::ColorVector, α=nothing) = map(getPyPlotColor, convertColor(cvec, α).v)
|
||||||
getPyPlotColor(scheme::ColorScheme, α=nothing) = getPyPlotColor(convertColor(getColor(scheme), α))
|
getPyPlotColor(scheme::ColorScheme, α=nothing) = getPyPlotColor(convertColor(getColor(scheme), α))
|
||||||
getPyPlotColor(c, α=nothing) = getPyPlotColor(convertColor(c, α))
|
getPyPlotColor(c, α=nothing) = getPyPlotColor(convertColor(c, α))
|
||||||
# getPyPlotColor(c, alpha) = getPyPlotColor(colorscheme(c, alpha))
|
|
||||||
|
|
||||||
function getPyPlotColorMap(c::ColorGradient, α=nothing)
|
function getPyPlotColorMap(c::ColorGradient, α=nothing)
|
||||||
# c = ColorGradient(c.colors, c.values, alpha=α)
|
|
||||||
# pycolors.pymember("LinearSegmentedColormap")[:from_list]("tmp", map(getPyPlotColor, getColorVector(c)))
|
|
||||||
# pyvals = [(c.values[i], getPyPlotColor(c.colors[i], α)) for i in 1:length(c.colors)]
|
|
||||||
pyvals = [(v, getPyPlotColor(getColorZ(c, v), α)) for v in c.values]
|
pyvals = [(v, getPyPlotColor(getColorZ(c, v), α)) for v in c.values]
|
||||||
# @show c α pyvals
|
|
||||||
pycolors.pymember("LinearSegmentedColormap")[:from_list]("tmp", pyvals)
|
pycolors.pymember("LinearSegmentedColormap")[:from_list]("tmp", pyvals)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -69,7 +64,6 @@ function getPyPlotMarker(marker::Shape)
|
|||||||
end
|
end
|
||||||
mat[n+1,:] = mat[1,:]
|
mat[n+1,:] = mat[1,:]
|
||||||
pypath.pymember("Path")(mat)
|
pypath.pymember("Path")(mat)
|
||||||
# marker.vertices
|
|
||||||
end
|
end
|
||||||
|
|
||||||
const _path_MOVETO = UInt8(1)
|
const _path_MOVETO = UInt8(1)
|
||||||
@ -135,11 +129,7 @@ function getPyPlotStepStyle(linetype::Symbol)
|
|||||||
return "default"
|
return "default"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
# immutable PyPlotFigWrapper
|
|
||||||
# fig
|
|
||||||
# kwargs # for add_subplot
|
|
||||||
# end
|
|
||||||
|
|
||||||
type PyPlotAxisWrapper
|
type PyPlotAxisWrapper
|
||||||
ax
|
ax
|
||||||
@ -148,7 +138,6 @@ type PyPlotAxisWrapper
|
|||||||
kwargs # for add_subplot
|
kwargs # for add_subplot
|
||||||
end
|
end
|
||||||
|
|
||||||
# getfig(wrap::@compat(Union{PyPlotAxisWrapper,PyPlotFigWrapper})) = wrap.fig
|
|
||||||
getfig(wrap::PyPlotAxisWrapper) = wrap.fig
|
getfig(wrap::PyPlotAxisWrapper) = wrap.fig
|
||||||
|
|
||||||
|
|
||||||
@ -165,8 +154,6 @@ function getLeftAxis(wrap::PyPlotAxisWrapper)
|
|||||||
wrap.ax
|
wrap.ax
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# getLeftAxis(wrap::PyPlotAxisWrapper) = wrap.ax
|
|
||||||
# getRightAxis(x) = getLeftAxis(x)[:twinx]()
|
|
||||||
|
|
||||||
function getRightAxis(wrap::PyPlotAxisWrapper)
|
function getRightAxis(wrap::PyPlotAxisWrapper)
|
||||||
if wrap.rightax == nothing
|
if wrap.rightax == nothing
|
||||||
@ -209,21 +196,6 @@ function getPyPlotFunction(plt::Plot, axis::Symbol, linetype::Symbol)
|
|||||||
return ax[get(fmap, linetype, :plot)]
|
return ax[get(fmap, linetype, :plot)]
|
||||||
end
|
end
|
||||||
|
|
||||||
function updateAxisColors(ax, fgcolor)
|
|
||||||
# for loc in ("bottom", "top", "left", "right")
|
|
||||||
for (loc, spine) in ax[:spines]
|
|
||||||
# ax[:spines][loc][:set_color](fgcolor)
|
|
||||||
spine[:set_color](fgcolor)
|
|
||||||
end
|
|
||||||
for axis in ("x", "y")
|
|
||||||
ax[:tick_params](axis=axis, colors=fgcolor, which="both")
|
|
||||||
end
|
|
||||||
for axis in (:yaxis, :xaxis)
|
|
||||||
ax[axis][:label][:set_color](fgcolor)
|
|
||||||
end
|
|
||||||
ax[:title][:set_color](fgcolor)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function handleSmooth(plt::Plot{PyPlotBackend}, ax, d::KW, smooth::Bool)
|
function handleSmooth(plt::Plot{PyPlotBackend}, ax, d::KW, smooth::Bool)
|
||||||
if smooth
|
if smooth
|
||||||
@ -237,11 +209,8 @@ function handleSmooth(plt::Plot{PyPlotBackend}, ax, d::KW, smooth::Bool)
|
|||||||
end
|
end
|
||||||
handleSmooth(plt::Plot{PyPlotBackend}, ax, d::KW, smooth::Real) = handleSmooth(plt, ax, d, true)
|
handleSmooth(plt::Plot{PyPlotBackend}, ax, d::KW, smooth::Real) = handleSmooth(plt, ax, d, true)
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# makePyPlotCurrent(wrap::PyPlotFigWrapper) = PyPlot.figure(wrap.fig.o[:number])
|
|
||||||
# makePyPlotCurrent(wrap::PyPlotAxisWrapper) = nothing #PyPlot.sca(wrap.ax.o)
|
|
||||||
makePyPlotCurrent(wrap::PyPlotAxisWrapper) = wrap.ax == nothing ? PyPlot.figure(wrap.fig.o[:number]) : nothing
|
makePyPlotCurrent(wrap::PyPlotAxisWrapper) = wrap.ax == nothing ? PyPlot.figure(wrap.fig.o[:number]) : nothing
|
||||||
makePyPlotCurrent(plt::Plot{PyPlotBackend}) = plt.o == nothing ? nothing : makePyPlotCurrent(plt.o)
|
makePyPlotCurrent(plt::Plot{PyPlotBackend}) = plt.o == nothing ? nothing : makePyPlotCurrent(plt.o)
|
||||||
|
|
||||||
@ -287,14 +256,7 @@ function pyplot_3d_setup!(wrap, d)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
# TODO:
|
|
||||||
# fillto # might have to use barHack/histogramHack??
|
|
||||||
# reg # true or false, add a regression line for each line
|
|
||||||
# pos # (Int,Int), move the enclosing window to this position
|
|
||||||
# windowtitle # string or symbol, set the title of the enclosing windowtitle
|
|
||||||
# screen # Integer, move enclosing window to this screen number (for multiscreen desktops)
|
|
||||||
# show # true or false, show the plot (in case you don't want the window to pop up right away)
|
|
||||||
|
|
||||||
function _create_plot(pkg::PyPlotBackend; kw...)
|
function _create_plot(pkg::PyPlotBackend; kw...)
|
||||||
# create the figure
|
# create the figure
|
||||||
@ -321,6 +283,7 @@ function _create_plot(pkg::PyPlotBackend; kw...)
|
|||||||
plt
|
plt
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
function _add_series(pkg::PyPlotBackend, plt::Plot; kw...)
|
function _add_series(pkg::PyPlotBackend, plt::Plot; kw...)
|
||||||
d = KW(kw)
|
d = KW(kw)
|
||||||
@ -430,7 +393,6 @@ function _add_series(pkg::PyPlotBackend, plt::Plot; kw...)
|
|||||||
extra_kwargs[:c] = convert(Vector{Float64}, d[:zcolor])
|
extra_kwargs[:c] = convert(Vector{Float64}, d[:zcolor])
|
||||||
extra_kwargs[:cmap] = getPyPlotColorMap(c, d[:markeralpha])
|
extra_kwargs[:cmap] = getPyPlotColorMap(c, d[:markeralpha])
|
||||||
else
|
else
|
||||||
# extra_kwargs[:c] = getPyPlotColor(c, d[:markeralpha])
|
|
||||||
ppc = getPyPlotColor(c, d[:markeralpha])
|
ppc = getPyPlotColor(c, d[:markeralpha])
|
||||||
|
|
||||||
# total hack due to PyPlot bug (see issue #145).
|
# total hack due to PyPlot bug (see issue #145).
|
||||||
@ -442,9 +404,6 @@ function _add_series(pkg::PyPlotBackend, plt::Plot; kw...)
|
|||||||
extra_kwargs[:c] = ppc
|
extra_kwargs[:c] = ppc
|
||||||
|
|
||||||
end
|
end
|
||||||
# if d[:markeralpha] != nothing
|
|
||||||
# extra_kwargs[:alpha] = d[:markeralpha]
|
|
||||||
# end
|
|
||||||
extra_kwargs[:edgecolors] = getPyPlotColor(d[:markerstrokecolor], d[:markerstrokealpha])
|
extra_kwargs[:edgecolors] = getPyPlotColor(d[:markerstrokecolor], d[:markerstrokealpha])
|
||||||
extra_kwargs[:linewidths] = d[:markerstrokewidth]
|
extra_kwargs[:linewidths] = d[:markerstrokewidth]
|
||||||
else
|
else
|
||||||
@ -456,12 +415,6 @@ function _add_series(pkg::PyPlotBackend, plt::Plot; kw...)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# if d[:markeralpha] != nothing
|
|
||||||
# extra_kwargs[:alpha] = d[:markeralpha]
|
|
||||||
# elseif d[:linealpha] != nothing
|
|
||||||
# extra_kwargs[:alpha] = d[:linealpha]
|
|
||||||
# end
|
|
||||||
|
|
||||||
# set these for all types
|
# set these for all types
|
||||||
if !(lt in (:contour,:surface,:wireframe,:heatmap))
|
if !(lt in (:contour,:surface,:wireframe,:heatmap))
|
||||||
if !(lt in (:scatter, :scatter3d, :shape))
|
if !(lt in (:scatter, :scatter3d, :shape))
|
||||||
@ -619,120 +572,46 @@ function Base.setindex!{X,Y,Z}(plt::Plot{PyPlotBackend}, xyz::Tuple{X,Y,Z}, i::I
|
|||||||
plt
|
plt
|
||||||
end
|
end
|
||||||
|
|
||||||
# -----------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
|
|
||||||
function addPyPlotLims(ax, lims, dimension)
|
function addPyPlotLims(ax, lims, letter)
|
||||||
lims == :auto && return
|
lims == :auto && return
|
||||||
ltype = limsType(lims)
|
ltype = limsType(lims)
|
||||||
if ltype == :limits
|
if ltype == :limits
|
||||||
if dimension == :xlim
|
setf = ax[symbol("set_", letter, "lim")]
|
||||||
isfinite(lims[1]) && ax[:set_xlim](left = lims[1])
|
l1, l2 = lims
|
||||||
isfinite(lims[2]) && ax[:set_xlim](right = lims[2])
|
if isfinite(l1)
|
||||||
elseif dimension == :ylim
|
letter == "x" ? setf(left = l1) : setf(bottom = l1)
|
||||||
isfinite(lims[1]) && ax[:set_ylim](bottom = lims[1])
|
end
|
||||||
isfinite(lims[2]) && ax[:set_ylim](top = lims[2])
|
if isfinite(l2)
|
||||||
elseif dimension == :zlim && haskey(ax, :set_zlim)
|
letter == "x" ? setf(right = l2) : setf(top = l2)
|
||||||
isfinite(lims[1]) && ax[:set_zlim](bottom = lims[1])
|
|
||||||
isfinite(lims[2]) && ax[:set_zlim](top = lims[2])
|
|
||||||
else
|
|
||||||
error("Invalid argument at position 3: $dimension")
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
error("Invalid input for $dimension: ", lims)
|
error("Invalid input for $letter: ", lims)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function addPyPlotTicks(ax, ticks, isx::Bool)
|
function addPyPlotTicks(ax, ticks, letter)
|
||||||
ticks == :auto && return
|
ticks == :auto && return
|
||||||
if ticks == :none || ticks == nothing
|
if ticks == :none || ticks == nothing
|
||||||
ticks = zeros(0)
|
ticks = zeros(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
ttype = ticksType(ticks)
|
ttype = ticksType(ticks)
|
||||||
|
tickfunc = symbol("set_", letter, "ticks")
|
||||||
|
labfunc = symbol("set_", letter, "ticklabels")
|
||||||
if ttype == :ticks
|
if ttype == :ticks
|
||||||
ax[isx ? :set_xticks : :set_yticks](ticks)
|
ax[tickfunc](ticks)
|
||||||
elseif ttype == :ticks_and_labels
|
elseif ttype == :ticks_and_labels
|
||||||
ax[isx ? :set_xticks : :set_yticks](ticks[1])
|
ax[tickfunc](ticks[1])
|
||||||
ax[isx ? :set_xticklabels : :set_yticklabels](ticks[2])
|
ax[labfunc](ticks[2])
|
||||||
else
|
else
|
||||||
error("Invalid input for $(isx ? "xticks" : "yticks"): ", ticks)
|
error("Invalid input for $(isx ? "xticks" : "yticks"): ", ticks)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
usingRightAxis(plt::Plot{PyPlotBackend}) = any(args -> args[:axis] in (:right,:auto), plt.seriesargs)
|
function applyPyPlotScale(ax, scaleType::Symbol, letter)
|
||||||
|
func = ax[symbol("set_", letter, "scale")]
|
||||||
function _update_plot(plt::Plot{PyPlotBackend}, d::KW)
|
|
||||||
figorax = plt.o
|
|
||||||
ax = getLeftAxis(figorax)
|
|
||||||
# PyPlot.sca(ax)
|
|
||||||
|
|
||||||
|
|
||||||
# title and axis labels
|
|
||||||
# haskey(d, :title) && PyPlot.title(d[:title])
|
|
||||||
haskey(d, :title) && ax[:set_title](d[:title])
|
|
||||||
haskey(d, :xlabel) && ax[:set_xlabel](d[:xlabel])
|
|
||||||
if haskey(d, :ylabel)
|
|
||||||
ax[:set_ylabel](d[:ylabel])
|
|
||||||
end
|
|
||||||
if usingRightAxis(plt) && get(d, :yrightlabel, "") != ""
|
|
||||||
rightax = getRightAxis(figorax)
|
|
||||||
rightax[:set_ylabel](d[:yrightlabel])
|
|
||||||
end
|
|
||||||
|
|
||||||
# scales
|
|
||||||
haskey(d, :xscale) && applyPyPlotScale(ax, d[:xscale], true)
|
|
||||||
haskey(d, :yscale) && applyPyPlotScale(ax, d[:yscale], false)
|
|
||||||
|
|
||||||
# limits and ticks
|
|
||||||
haskey(d, :xlims) && addPyPlotLims(ax, d[:xlims], :xlim)
|
|
||||||
haskey(d, :ylims) && addPyPlotLims(ax, d[:ylims], :ylim)
|
|
||||||
haskey(d, :zlims) && addPyPlotLims(ax, d[:zlims], :zlim)
|
|
||||||
haskey(d, :xticks) && addPyPlotTicks(ax, d[:xticks], true)
|
|
||||||
haskey(d, :yticks) && addPyPlotTicks(ax, d[:yticks], false)
|
|
||||||
|
|
||||||
if get(d, :xflip, false)
|
|
||||||
ax[:invert_xaxis]()
|
|
||||||
end
|
|
||||||
if get(d, :yflip, false)
|
|
||||||
ax[:invert_yaxis]()
|
|
||||||
end
|
|
||||||
|
|
||||||
axes = [getLeftAxis(figorax)]
|
|
||||||
if usingRightAxis(plt)
|
|
||||||
push!(axes, getRightAxis(figorax))
|
|
||||||
end
|
|
||||||
|
|
||||||
# font sizes
|
|
||||||
for ax in axes
|
|
||||||
# haskey(d, :yrightlabel) || continue
|
|
||||||
|
|
||||||
|
|
||||||
# guides
|
|
||||||
sz = get(d, :guidefont, plt.plotargs[:guidefont]).pointsize
|
|
||||||
ax[:title][:set_fontsize](sz)
|
|
||||||
ax[:xaxis][:label][:set_fontsize](sz)
|
|
||||||
ax[:yaxis][:label][:set_fontsize](sz)
|
|
||||||
|
|
||||||
# ticks
|
|
||||||
sz = get(d, :tickfont, plt.plotargs[:tickfont]).pointsize
|
|
||||||
for sym in (:get_xticklabels, :get_yticklabels)
|
|
||||||
for lab in ax[sym]()
|
|
||||||
lab[:set_fontsize](sz)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# grid
|
|
||||||
if get(d, :grid, false)
|
|
||||||
ax[:xaxis][:grid](true)
|
|
||||||
ax[:yaxis][:grid](true)
|
|
||||||
ax[:set_axisbelow](true)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
function applyPyPlotScale(ax, scaleType::Symbol, isx::Bool)
|
|
||||||
func = ax[isx ? :set_xscale : :set_yscale]
|
|
||||||
scaleType == :identity && return func("linear")
|
scaleType == :identity && return func("linear")
|
||||||
scaleType == :ln && return func("log", basex = e, basey = e)
|
scaleType == :ln && return func("log", basex = e, basey = e)
|
||||||
scaleType == :log2 && return func("log", basex = 2, basey = 2)
|
scaleType == :log2 && return func("log", basex = 2, basey = 2)
|
||||||
@ -740,6 +619,75 @@ function applyPyPlotScale(ax, scaleType::Symbol, isx::Bool)
|
|||||||
warn("Unhandled scaleType: ", scaleType)
|
warn("Unhandled scaleType: ", scaleType)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function updateAxisColors(ax, fgcolor)
|
||||||
|
for (loc, spine) in ax[:spines]
|
||||||
|
spine[:set_color](fgcolor)
|
||||||
|
end
|
||||||
|
for letter in ("x", "y", "z")
|
||||||
|
axis = axis_symbol(letter, "axis")
|
||||||
|
if haskey(ax, axis)
|
||||||
|
ax[:tick_params](axis=letter, colors=fgcolor, which="both")
|
||||||
|
ax[axis][:label][:set_color](fgcolor)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
ax[:title][:set_color](fgcolor)
|
||||||
|
end
|
||||||
|
|
||||||
|
function usingRightAxis(plt::Plot{PyPlotBackend})
|
||||||
|
any(args -> args[:axis] in (:right,:auto), plt.seriesargs)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
function _update_plot(plt::Plot{PyPlotBackend}, d::KW)
|
||||||
|
figorax = plt.o
|
||||||
|
ax = getLeftAxis(figorax)
|
||||||
|
ticksz = get(d, :tickfont, plt.plotargs[:tickfont]).pointsize
|
||||||
|
guidesz = get(d, :guidefont, plt.plotargs[:guidefont]).pointsize
|
||||||
|
|
||||||
|
# title
|
||||||
|
haskey(d, :title) && ax[:set_title](d[:title])
|
||||||
|
ax[:title][:set_fontsize](guidesz)
|
||||||
|
|
||||||
|
# handle right y axis
|
||||||
|
axes = [getLeftAxis(figorax)]
|
||||||
|
if usingRightAxis(plt)
|
||||||
|
push!(axes, getRightAxis(figorax))
|
||||||
|
if get(d, :yrightlabel, "") != ""
|
||||||
|
rightax = getRightAxis(figorax)
|
||||||
|
rightax[:set_ylabel](d[:yrightlabel])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# handle each axis in turn
|
||||||
|
for letter in ("x", "y", "z")
|
||||||
|
axis, scale, lims, ticks, flip, lab = axis_symbols(letter, "axis", "scale", "lims", "ticks", "flip", "label")
|
||||||
|
haskey(ax, axis) || continue
|
||||||
|
haskey(d, scale) && applyPyPlotScale(ax, d[scale], letter)
|
||||||
|
haskey(d, lims) && addPyPlotLims(ax, d[lims], letter)
|
||||||
|
haskey(d, ticks) && addPyPlotTicks(ax, d[ticks], letter)
|
||||||
|
haskey(d, lab) && ax[symbol("set_", letter, "label")](d[lab])
|
||||||
|
if get(d, flip, false)
|
||||||
|
ax[symbol("invert_", letter, "axis")]()
|
||||||
|
end
|
||||||
|
for tmpax in axes
|
||||||
|
tmpax[axis][:label][:set_fontsize](guidesz)
|
||||||
|
for lab in tmpax[symbol("get_", letter, "ticklabels")]()
|
||||||
|
lab[:set_fontsize](ticksz)
|
||||||
|
end
|
||||||
|
if get(d, :grid, false)
|
||||||
|
fgcolor = getPyPlotColor(plt.plotargs[:foreground_color])
|
||||||
|
tmpax[axis][:grid](true, color = fgcolor)
|
||||||
|
tmpax[:set_axisbelow](true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
|
|
||||||
function createPyPlotAnnotationObject(plt::Plot{PyPlotBackend}, x, y, val::@compat(AbstractString))
|
function createPyPlotAnnotationObject(plt::Plot{PyPlotBackend}, x, y, val::@compat(AbstractString))
|
||||||
|
|||||||
@ -21,72 +21,36 @@ stringsSupported() = stringsSupported(backend())
|
|||||||
|
|
||||||
supportedArgs(::GadflyBackend) = [
|
supportedArgs(::GadflyBackend) = [
|
||||||
:annotation,
|
:annotation,
|
||||||
# :axis,
|
:background_color, :foreground_color, :color_palette,
|
||||||
:background_color,
|
|
||||||
:linecolor,
|
|
||||||
:color_palette,
|
|
||||||
:fillrange,
|
|
||||||
:fillcolor,
|
|
||||||
:fillalpha,
|
|
||||||
:foreground_color,
|
|
||||||
:group,
|
:group,
|
||||||
:label,
|
:label,
|
||||||
:layout,
|
|
||||||
:legend,
|
|
||||||
:colorbar,
|
|
||||||
:linestyle,
|
|
||||||
:linetype,
|
:linetype,
|
||||||
:linewidth,
|
:linecolor, :linestyle, :linewidth, :linealpha,
|
||||||
:linealpha,
|
:markershape, :markercolor, :markersize, :markeralpha,
|
||||||
:markershape,
|
:markerstrokewidth, :markerstrokecolor, :markerstrokealpha,
|
||||||
:markercolor,
|
:fillrange, :fillcolor, :fillalpha,
|
||||||
:markersize,
|
|
||||||
:markeralpha,
|
|
||||||
:markerstrokewidth,
|
|
||||||
:markerstrokecolor,
|
|
||||||
:markerstrokealpha,
|
|
||||||
# :markerstrokestyle,
|
|
||||||
:n,
|
|
||||||
:nbins,
|
:nbins,
|
||||||
:nc,
|
:n, :nc, :nr, :layout,
|
||||||
:nr,
|
|
||||||
# :pos,
|
|
||||||
:smooth,
|
:smooth,
|
||||||
:show,
|
:title, :windowtitle, :show, :size,
|
||||||
:size,
|
:x, :xlabel, :xlims, :xticks, :xscale, :xflip,
|
||||||
:title,
|
:y, :ylabel, :ylims, :yticks, :yscale, :yflip,
|
||||||
:windowtitle,
|
# :z, :zlabel, :zlims, :zticks, :zscale, :zflip,
|
||||||
:x,
|
|
||||||
:xlabel,
|
|
||||||
:xlims,
|
|
||||||
:xticks,
|
|
||||||
:y,
|
|
||||||
:ylabel,
|
|
||||||
:ylims,
|
|
||||||
# :yrightlabel,
|
|
||||||
:yticks,
|
|
||||||
:xscale,
|
|
||||||
:yscale,
|
|
||||||
:xflip,
|
|
||||||
:yflip,
|
|
||||||
:z,
|
:z,
|
||||||
:zcolor,
|
:tickfont, :guidefont, :legendfont,
|
||||||
:tickfont,
|
:grid, :legend, :colorbar,
|
||||||
:guidefont,
|
:zcolor, :levels,
|
||||||
:legendfont,
|
:xerror, :yerror,
|
||||||
:grid,
|
:ribbon, :quiver,
|
||||||
# :surface,
|
|
||||||
:levels,
|
|
||||||
:xerror,
|
|
||||||
:yerror,
|
|
||||||
:ribbon,
|
|
||||||
:quiver,
|
|
||||||
:orientation,
|
:orientation,
|
||||||
]
|
]
|
||||||
supportedAxes(::GadflyBackend) = [:auto, :left]
|
supportedAxes(::GadflyBackend) = [:auto, :left]
|
||||||
supportedTypes(::GadflyBackend) = [:none, :line, :path, :steppre, :steppost, :sticks,
|
supportedTypes(::GadflyBackend) = [
|
||||||
:scatter, :hist2d, :hexbin, :hist, :bar, :box, :violin, :quiver,
|
:none, :line, :path, :steppre, :steppost, :sticks,
|
||||||
:hline, :vline, :contour, :shape]
|
:scatter, :hist2d, :hexbin, :hist,
|
||||||
|
:bar, :box, :violin, :quiver,
|
||||||
|
:hline, :vline, :contour, :shape
|
||||||
|
]
|
||||||
supportedStyles(::GadflyBackend) = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot]
|
supportedStyles(::GadflyBackend) = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot]
|
||||||
supportedMarkers(::GadflyBackend) = vcat(_allMarkers, Shape)
|
supportedMarkers(::GadflyBackend) = vcat(_allMarkers, Shape)
|
||||||
supportedScales(::GadflyBackend) = [:identity, :ln, :log2, :log10, :asinh, :sqrt]
|
supportedScales(::GadflyBackend) = [:identity, :ln, :log2, :log10, :asinh, :sqrt]
|
||||||
@ -110,78 +74,41 @@ subplotSupported(::ImmerseBackend) = true
|
|||||||
|
|
||||||
supportedArgs(::PyPlotBackend) = [
|
supportedArgs(::PyPlotBackend) = [
|
||||||
:annotation,
|
:annotation,
|
||||||
:axis,
|
:background_color, :foreground_color, :color_palette,
|
||||||
:background_color,
|
|
||||||
:linecolor,
|
|
||||||
:color_palette,
|
|
||||||
:fillrange,
|
|
||||||
:fillcolor,
|
|
||||||
:foreground_color,
|
|
||||||
:group,
|
:group,
|
||||||
:label,
|
:label,
|
||||||
:layout,
|
|
||||||
:legend,
|
|
||||||
:colorbar,
|
|
||||||
:linestyle,
|
|
||||||
:linetype,
|
:linetype,
|
||||||
:linewidth,
|
:linecolor, :linestyle, :linewidth, :linealpha,
|
||||||
:markershape,
|
:markershape, :markercolor, :markersize, :markeralpha,
|
||||||
:markercolor,
|
:markerstrokewidth, :markerstrokecolor, :markerstrokealpha,
|
||||||
:markersize,
|
:fillrange, :fillcolor, :fillalpha,
|
||||||
:markerstrokewidth,
|
|
||||||
:markerstrokecolor,
|
|
||||||
:markerstrokealpha,
|
|
||||||
# :markerstrokestyle,
|
|
||||||
:n,
|
|
||||||
:nbins,
|
:nbins,
|
||||||
:nc,
|
:n, :nc, :nr, :layout,
|
||||||
:nr,
|
|
||||||
# :pos,
|
|
||||||
:smooth,
|
:smooth,
|
||||||
# :ribbon,
|
:title, :windowtitle, :show, :size,
|
||||||
:show,
|
:x, :xlabel, :xlims, :xticks, :xscale, :xflip,
|
||||||
:size,
|
:y, :ylabel, :ylims, :yticks, :yscale, :yflip,
|
||||||
:title,
|
:axis, :yrightlabel,
|
||||||
:windowtitle,
|
:z, :zlabel, :zlims, :zticks, :zscale, :zflip,
|
||||||
:x,
|
|
||||||
:xlabel,
|
|
||||||
:xlims,
|
|
||||||
:xticks,
|
|
||||||
:y,
|
|
||||||
:ylabel,
|
|
||||||
:ylims,
|
|
||||||
:zlims,
|
|
||||||
:yrightlabel,
|
|
||||||
:yticks,
|
|
||||||
:xscale,
|
|
||||||
:yscale,
|
|
||||||
:xflip,
|
|
||||||
:yflip,
|
|
||||||
:z,
|
:z,
|
||||||
:zcolor, # only supported for scatter/scatter3d
|
:tickfont, :guidefont, :legendfont,
|
||||||
:tickfont,
|
:grid, :legend, :colorbar,
|
||||||
:guidefont,
|
:zcolor, :levels,
|
||||||
:legendfont,
|
:xerror, :yerror,
|
||||||
:grid,
|
:ribbon, :quiver,
|
||||||
# :surface,
|
|
||||||
:levels,
|
|
||||||
:fillalpha,
|
|
||||||
:linealpha,
|
|
||||||
:markeralpha,
|
|
||||||
:overwrite_figure,
|
|
||||||
:xerror,
|
|
||||||
:yerror,
|
|
||||||
:ribbon,
|
|
||||||
:quiver,
|
|
||||||
:orientation,
|
:orientation,
|
||||||
|
:overwrite_figure,
|
||||||
:polar,
|
:polar,
|
||||||
]
|
]
|
||||||
supportedAxes(::PyPlotBackend) = _allAxes
|
supportedAxes(::PyPlotBackend) = _allAxes
|
||||||
supportedTypes(::PyPlotBackend) = [:none, :line, :path, :steppre, :steppost, :shape,
|
supportedTypes(::PyPlotBackend) = [
|
||||||
:scatter, :hist2d, :hexbin, :hist, :density, :bar, :box, :violin, :quiver,
|
:none, :line, :path, :steppre, :steppost, :shape,
|
||||||
:hline, :vline, :contour, :path3d, :scatter3d, :surface, :wireframe, :heatmap]
|
:scatter, :hist2d, :hexbin, :hist, :density,
|
||||||
|
:bar, :box, :violin, :quiver,
|
||||||
|
:hline, :vline, :heatmap,
|
||||||
|
:contour, :path3d, :scatter3d, :surface, :wireframe
|
||||||
|
]
|
||||||
supportedStyles(::PyPlotBackend) = [:auto, :solid, :dash, :dot, :dashdot]
|
supportedStyles(::PyPlotBackend) = [:auto, :solid, :dash, :dot, :dashdot]
|
||||||
# supportedMarkers(::PyPlotBackend) = [:none, :auto, :rect, :ellipse, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star5, :hexagon]
|
|
||||||
supportedMarkers(::PyPlotBackend) = vcat(_allMarkers, Shape)
|
supportedMarkers(::PyPlotBackend) = vcat(_allMarkers, Shape)
|
||||||
supportedScales(::PyPlotBackend) = [:identity, :ln, :log2, :log10]
|
supportedScales(::PyPlotBackend) = [:identity, :ln, :log2, :log10]
|
||||||
subplotSupported(::PyPlotBackend) = true
|
subplotSupported(::PyPlotBackend) = true
|
||||||
|
|||||||
46
src/plot.jl
46
src/plot.jl
@ -78,62 +78,19 @@ function plot!(plt::Plot, args...; kw...)
|
|||||||
args = _apply_recipe(d, args...; kw...)
|
args = _apply_recipe(d, args...; kw...)
|
||||||
|
|
||||||
dumpdict(d, "After plot! preprocessing")
|
dumpdict(d, "After plot! preprocessing")
|
||||||
# @show groupargs map(typeof, args)
|
|
||||||
|
|
||||||
warnOnUnsupportedArgs(plt.backend, d)
|
warnOnUnsupportedArgs(plt.backend, d)
|
||||||
|
|
||||||
# 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)
|
||||||
|
|
||||||
# # grouping
|
# # grouping
|
||||||
# groupargs = get(d, :group, nothing) == nothing ? [nothing] : [extractGroupArgs(d[:group], args...)]
|
|
||||||
# # @show groupargs
|
|
||||||
|
|
||||||
# TODO: get the GroupBy object (or nothing), and loop through the groups, doing the following section many times
|
|
||||||
# dumpdict(d, "before", true)
|
|
||||||
groupby = if haskey(d, :group)
|
groupby = if haskey(d, :group)
|
||||||
extractGroupArgs(d[:group], args...)
|
extractGroupArgs(d[:group], args...)
|
||||||
else
|
else
|
||||||
nothing
|
nothing
|
||||||
end
|
end
|
||||||
# dumpdict(d, "after", true)
|
|
||||||
# @show groupby map(typeof, args)
|
|
||||||
|
|
||||||
_add_series(plt, d, groupby, args...)
|
_add_series(plt, d, groupby, args...)
|
||||||
|
|
||||||
#
|
|
||||||
# # get the list of dictionaries, one per series
|
|
||||||
# @show groupargs map(typeof, args)
|
|
||||||
# dumpdict(d, "before process_inputs")
|
|
||||||
# process_inputs(plt, d, groupargs..., args...)
|
|
||||||
# dumpdict(d, "after process_inputs", true)
|
|
||||||
# seriesArgList, xmeta, ymeta = build_series_args(plt, d)
|
|
||||||
# # seriesArgList, xmeta, ymeta = build_series_args(plt, groupargs..., args...; d...)
|
|
||||||
#
|
|
||||||
# # if we were able to extract guide information from the series inputs, then update the plot
|
|
||||||
# # @show xmeta, ymeta
|
|
||||||
# updateDictWithMeta(d, plt.plotargs, xmeta, true)
|
|
||||||
# updateDictWithMeta(d, plt.plotargs, ymeta, false)
|
|
||||||
#
|
|
||||||
# # now we can plot the series
|
|
||||||
# for (i,di) in enumerate(seriesArgList)
|
|
||||||
# plt.n += 1
|
|
||||||
#
|
|
||||||
# if !stringsSupported()
|
|
||||||
# setTicksFromStringVector(d, di, :x, :xticks)
|
|
||||||
# setTicksFromStringVector(d, di, :y, :yticks)
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# # remove plot args
|
|
||||||
# for k in keys(_plotDefaults)
|
|
||||||
# delete!(di, k)
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# dumpdict(di, "Series $i")
|
|
||||||
#
|
|
||||||
# _add_series(plt.backend, plt; di...)
|
|
||||||
# end
|
|
||||||
|
|
||||||
_add_annotations(plt, d)
|
_add_annotations(plt, d)
|
||||||
|
|
||||||
warnOnUnsupportedScales(plt.backend, d)
|
warnOnUnsupportedScales(plt.backend, d)
|
||||||
@ -150,7 +107,7 @@ function plot!(plt::Plot, args...; kw...)
|
|||||||
|
|
||||||
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
|
||||||
# # do we want to show it?
|
# # do we want to show it?
|
||||||
if haskey(d, :show) && d[:show]
|
if haskey(d, :show) && d[:show]
|
||||||
gui()
|
gui()
|
||||||
@ -212,6 +169,7 @@ function _add_series(plt::Plot, d::KW, ::Void, args...;
|
|||||||
if !stringsSupported()
|
if !stringsSupported()
|
||||||
setTicksFromStringVector(d, di, :x, :xticks)
|
setTicksFromStringVector(d, di, :x, :xticks)
|
||||||
setTicksFromStringVector(d, di, :y, :yticks)
|
setTicksFromStringVector(d, di, :y, :yticks)
|
||||||
|
setTicksFromStringVector(d, di, :z, :zticks)
|
||||||
end
|
end
|
||||||
|
|
||||||
# remove plot args
|
# remove plot args
|
||||||
|
|||||||
@ -231,6 +231,8 @@ limsType{T<:Real,S<:Real}(lims::@compat(Tuple{T,S})) = :limits
|
|||||||
limsType(lims::Symbol) = lims == :auto ? :auto : :invalid
|
limsType(lims::Symbol) = lims == :auto ? :auto : :invalid
|
||||||
limsType(lims) = :invalid
|
limsType(lims) = :invalid
|
||||||
|
|
||||||
|
axis_symbol(letter, postfix) = symbol(letter * postfix)
|
||||||
|
axis_symbols(letter, postfix...) = map(s -> axis_symbol(letter, s), postfix)
|
||||||
|
|
||||||
Base.convert{T<:Real}(::Type{Vector{T}}, rng::Range{T}) = T[x for x in rng]
|
Base.convert{T<:Real}(::Type{Vector{T}}, rng::Range{T}) = T[x for x in rng]
|
||||||
Base.convert{T<:Real,S<:Real}(::Type{Vector{T}}, rng::Range{S}) = T[x for x in rng]
|
Base.convert{T<:Real,S<:Real}(::Type{Vector{T}}, rng::Range{S}) = T[x for x in rng]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user