shape linetype; supported in gadfly; gadfly cleanup
This commit is contained in:
parent
16799d8b75
commit
7531c48e38
@ -11,7 +11,7 @@ const _3dTypes = [:path3d, :scatter3d, :surface, :wireframe]
|
||||
const _allTypes = vcat([
|
||||
:none, :line, :path, :steppre, :steppost, :sticks, :scatter,
|
||||
:heatmap, :hexbin, :hist, :hist2d, :hist3d, :density, :bar, :hline, :vline, :ohlc,
|
||||
:contour, :pie
|
||||
:contour, :pie, :shape
|
||||
], _3dTypes)
|
||||
@compat const _typeAliases = Dict(
|
||||
:n => :none,
|
||||
@ -35,6 +35,9 @@ const _allTypes = vcat([
|
||||
:line3d => :path3d,
|
||||
:surf => :surface,
|
||||
:wire => :wireframe,
|
||||
:shapes => :shape,
|
||||
:poly => :shape,
|
||||
:polygon => :shape,
|
||||
)
|
||||
|
||||
ishistlike(lt::Symbol) = lt in (:hist, :density)
|
||||
@ -515,7 +518,7 @@ function processFillArg(d::Dict, arg)
|
||||
d[:fillalpha] = arg
|
||||
|
||||
elseif !handleColors!(d, arg, :fillcolor)
|
||||
|
||||
|
||||
d[:fillrange] = arg
|
||||
end
|
||||
end
|
||||
@ -801,5 +804,3 @@ function getSeriesArgs(pkg::AbstractBackend, plotargs::Dict, kw, commandIndex::I
|
||||
|
||||
d
|
||||
end
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -81,7 +81,7 @@ supportedArgs(::GadflyBackend) = [
|
||||
supportedAxes(::GadflyBackend) = [:auto, :left]
|
||||
supportedTypes(::GadflyBackend) = [:none, :line, :path, :steppre, :steppost, :sticks,
|
||||
:scatter, :hist2d, :hexbin, :hist, :bar,
|
||||
:hline, :vline, :contour]
|
||||
:hline, :vline, :contour, :shape]
|
||||
supportedStyles(::GadflyBackend) = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot]
|
||||
supportedMarkers(::GadflyBackend) = vcat(_allMarkers, Shape)
|
||||
supportedScales(::GadflyBackend) = [:identity, :ln, :log2, :log10, :asinh, :sqrt]
|
||||
@ -770,4 +770,3 @@ supportedStyles(::PGFPlotsBackend) = [:auto, :solid] #, :dash, :dot, :dashdot, :
|
||||
supportedMarkers(::PGFPlotsBackend) = [:none, :auto, :ellipse] #, :rect, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star5] #vcat(_allMarkers, Shape)
|
||||
supportedScales(::PGFPlotsBackend) = [:identity] #, :log, :log2, :log10, :asinh, :sqrt]
|
||||
subplotSupported(::PGFPlotsBackend) = false
|
||||
|
||||
|
||||
@ -3,6 +3,9 @@ immutable Shape
|
||||
vertices::AVec
|
||||
end
|
||||
|
||||
get_xs(shape::Shape) = Float64[v[1] for v in shape.vertices]
|
||||
get_ys(shape::Shape) = Float64[v[2] for v in shape.vertices]
|
||||
|
||||
"get an array of tuples of points on a circle with radius `r`"
|
||||
function partialcircle(start_θ, end_θ, n = 20, r=1)
|
||||
@compat(Tuple{Float64,Float64})[(r*cos(u),r*sin(u)) for u in linspace(start_θ, end_θ, n)]
|
||||
@ -48,7 +51,7 @@ function makecross(; offset = -0.5, radius = 1.0)
|
||||
z1 = z2 - π/8
|
||||
outercircle = partialcircle(z1, z1 + 2π, 9, radius)
|
||||
innercircle = partialcircle(z2, z2 + 2π, 5, 0.5radius)
|
||||
Shape(weave(outercircle, innercircle,
|
||||
Shape(weave(outercircle, innercircle,
|
||||
ordering=Vector[outercircle,innercircle,outercircle])[1:end-2])
|
||||
end
|
||||
|
||||
@ -87,7 +90,7 @@ end
|
||||
|
||||
"Create a Font from a list of unordered features"
|
||||
function font(args...)
|
||||
|
||||
|
||||
# defaults
|
||||
family = "Helvetica"
|
||||
pointsize = 14
|
||||
@ -266,7 +269,7 @@ end
|
||||
BezierCurve,
|
||||
curve_points,
|
||||
directed_curve
|
||||
|
||||
|
||||
typealias P2 FixedSizeArrays.Vec{2,Float64}
|
||||
typealias P3 FixedSizeArrays.Vec{3,Float64}
|
||||
|
||||
@ -298,7 +301,7 @@ end
|
||||
miny, maxy = minimum(yview), maximum(yview)
|
||||
diffpct = P2(diff[1] / (maxx - minx),
|
||||
diff[2] / (maxy - miny))
|
||||
|
||||
|
||||
# these points give the initial/final "rise"
|
||||
# vertical_offset = P2(0, (maxy - miny) * max(0.03, min(abs(0.5diffpct[2]), 1.0)))
|
||||
vertical_offset = P2(0, max(0.15, 0.5norm(diff)))
|
||||
@ -319,7 +322,7 @@ end
|
||||
else
|
||||
[]
|
||||
end
|
||||
|
||||
|
||||
BezierCurve([p, upper_control, inside_control_points..., lower_control, q])
|
||||
end
|
||||
|
||||
|
||||
31
src/plot.jl
31
src/plot.jl
@ -444,6 +444,37 @@ function createKWargsList{T<:Real}(plt::AbstractPlot, x::AMat{T}, y::AMat{T}, zm
|
||||
createKWargsList(plt, Any[x], Any[y]; d...) #kw..., z = surf, linetype = :contour)
|
||||
end
|
||||
|
||||
# plotting arbitrary shapes/polygons
|
||||
function createKWargsList(plt::AbstractPlot, shape::Shape; kw...)
|
||||
x, y = unzip(shape.vertices)
|
||||
createKWargsList(plt, x, y; linetype = :shape, kw...)
|
||||
end
|
||||
|
||||
function shape_coords(shapes::AVec{Shape})
|
||||
xs = map(get_xs, shapes)
|
||||
ys = map(get_ys, shapes)
|
||||
x, y = unzip(shapes[1].vertices)
|
||||
for shape in shapes[2:end]
|
||||
tmpx, tmpy = unzip(shape.vertices)
|
||||
x = vcat(x, NaN, tmpx)
|
||||
y = vcat(y, NaN, tmpy)
|
||||
end
|
||||
x, y
|
||||
end
|
||||
|
||||
function createKWargsList(plt::AbstractPlot, shapes::AVec{Shape}; kw...)
|
||||
x, y = shape_coords(shapes)
|
||||
createKWargsList(plt, x, y; linetype = :shape, kw...)
|
||||
end
|
||||
function createKWargsList(plt::AbstractPlot, shapes::AMat{Shape}; kw...)
|
||||
x, y = [], []
|
||||
for j in 1:size(shapes, 2)
|
||||
tmpx, tmpy = shape_coords(vec(shapes[:,j]))
|
||||
push!(x, tmpx)
|
||||
push!(y, tmpy)
|
||||
end
|
||||
createKWargsList(plt, x, y; linetype = :shape, kw...)
|
||||
end
|
||||
|
||||
function createKWargsList(plt::AbstractPlot, surf::Surface; kw...)
|
||||
createKWargsList(plt, 1:size(surf.surf,1), 1:size(surf.surf,2), convert(Matrix{Float64}, surf.surf); kw...)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user