working on ticks/lims
This commit is contained in:
parent
646b88c5be
commit
273996aa91
@ -116,6 +116,8 @@ _plotDefaults[:yrightlabel] = ""
|
|||||||
_plotDefaults[:legend] = true
|
_plotDefaults[:legend] = true
|
||||||
_plotDefaults[:background_color] = colorant"white"
|
_plotDefaults[:background_color] = colorant"white"
|
||||||
_plotDefaults[:foreground_color] = :auto
|
_plotDefaults[:foreground_color] = :auto
|
||||||
|
_plotDefaults[:xlims] = :auto
|
||||||
|
_plotDefaults[:ylims] = :auto
|
||||||
_plotDefaults[:xticks] = :auto
|
_plotDefaults[:xticks] = :auto
|
||||||
_plotDefaults[:yticks] = :auto
|
_plotDefaults[:yticks] = :auto
|
||||||
_plotDefaults[:size] = (800,600)
|
_plotDefaults[:size] = (800,600)
|
||||||
@ -198,8 +200,10 @@ const _keyAliases = Dict(
|
|||||||
:fgcolor => :foreground_color,
|
:fgcolor => :foreground_color,
|
||||||
:fg_color => :foreground_color,
|
:fg_color => :foreground_color,
|
||||||
:foreground => :foreground_color,
|
:foreground => :foreground_color,
|
||||||
:xlim => :xticks,
|
:xlim => :xlims,
|
||||||
:ylim => :yticks,
|
:ylim => :ylims,
|
||||||
|
:xtick => :xticks,
|
||||||
|
:ytick => :yticks,
|
||||||
:windowsize => :size,
|
:windowsize => :size,
|
||||||
:wsize => :size,
|
:wsize => :size,
|
||||||
:wtitle => :windowtitle,
|
:wtitle => :windowtitle,
|
||||||
|
|||||||
@ -200,32 +200,57 @@ function addGadflySeries!(gplt, d::Dict, initargs::Dict)
|
|||||||
nothing
|
nothing
|
||||||
end
|
end
|
||||||
|
|
||||||
function addTicksGuideOrScale(gplt, ticks, isx::Bool)
|
# 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)
|
||||||
ticks == :auto && return
|
ticks == :auto && return
|
||||||
ttype = ticksType(ticks)
|
ttype = ticksType(ticks)
|
||||||
if ttype == :limits
|
if ttype == :ticks
|
||||||
minvalue = min(ticks...)
|
gtype = isx ? Gadfly.Guide.xticks : Gadfly.Guide.yticks
|
||||||
maxvalue = max(ticks...)
|
filter!(x -> !isa(x, gtype), gplt.guides)
|
||||||
scale = (isx ? Gadfly.Scale.x_continuous : Gadfly.Scale.y_continuous)(minvalue=minvalue, maxvalue=maxvalue)
|
push!(gplt.guides, gtype(ticks = sort(collect(ticks))))
|
||||||
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 = map(Composesort(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
|
else
|
||||||
error("Invalid input for $(isx ? "xticks" : "yticks"): ", ticks)
|
error("Invalid input for $(isx ? "xticks" : "yticks"): ", ticks)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function addLimitsScale(gplt, lims, isx::Bool)
|
||||||
|
lims == :auto && return
|
||||||
|
ltype = limsType(lims)
|
||||||
|
if ltype == :limits
|
||||||
|
gtype = isx ? Gadfly.Scale.x_continuous : Gadfly.Scale.y_continuous
|
||||||
|
filter!(x -> !isa(x, gtype), gplt.scales)
|
||||||
|
push!(gplt.scales, gtype(minvalue = min(lims...), maxvalue = max(lims...)))
|
||||||
|
else
|
||||||
|
error("Invalid input for $(isx ? "xlims" : "ylims"): ", lims)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
# create a blank Gadfly.Plot object
|
# create a blank Gadfly.Plot object
|
||||||
@ -258,8 +283,10 @@ function updateGadflyGuides(gplt, d::Dict)
|
|||||||
haskey(d, :title) && findGuideAndSet(gplt, Gadfly.Guide.title, d[:title])
|
haskey(d, :title) && findGuideAndSet(gplt, Gadfly.Guide.title, d[:title])
|
||||||
haskey(d, :xlabel) && findGuideAndSet(gplt, Gadfly.Guide.xlabel, d[:xlabel])
|
haskey(d, :xlabel) && findGuideAndSet(gplt, Gadfly.Guide.xlabel, d[:xlabel])
|
||||||
haskey(d, :ylabel) && findGuideAndSet(gplt, Gadfly.Guide.ylabel, d[:ylabel])
|
haskey(d, :ylabel) && findGuideAndSet(gplt, Gadfly.Guide.ylabel, d[:ylabel])
|
||||||
haskey(d, :xticks) && addTicksGuideOrScale(gplt, d[:xticks], true)
|
haskey(d, :xlims) && addLimitsScale(gplt, d[:xlims], true)
|
||||||
haskey(d, :yticks) && addTicksGuideOrScale(gplt, d[:yticks], true)
|
haskey(d, :ylims) && addLimitsScale(gplt, d[:ylims], false)
|
||||||
|
haskey(d, :xticks) && addTicksGuide(gplt, d[:xticks], true)
|
||||||
|
haskey(d, :yticks) && addTicksGuide(gplt, d[:yticks], false)
|
||||||
end
|
end
|
||||||
|
|
||||||
function updatePlotItems(plt::Plot{GadflyPackage}, d::Dict)
|
function updatePlotItems(plt::Plot{GadflyPackage}, d::Dict)
|
||||||
|
|||||||
@ -128,10 +128,13 @@ function regressionXY(x, y)
|
|||||||
regx, regy
|
regx, regy
|
||||||
end
|
end
|
||||||
|
|
||||||
ticksType{T<:Real,S<:Real}(ticks::Tuple{T,S}) = :limits
|
# ticksType{T<:Real,S<:Real}(ticks::Tuple{T,S}) = :limits
|
||||||
ticksType{T<:Real}(ticks::AVec{T}) = :ticks
|
ticksType{T<:Real}(ticks::AVec{T}) = :ticks
|
||||||
ticksType(ticks) = :invalid
|
ticksType(ticks) = :invalid
|
||||||
|
|
||||||
|
limsType{T<:Real,S<:Real}(lims::Tuple{T,S}) = :limits
|
||||||
|
limsType(lims) = :invalid
|
||||||
|
|
||||||
|
|
||||||
# Some conversion functions
|
# Some conversion functions
|
||||||
# note: I borrowed these conversion constants from Compose.jl's Measure
|
# note: I borrowed these conversion constants from Compose.jl's Measure
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user