fixes; changed reg to smooth, added loess smoothing in gadfly

This commit is contained in:
Thomas Breloff 2015-10-16 00:47:46 -04:00
parent 7c91d10c79
commit 47f21b1652
6 changed files with 32 additions and 35 deletions

File diff suppressed because one or more lines are too long

View File

@ -120,7 +120,7 @@ _seriesDefaults[:fillcolor] = :match
_seriesDefaults[:nbins] = 100 # number of bins for heatmaps and hists _seriesDefaults[:nbins] = 100 # number of bins for heatmaps and hists
_seriesDefaults[:heatmap_c] = (0.15, 0.5) # TODO: this should be replaced with a ColorGradient _seriesDefaults[:heatmap_c] = (0.15, 0.5) # TODO: this should be replaced with a ColorGradient
# _seriesDefaults[:fill] = nothing # fills in the area # _seriesDefaults[:fill] = nothing # fills in the area
_seriesDefaults[:reg] = false # regression line? _seriesDefaults[:smooth] = false # regression line?
_seriesDefaults[:group] = nothing # groupby vector _seriesDefaults[:group] = nothing # groupby vector
_seriesDefaults[:annotation] = nothing # annotation tuple(s)... (x,y,annotation) _seriesDefaults[:annotation] = nothing # annotation tuple(s)... (x,y,annotation)
_seriesDefaults[:z] = nothing # depth for contour, color scale, etc _seriesDefaults[:z] = nothing # depth for contour, color scale, etc
@ -256,7 +256,8 @@ end
:fgcolor => :foreground_color, :fgcolor => :foreground_color,
:fg_color => :foreground_color, :fg_color => :foreground_color,
:foreground => :foreground_color, :foreground => :foreground_color,
:regression => :reg, :regression => :smooth,
:reg => :smooth,
:xlim => :xlims, :xlim => :xlims,
:xlimit => :xlims, :xlimit => :xlims,
:xlimits => :xlims, :xlimits => :xlims,

View File

@ -35,7 +35,7 @@ supportedArgs(::GadflyPackage) = [
:nc, :nc,
:nr, :nr,
# :pos, # :pos,
:reg, :smooth,
:show, :show,
:size, :size,
:title, :title,
@ -334,12 +334,16 @@ function addToGadflyLegend(plt::Plot, d::Dict)
end end
getGadflySmoothing(smooth::Bool) = smooth ? [Gadfly.Geom.smooth(method=:lm)] : Any[]
getGadflySmoothing(smooth::Real) = [Gadfly.Geom.smooth(method=:loess, smoothing=float(smooth))]
function addGadflySeries!(plt::Plot, d::Dict) function addGadflySeries!(plt::Plot, d::Dict)
# add a regression line? # add a regression line?
# TODO: make more flexible # TODO: make more flexible
smooth = d[:reg] ? [Gadfly.Geom.smooth(method=:lm)] : Any[] # smooth = d[:smooth] ? [Gadfly.Geom.smooth(method=:lm)] : Any[]
smooth = getGadflySmoothing(d[:smooth])
# lines # lines
geom = getLineGeom(d) geom = getLineGeom(d)
@ -484,7 +488,7 @@ end
# append!(gplt.guides, guides) # append!(gplt.guides, guides)
# # add a regression line? # # add a regression line?
# if d[:reg] # if d[:smooth]
# # TODO: make more flexible # # TODO: make more flexible
# push!(gfargs, Gadfly.Geom.smooth(method=:lm)) # push!(gfargs, Gadfly.Geom.smooth(method=:lm))
# # push!(gfargs, Gadfly.Geom.smooth(method=:loess, smoothing=0.95)) # # push!(gfargs, Gadfly.Geom.smooth(method=:loess, smoothing=0.95))
@ -690,7 +694,7 @@ end
# plot one data series # plot one data series
function plot!(::GadflyPackage, plt::Plot; kw...) function plot!(::GadflyPackage, plt::Plot; kw...)
d = Dict(kw) d = Dict(kw)
addGadflySeries!(plt.o, d) addGadflySeries!(plt, d)
push!(plt.seriesargs, d) push!(plt.seriesargs, d)
plt plt
end end

View File

@ -34,7 +34,7 @@ supportedArgs(::QwtPackage) = [
:nc, :nc,
:nr, :nr,
:pos, :pos,
:reg, :smooth,
# :ribbon, # :ribbon,
:show, :show,
:size, :size,

View File

@ -32,7 +32,7 @@ supportedArgs(::[PkgName]Package) = [
:nc, :nc,
:nr, :nr,
# :pos, # :pos,
:reg, :smooth,
# :ribbon, # :ribbon,
:show, :show,
:size, :size,

View File

@ -57,7 +57,7 @@ supportedArgs(::WinstonPackage) = [
# :nc, # :nc,
# :nr, # :nr,
# :pos, # :pos,
:reg, :smooth,
# :ribbon, # :ribbon,
:show, :show,
:size, :size,
@ -206,7 +206,7 @@ function plot!(::WinstonPackage, plt::Plot; kw...)
# optionally add a regression line # optionally add a regression line
d[:reg] && d[:linetype] != :hist && addRegressionLineWinston(d, wplt) d[:smooth] && d[:linetype] != :hist && addRegressionLineWinston(d, wplt)
push!(plt.seriesargs, d) push!(plt.seriesargs, d)
plt plt