fixing markers

This commit is contained in:
Thomas Breloff 2015-09-17 15:44:01 -04:00
parent f674bba861
commit 168b77326b
4 changed files with 40 additions and 39 deletions

View File

@ -61,7 +61,7 @@ const examples = PlotExample[
[:(styles = setdiff(supportedStyles(), [:auto])), :(plot(rand(20,length(styles)); linestyle=:auto, labels=map(string,styles)))]), [:(styles = setdiff(supportedStyles(), [:auto])), :(plot(rand(20,length(styles)); linestyle=:auto, labels=map(string,styles)))]),
PlotExample("Supported marker types", PlotExample("Supported marker types",
"All options: (:none, :auto, :ellipse, :rect, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star1, :star2, :hexagon)", "All options: (:none, :auto, :ellipse, :rect, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star1, :star2, :hexagon)",
[:(markers = setdiff(supportedMarkers(), [:none,:auto])), :(plot([fill(i-1,10) for i=1:length(markers)]; marker=:auto, labels=map(string,markers), markersize=10))]), [:(markers = setdiff(supportedMarkers(), [:none,:auto])), :(plot(0.5:9.5, [fill(i-0.5,10) for i=length(markers):-1:1]; marker=:auto, labels=map(string,markers), markersize=10))]),
PlotExample("Bar", PlotExample("Bar",
"x is the midpoint of the bar. (todo: allow passing of edges instead of midpoints)", "x is the midpoint of the bar. (todo: allow passing of edges instead of midpoints)",
[:(bar(randn(1000)))]), [:(bar(randn(1000)))]),

View File

@ -82,9 +82,36 @@ function diamond(xs::AbstractArray, ys::AbstractArray, rs::AbstractArray)
end end
function cross(xs::AbstractArray, ys::AbstractArray, rs::AbstractArray) function cross(xs::AbstractArray, ys::AbstractArray, rs::AbstractArray)
n = max(length(xs), length(ys), length(rs)) n = max(length(xs), length(ys), length(rs))
polys = Vector{Vector{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.4r
# make a "plus sign"
polys[i] = Tuple{Compose.Measure, Compose.Measure}[
(x-r, y-u), (x-r, y+u), # L edge
(x-u, y+u), # BL inside
(x-u, y+r), (x+u, y+r), # B edge
(x+u, y+u), # BR inside
(x+r, y+u), (x+r, y-u), # R edge
(x+u, y-u), # TR inside
(x+u, y-r), (x-u, y-r), # T edge
(x-u, y-u) # TL inside
]
end
return Gadfly.polygon(polys)
end
function xcross(xs::AbstractArray, ys::AbstractArray, rs::AbstractArray)
n = max(length(xs), length(ys), length(rs))
polys = Vector{Vector{Tuple{Compose.Measure, Compose.Measure}}}(n) polys = Vector{Vector{Tuple{Compose.Measure, Compose.Measure}}}(n)
s = 1/sqrt(5) s = 1/sqrt(5)
for i in 1:n for i in 1:n
@ -104,33 +131,6 @@ function cross(xs::AbstractArray, ys::AbstractArray, rs::AbstractArray)
end end
function xcross(xs::AbstractArray, ys::AbstractArray, rs::AbstractArray)
n = max(length(xs), length(ys), length(rs))
polys = Vector{Vector{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.4r
# make a "plus"
polys[i] = Tuple{Compose.Measure, Compose.Measure}[
(x-r, y-u), (x-r, y+u), # L edge
(x-u, y+u), # BL inside
(x-u, y+r), (x+u, y+r), # B edge
(x+u, y+u), # BR inside
(x+r, y+u), (x+r, y-u), # R edge
(x+u, y-u), # TR inside
(x+u, y-r), (x-u, y-r), # T edge
(x-u, y-u) # TL inside
]
end
return Gadfly.polygon(polys)
end
function utriangle(xs::AbstractArray, ys::AbstractArray, rs::AbstractArray, scalar = 1) function utriangle(xs::AbstractArray, ys::AbstractArray, rs::AbstractArray, scalar = 1)
n = max(length(xs), length(ys), length(rs)) n = max(length(xs), length(ys), length(rs))

View File

@ -11,8 +11,8 @@ pyplot!() = plotter!(:pyplot)
supportedArgs(::PyPlotPackage) = setdiff(ARGS, [:reg, :heatmap_c, :fillto, :pos]) supportedArgs(::PyPlotPackage) = setdiff(ARGS, [:reg, :heatmap_c, :fillto, :pos])
supportedAxes(::PyPlotPackage) = ALL_AXES supportedAxes(::PyPlotPackage) = ALL_AXES
supportedTypes(::PyPlotPackage) = [:none, :line, :step, :stepinverted, :sticks, :scatter, :heatmap, :hexbin, :hist, :bar] supportedTypes(::PyPlotPackage) = [:none, :line, :step, :stepinverted, :sticks, :scatter, :heatmap, :hexbin, :hist, :bar]
supportedStyles(::PyPlotPackage) = setdiff(ALL_STYLES, [:dashdotdot]) supportedStyles(::PyPlotPackage) = [:auto, :solid, :dash, :dot, :dashdot]
supportedMarkers(::PyPlotPackage) = setdiff(ALL_MARKERS, [:star2]) supportedMarkers(::PyPlotPackage) = [:none, :auto, :rect, :ellipse, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star1, :hexagon]
subplotSupported(::PyPlotPackage) = false subplotSupported(::PyPlotPackage) = false
# convert colorant to 4-tuple RGBA # convert colorant to 4-tuple RGBA
@ -37,8 +37,8 @@ function getPyPlotMarker(marker::Symbol)
marker == :diamond && return "D" marker == :diamond && return "D"
marker == :utriangle && return "^" marker == :utriangle && return "^"
marker == :dtriangle && return "v" marker == :dtriangle && return "v"
marker == :cross && return "x" marker == :cross && return "+"
marker == :xcross && return "+" marker == :xcross && return "x"
marker == :star1 && return "*" marker == :star1 && return "*"
# marker == :star2 && return "*" # marker == :star2 && return "*"
marker == :hexagon && return "h" marker == :hexagon && return "h"

View File

@ -16,27 +16,28 @@ const winston_linestyle = Dict(:solid=>"solid",
:dash=>"dash", :dash=>"dash",
:dot=>"dotted", :dot=>"dotted",
:dashdot=>"dotdashed", :dashdot=>"dotdashed",
:dashdotdot=>"dotdashed") # :dashdotdot=>"dotdashed"
)
const winston_marker = Dict(:none=>".", const winston_marker = Dict(:none=>".",
:ellipse=>"circle",
:rect => "square", :rect => "square",
:ellipse=>"circle",
:diamond=>"diamond", :diamond=>"diamond",
:utriangle=>"triangle", :utriangle=>"triangle",
:dtriangle=>"down-triangle", :dtriangle=>"down-triangle",
:cross => "cross", :cross => "cross",
:xcross => "cross", # :xcross => "cross",
:star1 => "asterisk", :star1 => "asterisk",
:star2 => "filled circle", # :star2 => "filled circle",
:hexagon => "asterisk" # :hexagon => "asterisk"
) )
supportedArgs(::WinstonPackage) = setdiff(ARGS, [:heatmap_c, :fillto, :pos, :markercolor, :background_color]) supportedArgs(::WinstonPackage) = setdiff(ARGS, [:heatmap_c, :fillto, :pos, :markercolor, :background_color])
supportedAxes(::WinstonPackage) = [:auto, :left] supportedAxes(::WinstonPackage) = [:auto, :left]
supportedTypes(::WinstonPackage) = [:none, :line, :sticks, :scatter, :hist, :bar] supportedTypes(::WinstonPackage) = [:none, :line, :sticks, :scatter, :hist, :bar]
supportedStyles(::WinstonPackage) = unshift!(collect(keys(winston_linestyle)), :auto) # vcat(:auto, keys(winston_linestyle)) supportedStyles(::WinstonPackage) = [:auto, :solid, :dash, :dot, :dashdot]
supportedMarkers(::WinstonPackage) = unshift!(collect(keys(winston_marker)), :auto) # vcat(:auto, collect(keys(winston_marker))) supportedMarkers(::WinstonPackage) = [:none, :auto, :rect, :ellipse, :diamond, :utriangle, :dtriangle, :cross, :star1]
subplotSupported(::WinstonPackage) = false subplotSupported(::WinstonPackage) = false
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------