added hline/vline support in gadfly
This commit is contained in:
parent
c5300cd7be
commit
ea7867429f
28
src/Plots.jl
28
src/Plots.jl
@ -6,30 +6,32 @@ using Colors
|
|||||||
|
|
||||||
export
|
export
|
||||||
plotter,
|
plotter,
|
||||||
plot,
|
|
||||||
plot_display,
|
|
||||||
subplot,
|
|
||||||
|
|
||||||
plotter!,
|
plotter!,
|
||||||
|
plot,
|
||||||
plot!,
|
plot!,
|
||||||
|
plot_display,
|
||||||
plot_display!,
|
plot_display!,
|
||||||
|
subplot,
|
||||||
subplot!,
|
subplot!,
|
||||||
|
|
||||||
currentPlot,
|
currentPlot,
|
||||||
plotDefault,
|
|
||||||
scatter,
|
|
||||||
bar,
|
|
||||||
histogram,
|
|
||||||
heatmap,
|
|
||||||
sticks,
|
|
||||||
|
|
||||||
currentPlot!,
|
currentPlot!,
|
||||||
|
plotDefault,
|
||||||
plotDefault!,
|
plotDefault!,
|
||||||
|
scatter,
|
||||||
scatter!,
|
scatter!,
|
||||||
|
bar,
|
||||||
bar!,
|
bar!,
|
||||||
|
histogram,
|
||||||
histogram!,
|
histogram!,
|
||||||
|
heatmap,
|
||||||
heatmap!,
|
heatmap!,
|
||||||
|
sticks,
|
||||||
sticks!,
|
sticks!,
|
||||||
|
hline,
|
||||||
|
hline!,
|
||||||
|
vline,
|
||||||
|
vline!,
|
||||||
|
|
||||||
savepng,
|
savepng,
|
||||||
|
|
||||||
@ -70,6 +72,10 @@ heatmap(args...; kw...) = plot(args...; kw..., linetype = :heatmap)
|
|||||||
heatmap!(args...; kw...) = plot!(args...; kw..., linetype = :heatmap)
|
heatmap!(args...; kw...) = plot!(args...; kw..., linetype = :heatmap)
|
||||||
sticks(args...; kw...) = plot(args...; kw..., linetype = :sticks, marker = :ellipse)
|
sticks(args...; kw...) = plot(args...; kw..., linetype = :sticks, marker = :ellipse)
|
||||||
sticks!(args...; kw...) = plot!(args...; kw..., linetype = :sticks, marker = :ellipse)
|
sticks!(args...; kw...) = plot!(args...; kw..., linetype = :sticks, marker = :ellipse)
|
||||||
|
hline(args...; kw...) = plot(args...; kw..., linetype = :hline)
|
||||||
|
hline!(args...; kw...) = plot!(args...; kw..., linetype = :hline)
|
||||||
|
vline(args...; kw...) = plot(args...; kw..., linetype = :vline)
|
||||||
|
vline!(args...; kw...) = plot!(args...; kw..., linetype = :vline)
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
|
|||||||
19
src/args.jl
19
src/args.jl
@ -5,7 +5,18 @@
|
|||||||
|
|
||||||
const COLORS = distinguishable_colors(20)
|
const COLORS = distinguishable_colors(20)
|
||||||
const AXES = [:left, :right]
|
const AXES = [:left, :right]
|
||||||
const TYPES = [:line, :step, :stepinverted, :sticks, :scatter, :heatmap, :hexbin, :hist, :bar]
|
const TYPES = [:line,
|
||||||
|
:step,
|
||||||
|
:stepinverted,
|
||||||
|
:sticks,
|
||||||
|
:scatter,
|
||||||
|
:heatmap,
|
||||||
|
:hexbin,
|
||||||
|
:hist,
|
||||||
|
:bar,
|
||||||
|
:hline,
|
||||||
|
:vline,
|
||||||
|
]
|
||||||
const STYLES = [:solid, :dash, :dot, :dashdot, :dashdotdot]
|
const STYLES = [:solid, :dash, :dot, :dashdot, :dashdotdot]
|
||||||
const MARKERS = [:ellipse, :rect, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star1, :star2, :hexagon]
|
const MARKERS = [:ellipse, :rect, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star1, :star2, :hexagon]
|
||||||
|
|
||||||
@ -207,3 +218,9 @@ function getPlotKeywordArgs(pkg::PlottingPackage, kw, idx::Int, n::Int)
|
|||||||
d
|
d
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: arg aliases
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@ gadfly!() = plotter!(:gadfly)
|
|||||||
|
|
||||||
supportedArgs(::GadflyPackage) = setdiff(ARGS, [:heatmap_c, :fillto, :pos])
|
supportedArgs(::GadflyPackage) = setdiff(ARGS, [:heatmap_c, :fillto, :pos])
|
||||||
supportedAxes(::GadflyPackage) = setdiff(ALL_AXES, [:right])
|
supportedAxes(::GadflyPackage) = setdiff(ALL_AXES, [:right])
|
||||||
supportedTypes(::GadflyPackage) = setdiff(ALL_TYPES, [:stepinverted])
|
supportedTypes(::GadflyPackage) = [:none, :line, :step, :sticks, :scatter, :heatmap, :hexbin, :hist, :bar, :hline, :vline]
|
||||||
supportedStyles(::GadflyPackage) = [:auto, :solid]
|
supportedStyles(::GadflyPackage) = [:auto, :solid]
|
||||||
supportedMarkers(::GadflyPackage) = [:none, :auto, :rect, :ellipse, :diamond, :cross]
|
supportedMarkers(::GadflyPackage) = [:none, :auto, :rect, :ellipse, :diamond, :cross]
|
||||||
|
|
||||||
@ -120,6 +120,25 @@ end
|
|||||||
# end
|
# end
|
||||||
|
|
||||||
|
|
||||||
|
function addGadflyFixedLines!(gplt, d::Dict)
|
||||||
|
|
||||||
|
sz = d[:width] * Gadfly.px
|
||||||
|
c = d[:color]
|
||||||
|
|
||||||
|
if d[:linetype] == :hline
|
||||||
|
geom = Gadfly.Geom.hline(color=c, size=sz)
|
||||||
|
layer = Gadfly.layer(yintercept = d[:y], geom)
|
||||||
|
else
|
||||||
|
geom = Gadfly.Geom.vline(color=c, size=sz)
|
||||||
|
layer = Gadfly.layer(xintercept = d[:y], geom)
|
||||||
|
end
|
||||||
|
|
||||||
|
prepend!(gplt.layers, layer)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function addGadflySeries!(gplt, d::Dict)
|
function addGadflySeries!(gplt, d::Dict)
|
||||||
|
|
||||||
# first things first... lets so the sticks hack
|
# first things first... lets so the sticks hack
|
||||||
@ -130,6 +149,10 @@ function addGadflySeries!(gplt, d::Dict)
|
|||||||
if dScatter[:marker] != :none
|
if dScatter[:marker] != :none
|
||||||
push!(gplt.guides, createGadflyAnnotation(dScatter))
|
push!(gplt.guides, createGadflyAnnotation(dScatter))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
elseif d[:linetype] in (:hline, :vline)
|
||||||
|
addGadflyFixedLines!(gplt, d)
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
gfargs = []
|
gfargs = []
|
||||||
|
|||||||
@ -10,7 +10,7 @@ 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) = ALL_TYPES
|
supportedTypes(::PyPlotPackage) = [:none, :line, :step, :stepinverted, :sticks, :scatter, :heatmap, :hexbin, :hist, :bar]
|
||||||
supportedStyles(::PyPlotPackage) = setdiff(ALL_STYLES, [:dashdotdot])
|
supportedStyles(::PyPlotPackage) = setdiff(ALL_STYLES, [:dashdotdot])
|
||||||
supportedMarkers(::PyPlotPackage) = setdiff(ALL_MARKERS, [:star2])
|
supportedMarkers(::PyPlotPackage) = setdiff(ALL_MARKERS, [:star2])
|
||||||
subplotSupported(::PyPlotPackage) = false
|
subplotSupported(::PyPlotPackage) = false
|
||||||
|
|||||||
@ -6,6 +6,8 @@ immutable QwtPackage <: PlottingPackage end
|
|||||||
export qwt!
|
export qwt!
|
||||||
qwt!() = plotter!(:qwt)
|
qwt!() = plotter!(:qwt)
|
||||||
|
|
||||||
|
supportedTypes(::QwtPackage) = [:none, :line, :step, :stepinverted, :sticks, :scatter, :heatmap, :hexbin, :hist, :bar]
|
||||||
|
|
||||||
# -------------------------------
|
# -------------------------------
|
||||||
|
|
||||||
function adjustQwtKeywords(iscreating::Bool; kw...)
|
function adjustQwtKeywords(iscreating::Bool; kw...)
|
||||||
|
|||||||
@ -10,7 +10,7 @@ unicodeplots!() = plotter!(:unicodeplots)
|
|||||||
|
|
||||||
supportedArgs(::UnicodePlotsPackage) = setdiff(ARGS, [:reg, :heatmap_c, :fillto, :pos])
|
supportedArgs(::UnicodePlotsPackage) = setdiff(ARGS, [:reg, :heatmap_c, :fillto, :pos])
|
||||||
supportedAxes(::UnicodePlotsPackage) = [:auto, :left]
|
supportedAxes(::UnicodePlotsPackage) = [:auto, :left]
|
||||||
supportedTypes(::UnicodePlotsPackage) = setdiff(ALL_TYPES, [:stepinverted])
|
supportedTypes(::UnicodePlotsPackage) = [:none, :line, :step, :sticks, :scatter, :heatmap, :hexbin, :hist, :bar, :hline, :vline]
|
||||||
supportedStyles(::UnicodePlotsPackage) = [:auto, :solid]
|
supportedStyles(::UnicodePlotsPackage) = [:auto, :solid]
|
||||||
supportedMarkers(::UnicodePlotsPackage) = [:none, :auto, :ellipse]
|
supportedMarkers(::UnicodePlotsPackage) = [:none, :auto, :ellipse]
|
||||||
|
|
||||||
|
|||||||
@ -142,7 +142,7 @@ function plotter()
|
|||||||
error("Unknown plotter $currentBackendSymbol. Choose from: $BACKENDS")
|
error("Unknown plotter $currentBackendSymbol. Choose from: $BACKENDS")
|
||||||
end
|
end
|
||||||
push!(INITIALIZED_BACKENDS, currentBackendSymbol)
|
push!(INITIALIZED_BACKENDS, currentBackendSymbol)
|
||||||
println("[Plots.jl] done.")
|
# println("[Plots.jl] done.")
|
||||||
|
|
||||||
end
|
end
|
||||||
CURRENT_BACKEND.pkg
|
CURRENT_BACKEND.pkg
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user