working on shapes overhaul
This commit is contained in:
parent
4fa697ec75
commit
ac1ce03fe5
@ -236,7 +236,7 @@ __Tip__: When plotting multiple lines, you can set all series to use the same va
|
||||
```julia
|
||||
plot(rand(100,4); color = [:red RGB(0,0,1)], # (Matrix) lines 1 and 3 are red, lines 2 and 4 are blue
|
||||
axis = :auto, # lines 1 and 3 are on the left axis, lines 2 and 4 are on the right
|
||||
markershape = [:rect, :star1] # (Vector) ALL lines are passed the vector [:rect, :star1]
|
||||
markershape = [:rect, :star] # (Vector) ALL lines are passed the vector [:rect, :star1]
|
||||
width = 5) # all lines have a width of 5
|
||||
```
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
15
src/args.jl
15
src/args.jl
@ -37,8 +37,9 @@ const _allStyles = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot]
|
||||
:ddd => :dashdotdot,
|
||||
)
|
||||
|
||||
const _allMarkers = [:none, :auto, :ellipse, :rect, :diamond, :utriangle, :dtriangle,
|
||||
:cross, :xcross, :star1, :star2, :hexagon, :octagon, Shape]
|
||||
# const _allMarkers = [:none, :auto, :ellipse, :rect, :diamond, :utriangle, :dtriangle,
|
||||
# :cross, :xcross, :star5, :star8, :hexagon, :octagon, Shape]
|
||||
const _allMarkers = hcat(:none, :auto, sortedKeys(_shapes))
|
||||
@compat const _markerAliases = Dict(
|
||||
:n => :none,
|
||||
:no => :none,
|
||||
@ -64,9 +65,13 @@ const _allMarkers = [:none, :auto, :ellipse, :rect, :diamond, :utriangle, :dtria
|
||||
:plus => :cross,
|
||||
:x => :xcross,
|
||||
:X => :xcross,
|
||||
:star => :star1,
|
||||
:s => :star1,
|
||||
:s2 => :star2,
|
||||
:star => :star5,
|
||||
:s => :star5,
|
||||
:star1 => :star5,
|
||||
:s2 => :star8,
|
||||
:star2 => :star8,
|
||||
:p => :pentagon,
|
||||
:pent => :pentagon,
|
||||
:h => :hexagon,
|
||||
:hex => :hexagon,
|
||||
:o => :octagon,
|
||||
|
||||
@ -60,7 +60,8 @@ supportedArgs(::GadflyPackage) = [
|
||||
supportedAxes(::GadflyPackage) = [:auto, :left]
|
||||
supportedTypes(::GadflyPackage) = [:none, :line, :path, :steppost, :sticks, :scatter, :heatmap, :hexbin, :hist, :bar, :hline, :vline, :ohlc]
|
||||
supportedStyles(::GadflyPackage) = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot]
|
||||
supportedMarkers(::GadflyPackage) = [:none, :auto, :rect, :ellipse, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star1, :star2, :hexagon, :octagon, Shape]
|
||||
# supportedMarkers(::GadflyPackage) = [:none, :auto, :rect, :ellipse, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star1, :star2, :hexagon, :octagon, Shape]
|
||||
supportedMarkers(::GadflyPackage) = hcat(:none, :auto, sortedKeys(_shapes))
|
||||
supportedScales(::GadflyPackage) = [:identity, :log, :log2, :log10, :asinh, :sqrt]
|
||||
|
||||
|
||||
@ -147,11 +148,14 @@ function getMarkerGeoms(d::Dict)
|
||||
shape = d[:markershape]
|
||||
isa(shape, Shape) && return [gadflyshape(shape)]
|
||||
shape == :none && return Any[]
|
||||
shape == :ellipse && return [Gadfly.Geom.point]
|
||||
shape == :rect && return [gadflyshape(_square)]
|
||||
shape == :diamond && return [gadflyshape(_diamond)]
|
||||
shape == :cross && return [gadflyshape(_cross)]
|
||||
error("unhandled marker: ", shape)
|
||||
if !haskey(_shapes, shape)
|
||||
error("unhandled marker: ", shape)
|
||||
end
|
||||
[gadflyshape(_shapes[shape])]
|
||||
# shape == :ellipse && return [Gadfly.Geom.point]
|
||||
# shape == :rect && return [gadflyshape(_square)]
|
||||
# shape == :diamond && return [gadflyshape(_diamond)]
|
||||
# shape == :cross && return [gadflyshape(_cross)]
|
||||
end
|
||||
|
||||
|
||||
|
||||
@ -62,7 +62,7 @@ supportedArgs(::PyPlotPackage) = [
|
||||
supportedAxes(::PyPlotPackage) = _allAxes
|
||||
supportedTypes(::PyPlotPackage) = [:none, :line, :path, :step, :stepinverted, :sticks, :scatter, :heatmap, :hexbin, :hist, :bar, :hline, :vline]
|
||||
supportedStyles(::PyPlotPackage) = [:auto, :solid, :dash, :dot, :dashdot]
|
||||
supportedMarkers(::PyPlotPackage) = [:none, :auto, :rect, :ellipse, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star1, :hexagon]
|
||||
supportedMarkers(::PyPlotPackage) = [:none, :auto, :rect, :ellipse, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star5, :hexagon]
|
||||
supportedScales(::PyPlotPackage) = [:identity, :log, :log2, :log10]
|
||||
subplotSupported(::PyPlotPackage) = true
|
||||
|
||||
@ -96,7 +96,7 @@ function getPyPlotMarker(marker::Symbol)
|
||||
marker == :dtriangle && return "v"
|
||||
marker == :cross && return "+"
|
||||
marker == :xcross && return "x"
|
||||
marker == :star1 && return "*"
|
||||
marker == :star5 && return "*"
|
||||
marker == :hexagon && return "h"
|
||||
warn("Unknown marker $marker")
|
||||
return "o"
|
||||
|
||||
@ -56,7 +56,7 @@ supportedArgs(::QwtPackage) = [
|
||||
# :z,
|
||||
]
|
||||
supportedTypes(::QwtPackage) = [:none, :line, :path, :steppre, :steppost, :sticks, :scatter, :heatmap, :hexbin, :hist, :bar, :hline, :vline]
|
||||
supportedMarkers(::QwtPackage) = [:none, :auto, :rect, :ellipse, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star1, :star2, :hexagon]
|
||||
supportedMarkers(::QwtPackage) = [:none, :auto, :rect, :ellipse, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star5, :star8, :hexagon]
|
||||
supportedScales(::QwtPackage) = [:identity, :log10]
|
||||
|
||||
# -------------------------------
|
||||
@ -70,9 +70,10 @@ supportedScales(::QwtPackage) = [:identity, :log10]
|
||||
:path => :line,
|
||||
:steppost => :step,
|
||||
:steppre => :stepinverted,
|
||||
:star5 => :star1,
|
||||
:star8 => :star2,
|
||||
)
|
||||
|
||||
|
||||
function fixcolors(d::Dict)
|
||||
for (k,v) in d
|
||||
if typeof(v) <: ColorScheme
|
||||
@ -81,9 +82,9 @@ function fixcolors(d::Dict)
|
||||
end
|
||||
end
|
||||
|
||||
function replaceLinetypeAlias(d)
|
||||
if haskey(_qwtAliases, d[:linetype])
|
||||
d[:linetype] = _qwtAliases[d[:linetype]]
|
||||
function replaceQwtAliases(d, s)
|
||||
if haskey(_qwtAliases, d[s])
|
||||
d[s] = _qwtAliases[d[s]]
|
||||
end
|
||||
end
|
||||
|
||||
@ -111,7 +112,8 @@ function adjustQwtKeywords(plt::Plot{QwtPackage}, iscreating::Bool; kw...)
|
||||
d = barHack(; histogramHack(; kw...)...)
|
||||
end
|
||||
|
||||
replaceLinetypeAlias(d)
|
||||
replaceQwtAliases(d, :linetype)
|
||||
replaceQwtAliases(d, :markershape)
|
||||
|
||||
for k in keys(d)
|
||||
if haskey(_qwtAliases, k)
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
:dtriangle=>"down-triangle",
|
||||
:cross => "plus",
|
||||
:xcross => "cross",
|
||||
:star1 => "asterisk"
|
||||
:star5 => "asterisk"
|
||||
)
|
||||
|
||||
|
||||
@ -81,7 +81,7 @@ supportedArgs(::WinstonPackage) = [
|
||||
supportedAxes(::WinstonPackage) = [:auto, :left]
|
||||
supportedTypes(::WinstonPackage) = [:none, :line, :path, :sticks, :scatter, :hist, :bar]
|
||||
supportedStyles(::WinstonPackage) = [:auto, :solid, :dash, :dot, :dashdot]
|
||||
supportedMarkers(::WinstonPackage) = [:none, :auto, :rect, :ellipse, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star1]
|
||||
supportedMarkers(::WinstonPackage) = [:none, :auto, :rect, :ellipse, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star5]
|
||||
supportedScales(::WinstonPackage) = [:identity, :log10]
|
||||
subplotSupported(::WinstonPackage) = false
|
||||
|
||||
|
||||
124
src/types.jl
124
src/types.jl
@ -51,37 +51,37 @@ immutable Shape
|
||||
vertices::AVec
|
||||
end
|
||||
|
||||
const _square = Shape(@compat(Tuple{Float64,Float64})[
|
||||
( 1.0, -1.0),
|
||||
( 1.0, 1.0),
|
||||
(-1.0, 1.0),
|
||||
(-1.0, -1.0)
|
||||
])
|
||||
# const _square = Shape(@compat(Tuple{Float64,Float64})[
|
||||
# ( 1.0, -1.0),
|
||||
# ( 1.0, 1.0),
|
||||
# (-1.0, 1.0),
|
||||
# (-1.0, -1.0)
|
||||
# ])
|
||||
|
||||
const _diamond = Shape(@compat(Tuple{Float64,Float64})[
|
||||
( 0.0, -1.0),
|
||||
( 1.0, 0.0),
|
||||
( 0.0, 1.0),
|
||||
(-1.0, 0.0)
|
||||
])
|
||||
# const _diamond = Shape(@compat(Tuple{Float64,Float64})[
|
||||
# ( 0.0, -1.0),
|
||||
# ( 1.0, 0.0),
|
||||
# ( 0.0, 1.0),
|
||||
# (-1.0, 0.0)
|
||||
# ])
|
||||
|
||||
const _cross = Shape(@compat(Tuple{Float64,Float64})[
|
||||
(-1.0, -0.4), (-1.0, 0.4), # L edge
|
||||
(-0.4, 0.4), # BL inside
|
||||
(-0.4, 1.0), ( 0.4, 1.0), # B edge
|
||||
( 0.4, 0.4), # BR inside
|
||||
( 1.0, 0.4), ( 1.0, -0.4), # R edge
|
||||
( 0.4, -0.4), # TR inside
|
||||
( 0.4, -1.0), (-0.4, -1.0), # T edge
|
||||
(-0.4, -0.4) # TL inside
|
||||
])
|
||||
# const _cross = Shape(@compat(Tuple{Float64,Float64})[
|
||||
# (-1.0, -0.4), (-1.0, 0.4), # L edge
|
||||
# (-0.4, 0.4), # BL inside
|
||||
# (-0.4, 1.0), ( 0.4, 1.0), # B edge
|
||||
# ( 0.4, 0.4), # BR inside
|
||||
# ( 1.0, 0.4), ( 1.0, -0.4), # R edge
|
||||
# ( 0.4, -0.4), # TR inside
|
||||
# ( 0.4, -1.0), (-0.4, -1.0), # T edge
|
||||
# (-0.4, -0.4) # TL inside
|
||||
# ])
|
||||
|
||||
const _xcross = Shape(@compat(Tuple{Float64,Float64})[
|
||||
(x, y - u), (x + u, y - 2u), (x + 2u, y - u),
|
||||
(x + u, y), (x + 2u, y + u), (x + u, y + 2u),
|
||||
(x, y + u), (x - u, y + 2u), (x - 2u, y + u),
|
||||
(x - u, y), (x - 2u, y - u), (x - u, y - 2u)
|
||||
]
|
||||
# const _xcross = Shape(@compat(Tuple{Float64,Float64})[
|
||||
# (x, y - u), (x + u, y - 2u), (x + 2u, y - u),
|
||||
# (x + u, y), (x + 2u, y + u), (x + u, y + 2u),
|
||||
# (x, y + u), (x - u, y + 2u), (x - 2u, y + u),
|
||||
# (x - u, y), (x - 2u, y - u), (x - u, y - 2u)
|
||||
# ]
|
||||
|
||||
|
||||
# function xcross(xs::AbstractArray, ys::AbstractArray, rs::AbstractArray)
|
||||
@ -105,11 +105,11 @@ const _xcross = Shape(@compat(Tuple{Float64,Float64})[
|
||||
# end
|
||||
|
||||
|
||||
const _utriangle = Shape(@compat(Tuple{Float64,Float64})[
|
||||
(x - r, y + u),
|
||||
(x + r, y + u),
|
||||
(x, y - u)
|
||||
]
|
||||
# const _utriangle = Shape(@compat(Tuple{Float64,Float64})[
|
||||
# (x - r, y + u),
|
||||
# (x + r, y + u),
|
||||
# (x, y - u)
|
||||
# ]
|
||||
|
||||
# function utriangle(xs::AbstractArray, ys::AbstractArray, rs::AbstractArray, scalar = 1)
|
||||
# n = max(length(xs), length(ys), length(rs))
|
||||
@ -136,7 +136,7 @@ function partialcircle(start_θ, end_θ, n = 20, r=1)
|
||||
end
|
||||
|
||||
"interleave 2 vectors into each other (like a zipper's teeth)"
|
||||
function weave(x,y; ordering = [x,y])
|
||||
function weave(x,y; ordering = Vector[x,y])
|
||||
ret = eltype(x)[]
|
||||
done = false
|
||||
while !done
|
||||
@ -166,16 +166,17 @@ end
|
||||
"create a shape by picking points around the unit circle. `n` is the number of point/sides, `offset` is the starting angle"
|
||||
function makeshape(n; offset = -0.5, radius = 1.0)
|
||||
z = offset * π
|
||||
Shape(Plots.partialcircle(z, z + 2π, n+1, radius)[1:end-1])
|
||||
Shape(partialcircle(z, z + 2π, n+1, radius)[1:end-1])
|
||||
end
|
||||
|
||||
|
||||
function makecross(; offset = -0.5, radius = 1.0)
|
||||
z1 = offset * π + π/8
|
||||
z2 = z1 + π/8
|
||||
z2 = offset * π
|
||||
z1 = z2 - π/8
|
||||
outercircle = partialcircle(z1, z1 + 2π, 9, radius)
|
||||
innercircle = partialcircle(z2, z2 + 2π, 5, 0.4radius)
|
||||
Shape(weave(outercircle, innercircle)[1:end-2])
|
||||
innercircle = partialcircle(z2, z2 + 2π, 5, 0.5radius)
|
||||
Shape(weave(outercircle, innercircle,
|
||||
ordering=Vector[outercircle,innercircle,outercircle])[1:end-2])
|
||||
end
|
||||
|
||||
|
||||
@ -189,7 +190,8 @@ const _shapes = Dict(
|
||||
:hexagon => makeshape(6),
|
||||
:septagon => makeshape(7),
|
||||
:octagon => makeshape(8),
|
||||
|
||||
:cross => makecross(offset=-0.25),
|
||||
:xcross => makecross(),
|
||||
)
|
||||
|
||||
for n in [4,5,6,7,8]
|
||||
@ -203,34 +205,34 @@ end
|
||||
|
||||
|
||||
|
||||
const _xcross = Shape(@compat(Tuple{Float64,Float64})[
|
||||
]
|
||||
# const _xcross = Shape(@compat(Tuple{Float64,Float64})[
|
||||
# ]
|
||||
|
||||
# function hexagon(xs::AbstractArray, ys::AbstractArray, rs::AbstractArray)
|
||||
# n = max(length(xs), length(ys), length(rs))
|
||||
# # function hexagon(xs::AbstractArray, ys::AbstractArray, rs::AbstractArray)
|
||||
# # n = max(length(xs), length(ys), length(rs))
|
||||
|
||||
# polys = Array(Vector{@compat(Tuple{Compose.Measure, Compose.Measure})}, n)
|
||||
# for i in 1:n
|
||||
# x = Compose.x_measure(xs[mod1(i, length(xs))])
|
||||
# y = Compose.y_measure(ys[mod1(i, length(ys))])
|
||||
# r = rs[mod1(i, length(rs))]
|
||||
# u = 0.6r
|
||||
# # polys = Array(Vector{@compat(Tuple{Compose.Measure, Compose.Measure})}, n)
|
||||
# # for i in 1:n
|
||||
# # x = Compose.x_measure(xs[mod1(i, length(xs))])
|
||||
# # y = Compose.y_measure(ys[mod1(i, length(ys))])
|
||||
# # r = rs[mod1(i, length(rs))]
|
||||
# # u = 0.6r
|
||||
|
||||
# polys[i] = [
|
||||
# (x-r, y-u), (x-r, y+u), # L edge
|
||||
# (x, y+r), # B
|
||||
# (x+r, y+u), (x+r, y-u), # R edge
|
||||
# (x, y-r) # T
|
||||
# ]
|
||||
# end
|
||||
# # polys[i] = [
|
||||
# # (x-r, y-u), (x-r, y+u), # L edge
|
||||
# # (x, y+r), # B
|
||||
# # (x+r, y+u), (x+r, y-u), # R edge
|
||||
# # (x, y-r) # T
|
||||
# # ]
|
||||
# # end
|
||||
|
||||
# return Gadfly.polygon(polys)
|
||||
# end
|
||||
# # return Gadfly.polygon(polys)
|
||||
# # end
|
||||
|
||||
|
||||
|
||||
const _xcross = Shape(@compat(Tuple{Float64,Float64})[
|
||||
]
|
||||
# const _xcross = Shape(@compat(Tuple{Float64,Float64})[
|
||||
# ]
|
||||
|
||||
# function octagon(xs::AbstractArray, ys::AbstractArray, rs::AbstractArray)
|
||||
# n = max(length(xs), length(ys), length(rs))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user