lims/ticks for gadfly/immerse
This commit is contained in:
parent
80e8b5b5e4
commit
a207856e99
12
src/Plots.jl
12
src/Plots.jl
@ -39,6 +39,10 @@ export
|
|||||||
title!,
|
title!,
|
||||||
xlabel!,
|
xlabel!,
|
||||||
ylabel!,
|
ylabel!,
|
||||||
|
xlims!,
|
||||||
|
ylims!,
|
||||||
|
xticks!,
|
||||||
|
yticks!,
|
||||||
|
|
||||||
savepng,
|
savepng,
|
||||||
gui,
|
gui,
|
||||||
@ -95,10 +99,18 @@ ohlc!(args...; kw...) = plot!(args...; kw..., linetype = :ohlc)
|
|||||||
title!(s::AbstractString) = plot!(title = s)
|
title!(s::AbstractString) = plot!(title = s)
|
||||||
xlabel!(s::AbstractString) = plot!(xlabel = s)
|
xlabel!(s::AbstractString) = plot!(xlabel = s)
|
||||||
ylabel!(s::AbstractString) = plot!(ylabel = s)
|
ylabel!(s::AbstractString) = plot!(ylabel = s)
|
||||||
|
xlims!{T<:Real,S<:Real}(s::Tuple{T,S}) = plot!(xlims = s)
|
||||||
|
ylims!{T<:Real,S<:Real}(s::Tuple{T,S}) = plot!(ylims = s)
|
||||||
|
xticks!{T<:Real}(s::AVec{T}) = plot!(xticks = s)
|
||||||
|
yticks!{T<:Real}(s::AVec{T}) = plot!(yticks = s)
|
||||||
|
|
||||||
title!(plt::Plot, s::AbstractString) = plot!(plt; title = s)
|
title!(plt::Plot, s::AbstractString) = plot!(plt; title = s)
|
||||||
xlabel!(plt::Plot, s::AbstractString) = plot!(plt; xlabel = s)
|
xlabel!(plt::Plot, s::AbstractString) = plot!(plt; xlabel = s)
|
||||||
ylabel!(plt::Plot, s::AbstractString) = plot!(plt; ylabel = s)
|
ylabel!(plt::Plot, s::AbstractString) = plot!(plt; ylabel = s)
|
||||||
|
xlims!{T<:Real,S<:Real}(plt::Plot, s::Tuple{T,S}) = plot!(plt; xlims = s)
|
||||||
|
ylims!{T<:Real,S<:Real}(plt::Plot, s::Tuple{T,S}) = plot!(plt; ylims = s)
|
||||||
|
xticks!{T<:Real}(plt::Plot, s::AVec{T}) = plot!(plt; xticks = s)
|
||||||
|
yticks!{T<:Real}(plt::Plot, s::AVec{T}) = plot!(plt; yticks = s)
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
|
|||||||
@ -201,7 +201,11 @@ const _keyAliases = Dict(
|
|||||||
:fg_color => :foreground_color,
|
:fg_color => :foreground_color,
|
||||||
:foreground => :foreground_color,
|
:foreground => :foreground_color,
|
||||||
:xlim => :xlims,
|
:xlim => :xlims,
|
||||||
|
:xlimit => :xlims,
|
||||||
|
:xlimits => :xlims,
|
||||||
:ylim => :ylims,
|
:ylim => :ylims,
|
||||||
|
:ylimit => :ylims,
|
||||||
|
:ylimits => :ylims,
|
||||||
:xtick => :xticks,
|
:xtick => :xticks,
|
||||||
:ytick => :yticks,
|
:ytick => :yticks,
|
||||||
:windowsize => :size,
|
:windowsize => :size,
|
||||||
|
|||||||
@ -7,7 +7,7 @@ export gadfly!
|
|||||||
gadfly!() = plotter!(:gadfly)
|
gadfly!() = plotter!(:gadfly)
|
||||||
|
|
||||||
|
|
||||||
supportedArgs(::GadflyPackage) = setdiff(_allArgs, [:heatmap_c, :pos])
|
supportedArgs(::GadflyPackage) = setdiff(_allArgs, [:heatmap_c, :pos, :screen, :yrightlabel])
|
||||||
supportedAxes(::GadflyPackage) = setdiff(_allAxes, [:right])
|
supportedAxes(::GadflyPackage) = setdiff(_allAxes, [:right])
|
||||||
supportedTypes(::GadflyPackage) = [:none, :line, :path, :steppost, :sticks, :scatter, :heatmap, :hexbin, :hist, :bar, :hline, :vline, :ohlc]
|
supportedTypes(::GadflyPackage) = [:none, :line, :path, :steppost, :sticks, :scatter, :heatmap, :hexbin, :hist, :bar, :hline, :vline, :ohlc]
|
||||||
supportedStyles(::GadflyPackage) = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot]
|
supportedStyles(::GadflyPackage) = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot]
|
||||||
@ -162,9 +162,6 @@ function addGadflySeries!(gplt, d::Dict, initargs::Dict)
|
|||||||
(:ymin, Float64[min(y, fillto[mod1(i,n)]) for (i,y) in enumerate(d[:y])]),
|
(:ymin, Float64[min(y, fillto[mod1(i,n)]) for (i,y) in enumerate(d[:y])]),
|
||||||
(:ymax, Float64[max(y, fillto[mod1(i,n)]) for (i,y) in enumerate(d[:y])])
|
(:ymax, Float64[max(y, fillto[mod1(i,n)]) for (i,y) in enumerate(d[:y])])
|
||||||
]
|
]
|
||||||
# push!(d[:kwargs], (:ymin, Float64[min(y, fillto[mod1(i,n)]) for (i,y) in enumerate(d[:y])]))
|
|
||||||
# push!(d[:kwargs], (:ymax, Float64[max(y, fillto[mod1(i,n)]) for (i,y) in enumerate(d[:y])]))
|
|
||||||
# push!(d[:kwargs], (:ymax, Float64[max(y, fillto) for y in d[:y]]))
|
|
||||||
push!(gfargs, Gadfly.Geom.ribbon)
|
push!(gfargs, Gadfly.Geom.ribbon)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -193,38 +190,11 @@ function addGadflySeries!(gplt, d::Dict, initargs::Dict)
|
|||||||
|
|
||||||
|
|
||||||
# add the layer to the Gadfly.Plot
|
# add the layer to the Gadfly.Plot
|
||||||
# @show d[:kwargs]
|
|
||||||
# prepend!(gplt.layers, Gadfly.layer(unique(gfargs)..., d[:args]...; x = x, y = d[:y], d[:kwargs]...))
|
# prepend!(gplt.layers, Gadfly.layer(unique(gfargs)..., d[:args]...; x = x, y = d[:y], d[:kwargs]...))
|
||||||
prepend!(gplt.layers, Gadfly.layer(unique(gfargs)...; x = x, y = d[:y], yminmax...))
|
prepend!(gplt.layers, Gadfly.layer(unique(gfargs)...; x = x, y = d[:y], yminmax...))
|
||||||
# prepend!(gplt.layers, Gadfly.layer(unique(gfargs)...; x = x, y = d[:y]))
|
|
||||||
nothing
|
nothing
|
||||||
end
|
end
|
||||||
|
|
||||||
# function addTicksGuideOrScale(gplt, ticks, isx::Bool)
|
|
||||||
# ticks == :auto && return
|
|
||||||
# ttype = ticksType(ticks)
|
|
||||||
# if ttype == :limits
|
|
||||||
# minvalue = min(ticks...)
|
|
||||||
# maxvalue = max(ticks...)
|
|
||||||
# scale = (isx ? Gadfly.Scale.x_continuous : Gadfly.Scale.y_continuous)(minvalue=minvalue, maxvalue=maxvalue)
|
|
||||||
# push!(gplt.scales, scale)
|
|
||||||
# elseif ttype == :ticks
|
|
||||||
# # if isx
|
|
||||||
# # ticks = map(Compose.x_measure, sort(collect(ticks)))
|
|
||||||
# # push!(gplt.statistics, Gadfly.Stat.xticks(ticks=ticks))
|
|
||||||
# # else
|
|
||||||
# # ticks = map(Compose.y_measure, sort(collect(ticks)))
|
|
||||||
# # push!(gplt.statistics, Gadfly.Stat.yticks(ticks=ticks))
|
|
||||||
# # end
|
|
||||||
# ticks = sort(ticks)
|
|
||||||
# guide = (isx ? Gadfly.Guide.xticks : Gadfly.Guide.yticks)(ticks=ticks)
|
|
||||||
# push!(gplt.guides, guide)
|
|
||||||
# # stat = (isx ? Gadfly.Stat.xticks : Gadfly.Stat.yticks)(ticks=ticks)
|
|
||||||
# # push!(gplt.statistics, stat)
|
|
||||||
# else
|
|
||||||
# error("Invalid input for $(isx ? "xticks" : "yticks"): ", ticks)
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
|
|
||||||
function addTicksGuide(gplt, ticks, isx::Bool)
|
function addTicksGuide(gplt, ticks, isx::Bool)
|
||||||
ticks == :auto && return
|
ticks == :auto && return
|
||||||
@ -238,13 +208,16 @@ function addTicksGuide(gplt, ticks, isx::Bool)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
isContinuousScale(scale, isx::Bool) = isa(scale, Gadfly.Scale.ContinuousScale) && scale.vars[1] == (isx ? :x : :y)
|
||||||
|
|
||||||
function addLimitsScale(gplt, lims, isx::Bool)
|
function addLimitsScale(gplt, lims, isx::Bool)
|
||||||
lims == :auto && return
|
lims == :auto && return
|
||||||
ltype = limsType(lims)
|
ltype = limsType(lims)
|
||||||
if ltype == :limits
|
if ltype == :limits
|
||||||
gtype = isx ? Gadfly.Scale.x_continuous : Gadfly.Scale.y_continuous
|
# remove any existing scales, then add a new one
|
||||||
filter!(x -> !isa(x, gtype), gplt.scales)
|
gfunc = isx ? Gadfly.Scale.x_continuous : Gadfly.Scale.y_continuous
|
||||||
push!(gplt.scales, gtype(minvalue = min(lims...), maxvalue = max(lims...)))
|
filter!(scale -> !isContinuousScale(scale,isx), gplt.scales)
|
||||||
|
push!(gplt.scales, gfunc(minvalue = min(lims...), maxvalue = max(lims...)))
|
||||||
else
|
else
|
||||||
error("Invalid input for $(isx ? "xlims" : "ylims"): ", lims)
|
error("Invalid input for $(isx ? "xlims" : "ylims"): ", lims)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -8,7 +8,7 @@ pyplot!() = plotter!(:pyplot)
|
|||||||
|
|
||||||
# -------------------------------
|
# -------------------------------
|
||||||
|
|
||||||
supportedArgs(::PyPlotPackage) = setdiff(_allArgs, [:reg, :heatmap_c, :fillto, :pos])
|
supportedArgs(::PyPlotPackage) = setdiff(_allArgs, [:reg, :heatmap_c, :fillto, :pos, :xlims, :ylims, :xticks, :yticks])
|
||||||
supportedAxes(::PyPlotPackage) = _allAxes
|
supportedAxes(::PyPlotPackage) = _allAxes
|
||||||
supportedTypes(::PyPlotPackage) = [:none, :line, :path, :step, :stepinverted, :sticks, :scatter, :heatmap, :hexbin, :hist, :bar]
|
supportedTypes(::PyPlotPackage) = [:none, :line, :path, :step, :stepinverted, :sticks, :scatter, :heatmap, :hexbin, :hist, :bar]
|
||||||
supportedStyles(::PyPlotPackage) = [:auto, :solid, :dash, :dot, :dashdot]
|
supportedStyles(::PyPlotPackage) = [:auto, :solid, :dash, :dot, :dashdot]
|
||||||
|
|||||||
@ -6,6 +6,7 @@ immutable QwtPackage <: PlottingPackage end
|
|||||||
export qwt!
|
export qwt!
|
||||||
qwt!() = plotter!(:qwt)
|
qwt!() = plotter!(:qwt)
|
||||||
|
|
||||||
|
supportedArgs(::QwtPackage) = setdiff(_allArgs, [:xlims, :ylims, :xticks, :yticks])
|
||||||
supportedTypes(::QwtPackage) = [:none, :line, :path, :steppre, :steppost, :sticks, :scatter, :heatmap, :hexbin, :hist, :bar]
|
supportedTypes(::QwtPackage) = [:none, :line, :path, :steppre, :steppost, :sticks, :scatter, :heatmap, :hexbin, :hist, :bar]
|
||||||
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, :star1, :star2, :hexagon]
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,7 @@ unicodeplots!() = plotter!(:unicodeplots)
|
|||||||
|
|
||||||
# -------------------------------
|
# -------------------------------
|
||||||
|
|
||||||
supportedArgs(::UnicodePlotsPackage) = setdiff(_allArgs, [:reg, :heatmap_c, :fillto, :pos])
|
supportedArgs(::UnicodePlotsPackage) = setdiff(_allArgs, [:reg, :heatmap_c, :fillto, :pos, :xlims, :ylims, :xticks, :yticks])
|
||||||
supportedAxes(::UnicodePlotsPackage) = [:auto, :left]
|
supportedAxes(::UnicodePlotsPackage) = [:auto, :left]
|
||||||
supportedTypes(::UnicodePlotsPackage) = [:none, :line, :path, :steppost, :sticks, :scatter, :heatmap, :hexbin, :hist, :bar]
|
supportedTypes(::UnicodePlotsPackage) = [:none, :line, :path, :steppost, :sticks, :scatter, :heatmap, :hexbin, :hist, :bar]
|
||||||
supportedStyles(::UnicodePlotsPackage) = [:auto, :solid]
|
supportedStyles(::UnicodePlotsPackage) = [:auto, :solid]
|
||||||
|
|||||||
@ -30,7 +30,7 @@ const winston_marker = Dict(:none=>".",
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
supportedArgs(::WinstonPackage) = setdiff(_allArgs, [:heatmap_c, :fillto, :pos, :markercolor, :background_color])
|
supportedArgs(::WinstonPackage) = setdiff(_allArgs, [:heatmap_c, :fillto, :pos, :markercolor, :background_color, :xlims, :ylims, :xticks, :yticks])
|
||||||
supportedAxes(::WinstonPackage) = [:auto, :left]
|
supportedAxes(::WinstonPackage) = [:auto, :left]
|
||||||
supportedTypes(::WinstonPackage) = [:none, :line, :path, :sticks, :scatter, :hist, :bar]
|
supportedTypes(::WinstonPackage) = [:none, :line, :path, :sticks, :scatter, :hist, :bar]
|
||||||
supportedStyles(::WinstonPackage) = intersect(_allStyles, collect(keys(winston_linestyle)))
|
supportedStyles(::WinstonPackage) = intersect(_allStyles, collect(keys(winston_linestyle)))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user