fixes to logic accepting arrays of values; additional fixes in gadfly and pyplot for this
This commit is contained in:
parent
b8d136588c
commit
2a9fa9539f
20
src/args.jl
20
src/args.jl
@ -507,6 +507,11 @@ function processFillArg(d::Dict, arg)
|
||||
end
|
||||
end
|
||||
|
||||
_replace_markershape(shape::Symbol) = get(_markerAliases, shape, shape)
|
||||
_replace_markershape(shapes::AVec) = map(_replace_markershape, shapes)
|
||||
_replace_markershape(shape) = shape
|
||||
|
||||
|
||||
"Handle all preprocessing of args... break out colors/sizes/etc and replace aliases."
|
||||
function preprocessArgs!(d::Dict)
|
||||
replaceAliases!(d, _keyAliases)
|
||||
@ -539,7 +544,12 @@ function preprocessArgs!(d::Dict)
|
||||
anymarker = true
|
||||
end
|
||||
delete!(d, :marker)
|
||||
if anymarker && !haskey(d, :markershape)
|
||||
# if anymarker && !haskey(d, :markershape)
|
||||
# d[:markershape] = :ellipse
|
||||
# end
|
||||
if haskey(d, :markershape)
|
||||
d[:markershape] = _replace_markershape(d[:markershape])
|
||||
elseif anymarker
|
||||
d[:markershape] = :ellipse
|
||||
end
|
||||
|
||||
@ -619,6 +629,9 @@ function warnOnUnsupportedArgs(pkg::PlottingPackage, d::Dict)
|
||||
end
|
||||
end
|
||||
|
||||
_markershape_supported(pkg::PlottingPackage, shape::Symbol) = shape in supportedMarkers(pkg)
|
||||
_markershape_supported(pkg::PlottingPackage, shape::Shape) = Shape in supportedMarkers(pkg)
|
||||
_markershape_supported(pkg::PlottingPackage, shapes::AVec) = all([_markershape_supported(pkg, shape) for shape in shapes])
|
||||
|
||||
function warnOnUnsupported(pkg::PlottingPackage, d::Dict)
|
||||
(d[:axis] in supportedAxes(pkg)
|
||||
@ -629,8 +642,9 @@ function warnOnUnsupported(pkg::PlottingPackage, d::Dict)
|
||||
(d[:linestyle] in supportedStyles(pkg)
|
||||
|| warn("linestyle $(d[:linestyle]) is unsupported with $pkg. Choose from: $(supportedStyles(pkg))"))
|
||||
(d[:markershape] == :none
|
||||
|| d[:markershape] in supportedMarkers(pkg)
|
||||
|| (Shape in supportedMarkers(pkg) && typeof(d[:markershape]) <: Shape)
|
||||
|| _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))"))
|
||||
end
|
||||
|
||||
|
||||
@ -168,11 +168,16 @@ end
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
# extract the underlying ShapeGeometry object(s)
|
||||
getMarkerGeom(shape::Shape) = gadflyshape(shape)
|
||||
getMarkerGeom(shape::Symbol) = gadflyshape(_shapes[shape])
|
||||
getMarkerGeom(shapes::AVec) = map(getMarkerGeom, shapes)
|
||||
getMarkerGeom(d::Dict) = getMarkerGeom(d[:markershape])
|
||||
|
||||
function getMarkerGeom(d::Dict)
|
||||
shape = d[:markershape]
|
||||
gadflyshape(isa(shape, Shape) ? shape : _shapes[shape])
|
||||
end
|
||||
# function getMarkerGeom(d::Dict)
|
||||
# shape = d[:markershape]
|
||||
# gadflyshape(isa(shape, Shape) ? shape : _shapes[shape])
|
||||
# end
|
||||
|
||||
|
||||
function getGadflyMarkerTheme(d::Dict, plotargs::Dict)
|
||||
|
||||
@ -31,6 +31,7 @@ end
|
||||
|
||||
# convert colorant to 4-tuple RGBA
|
||||
getPyPlotColor(c::Colorant, α=nothing) = map(f->float(f(convertColor(c,α))), (red, green, blue, alpha))
|
||||
getPyPlotColor(cvec::ColorVector, α=nothing) = map(getPyPlotColor, convertColor(cvec, α).v)
|
||||
getPyPlotColor(scheme::ColorScheme, α=nothing) = getPyPlotColor(convertColor(getColor(scheme), α))
|
||||
getPyPlotColor(c, α=nothing) = getPyPlotColor(convertColor(c, α))
|
||||
# getPyPlotColor(c, alpha) = getPyPlotColor(colorscheme(c, alpha))
|
||||
@ -90,8 +91,14 @@ function getPyPlotMarker(marker::Symbol)
|
||||
return "o"
|
||||
end
|
||||
|
||||
# getPyPlotMarker(markers::AVec) = map(getPyPlotMarker, markers)
|
||||
function getPyPlotMarker(markers::AVec)
|
||||
warn("Vectors of markers are currently unsupported in PyPlot: $markers")
|
||||
getPyPlotMarker(markers[1])
|
||||
end
|
||||
|
||||
# pass through
|
||||
function getPyPlotMarker(marker::@compat(AbstractString))
|
||||
function getPyPlotMarker(marker::AbstractString)
|
||||
@assert length(marker) == 1
|
||||
marker
|
||||
end
|
||||
@ -249,11 +256,21 @@ end
|
||||
function _add_series(pkg::PyPlotPackage, plt::Plot; kw...)
|
||||
d = Dict(kw)
|
||||
|
||||
# 3D plots have a different underlying Axes object in PyPlot
|
||||
lt = d[:linetype]
|
||||
if lt in _3dTypes && isempty(plt.o.kwargs)
|
||||
push!(plt.o.kwargs, (:projection, "3d"))
|
||||
end
|
||||
|
||||
# handle mismatched x/y sizes, as PyPlot doesn't like that
|
||||
x, y = d[:x], d[:y]
|
||||
nx, ny = map(length, (x,y))
|
||||
if nx < ny
|
||||
d[:x] = Float64[x[mod1(i,nx)] for i=1:ny]
|
||||
else
|
||||
d[:y] = Float64[y[mod1(i,ny)] for i=1:nx]
|
||||
end
|
||||
|
||||
ax = getAxis(plt, d[:axis])
|
||||
if !(lt in supportedTypes(pkg))
|
||||
error("linetype $(lt) is unsupported in PyPlot. Choose from: $(supportedTypes(pkg))")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user