working on markerstroke, name changes, and arg improvements
This commit is contained in:
parent
391c7e8570
commit
6236acea02
@ -211,7 +211,7 @@ Keyword | Default | Type | Aliases
|
|||||||
`:color_palette` | `auto` | Plot | `:palette`
|
`:color_palette` | `auto` | Plot | `:palette`
|
||||||
`:fill` | `nothing` | Series | `:area`, `:f`
|
`:fill` | `nothing` | Series | `:area`, `:f`
|
||||||
`:fillcolor` | `match` | Series | `:fc`, `:fcolor`, `:fillcolors`
|
`:fillcolor` | `match` | Series | `:fc`, `:fcolor`, `:fillcolors`
|
||||||
`:fillopacity` | `nothing` | Series | `:fillopacitys`, `:fo`
|
`:fillalpha` | `nothing` | Series | `:fillalphas`, `:fo`
|
||||||
`:fillrange` | `nothing` | Series | `:fillranges`, `:fillrng`
|
`:fillrange` | `nothing` | Series | `:fillranges`, `:fillrng`
|
||||||
`:foreground_color` | `auto` | Plot | `:fg`, `:fg_color`, `:fgcolor`, `:foreground`
|
`:foreground_color` | `auto` | Plot | `:fg`, `:fg_color`, `:fgcolor`, `:foreground`
|
||||||
`:grid` | `true` | Plot |
|
`:grid` | `true` | Plot |
|
||||||
@ -222,7 +222,7 @@ Keyword | Default | Type | Aliases
|
|||||||
`:legend` | `true` | Plot | `:leg`
|
`:legend` | `true` | Plot | `:leg`
|
||||||
`:legendfont` | `Plots.Font("Helvetica",8,:hcenter,:vcenter,0.0,RGB{U8}(0.0,0.0,0.0))` | Plot |
|
`:legendfont` | `Plots.Font("Helvetica",8,:hcenter,:vcenter,0.0,RGB{U8}(0.0,0.0,0.0))` | Plot |
|
||||||
`:line` | `nothing` | Series | `:l`
|
`:line` | `nothing` | Series | `:l`
|
||||||
`:lineopacity` | `nothing` | Series | `:lineopacitys`, `:lo`
|
`:linealpha` | `nothing` | Series | `:linealphas`, `:lo`
|
||||||
`:linestyle` | `solid` | Series | `:linestyles`, `:ls`, `:s`, `:style`
|
`:linestyle` | `solid` | Series | `:linestyles`, `:ls`, `:s`, `:style`
|
||||||
`:linetype` | `path` | Series | `:linetypes`, `:lt`, `:t`, `:type`
|
`:linetype` | `path` | Series | `:linetypes`, `:lt`, `:t`, `:type`
|
||||||
`:linewidth` | `1` | Series | `:linewidths`, `:lw`, `:w`, `:width`
|
`:linewidth` | `1` | Series | `:linewidths`, `:lw`, `:w`, `:width`
|
||||||
@ -232,7 +232,7 @@ Keyword | Default | Type | Aliases
|
|||||||
`:linky` | `false` | Plot | `:ylink`
|
`:linky` | `false` | Plot | `:ylink`
|
||||||
`:marker` | `nothing` | Series | `:m`, `:mark`
|
`:marker` | `nothing` | Series | `:m`, `:mark`
|
||||||
`:markercolor` | `match` | Series | `:markercolors`, `:mc`, `:mcolor`
|
`:markercolor` | `match` | Series | `:markercolors`, `:mc`, `:mcolor`
|
||||||
`:markeropacity` | `nothing` | Series | `:alpha`, `:markeropacitys`, `:mo`, `:opacity`
|
`:markeralpha` | `nothing` | Series | `:alpha`, `:markeralphas`, `:mo`, `:alpha`
|
||||||
`:markershape` | `none` | Series | `:markershapes`, `:shape`
|
`:markershape` | `none` | Series | `:markershapes`, `:shape`
|
||||||
`:markersize` | `6` | Series | `:markersizes`, `:ms`, `:msize`
|
`:markersize` | `6` | Series | `:markersizes`, `:ms`, `:msize`
|
||||||
`:n` | `-1` | Plot |
|
`:n` | `-1` | Plot |
|
||||||
|
|||||||
@ -63,6 +63,8 @@ export
|
|||||||
Shape,
|
Shape,
|
||||||
text,
|
text,
|
||||||
font,
|
font,
|
||||||
|
stroke,
|
||||||
|
brush,
|
||||||
OHLC,
|
OHLC,
|
||||||
|
|
||||||
colorscheme,
|
colorscheme,
|
||||||
|
|||||||
290
src/args.jl
290
src/args.jl
@ -110,34 +110,38 @@ subplotSupported() = subplotSupported(backend())
|
|||||||
const _seriesDefaults = Dict{Symbol, Any}()
|
const _seriesDefaults = Dict{Symbol, Any}()
|
||||||
|
|
||||||
# series-specific
|
# series-specific
|
||||||
_seriesDefaults[:axis] = :left
|
_seriesDefaults[:axis] = :left
|
||||||
_seriesDefaults[:color] = :auto
|
_seriesDefaults[:label] = "AUTO"
|
||||||
_seriesDefaults[:label] = "AUTO"
|
_seriesDefaults[:linetype] = :path
|
||||||
_seriesDefaults[:linetype] = :path
|
_seriesDefaults[:linestyle] = :solid
|
||||||
_seriesDefaults[:linestyle] = :solid
|
_seriesDefaults[:linewidth] = 1
|
||||||
_seriesDefaults[:linewidth] = 1
|
_seriesDefaults[:linecolor] = :auto
|
||||||
_seriesDefaults[:lineopacity] = nothing
|
_seriesDefaults[:linealpha] = nothing
|
||||||
_seriesDefaults[:markershape] = :none
|
# _seriesDefaults[:linestroke] = Stroke(1, :auto, nothing, :solid) # linewidth, linecolor, linealpha, linestyle
|
||||||
_seriesDefaults[:markercolor] = :match
|
# _seriesDefaults[:fillbrush] = Brush(nothing, :match, nothing) # fillrange, fillcolor, fillalpha
|
||||||
_seriesDefaults[:markeropacity] = nothing
|
_seriesDefaults[:fillrange] = nothing # ribbons, areas, etc
|
||||||
_seriesDefaults[:markersize] = 6
|
_seriesDefaults[:fillcolor] = :match
|
||||||
_seriesDefaults[:fillrange] = nothing # ribbons, areas, etc
|
_seriesDefaults[:fillalpha] = nothing
|
||||||
_seriesDefaults[:fillcolor] = :match
|
_seriesDefaults[:markershape] = :none
|
||||||
_seriesDefaults[:fillopacity] = nothing
|
# _seriesDefaults[:markerstroke] = Stroke(1, :match_foreground, nothing, :solid)
|
||||||
# _seriesDefaults[:ribbon] = nothing
|
# _seriesDefaults[:markerbrush] = Brush(6, :match, nothing)
|
||||||
# _seriesDefaults[:ribboncolor] = :match
|
_seriesDefaults[:markercolor] = :match
|
||||||
_seriesDefaults[:nbins] = 30 # number of bins for heatmaps and hists
|
_seriesDefaults[:markeralpha] = nothing
|
||||||
# _seriesDefaults[:heatmap_c] = (0.15, 0.5) # TODO: this should be replaced with a ColorGradient
|
_seriesDefaults[:markersize] = 6
|
||||||
# _seriesDefaults[:fill] = nothing # fills in the area
|
_seriesDefaults[:markerstrokestyle] = :solid
|
||||||
_seriesDefaults[:smooth] = false # regression line?
|
_seriesDefaults[:markerstrokewidth] = 1
|
||||||
_seriesDefaults[:group] = nothing # groupby vector
|
_seriesDefaults[:markerstrokecolor] = :match
|
||||||
_seriesDefaults[:annotation] = nothing # annotation tuple(s)... (x,y,annotation)
|
_seriesDefaults[:markerstrokealpha] = nothing
|
||||||
_seriesDefaults[:z] = nothing # depth for contour, color scale, etc
|
# _seriesDefaults[:ribbon] = nothing
|
||||||
# _seriesDefaults[:args] = [] # additional args to pass to the backend
|
# _seriesDefaults[:ribboncolor] = :match
|
||||||
# _seriesDefaults[:kwargs] = [] # additional keyword args to pass to the backend
|
_seriesDefaults[:nbins] = 30 # number of bins for heatmaps and hists
|
||||||
# # note: can be Vector{Dict} or Vector{Tuple}
|
_seriesDefaults[:smooth] = false # regression line?
|
||||||
_seriesDefaults[:surface] = nothing
|
_seriesDefaults[:group] = nothing # groupby vector
|
||||||
_seriesDefaults[:nlevels] = 15
|
_seriesDefaults[:annotation] = nothing # annotation tuple(s)... (x,y,annotation)
|
||||||
|
_seriesDefaults[:z] = nothing # depth for contour, color scale, etc
|
||||||
|
_seriesDefaults[:z]
|
||||||
|
_seriesDefaults[:surface] = nothing
|
||||||
|
_seriesDefaults[:nlevels] = 15
|
||||||
|
|
||||||
|
|
||||||
const _plotDefaults = Dict{Symbol, Any}()
|
const _plotDefaults = Dict{Symbol, Any}()
|
||||||
@ -185,12 +189,6 @@ supportedArgs(::PlottingPackage) = _allArgs
|
|||||||
supportedArgs() = supportedArgs(backend())
|
supportedArgs() = supportedArgs(backend())
|
||||||
|
|
||||||
|
|
||||||
@compat const _argNotes = Dict(
|
|
||||||
:color => "Series color. To have different marker and/or fill colors, optionally set the markercolor and fillcolor args.",
|
|
||||||
:z => "Determines the depth. For color gradients, we expect 0 ≤ z ≤ 1.",
|
|
||||||
# :heatmap_c => "For Qwt heatmaps only... will be deprecated eventually.",
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -220,79 +218,88 @@ end
|
|||||||
# Alternate args
|
# Alternate args
|
||||||
|
|
||||||
@compat const _keyAliases = Dict(
|
@compat const _keyAliases = Dict(
|
||||||
:c => :color,
|
:c => :linecolor,
|
||||||
:lab => :label,
|
:color => :linecolor,
|
||||||
:l => :line,
|
:colour => :linecolor,
|
||||||
:w => :linewidth,
|
:lab => :label,
|
||||||
:width => :linewidth,
|
:l => :line,
|
||||||
:lw => :linewidth,
|
:w => :linewidth,
|
||||||
:lo => :lineopacity,
|
:width => :linewidth,
|
||||||
:type => :linetype,
|
:lw => :linewidth,
|
||||||
:lt => :linetype,
|
:la => :linealpha,
|
||||||
:t => :linetype,
|
:lineopacity => :linealpha,
|
||||||
:style => :linestyle,
|
:type => :linetype,
|
||||||
:s => :linestyle,
|
:lt => :linetype,
|
||||||
:ls => :linestyle,
|
:t => :linetype,
|
||||||
:m => :marker,
|
:style => :linestyle,
|
||||||
:mark => :marker,
|
:s => :linestyle,
|
||||||
:shape => :markershape,
|
:ls => :linestyle,
|
||||||
:mc => :markercolor,
|
:m => :marker,
|
||||||
:mcolor => :markercolor,
|
:mark => :marker,
|
||||||
:ms => :markersize,
|
:shape => :markershape,
|
||||||
:msize => :markersize,
|
:mc => :markercolor,
|
||||||
:mo => :markeropacity,
|
:mcolor => :markercolor,
|
||||||
:opacity => :markeropacity,
|
:markercolour => :markercolor,
|
||||||
:alpha => :markeropacity,
|
:ms => :markersize,
|
||||||
:f => :fill,
|
:msize => :markersize,
|
||||||
:area => :fill,
|
:ma => :markeralpha,
|
||||||
:fillrng => :fillrange,
|
:alpha => :markeralpha,
|
||||||
:fc => :fillcolor,
|
:opacity => :markeralpha,
|
||||||
:fcolor => :fillcolor,
|
:markeropacity => :markeralpha,
|
||||||
:fo => :fillopacity,
|
:f => :fill,
|
||||||
:g => :group,
|
:area => :fill,
|
||||||
:nb => :nbins,
|
:fillrng => :fillrange,
|
||||||
:nbin => :nbins,
|
:fc => :fillcolor,
|
||||||
:rib => :ribbon,
|
:fcolor => :fillcolor,
|
||||||
:ann => :annotation,
|
:fillcolour => :fillcolor,
|
||||||
:anns => :annotation,
|
:fa => :fillalpha,
|
||||||
:annotate => :annotation,
|
:fillopacity => :fillalpha,
|
||||||
:annotations => :annotation,
|
:g => :group,
|
||||||
:xlab => :xlabel,
|
:nb => :nbins,
|
||||||
:ylab => :ylabel,
|
:nbin => :nbins,
|
||||||
:yrlab => :yrightlabel,
|
:rib => :ribbon,
|
||||||
:ylabr => :yrightlabel,
|
:ann => :annotation,
|
||||||
:y2lab => :yrightlabel,
|
:anns => :annotation,
|
||||||
:ylab2 => :yrightlabel,
|
:annotate => :annotation,
|
||||||
:ylabelright => :yrightlabel,
|
:annotations => :annotation,
|
||||||
:ylabel2 => :yrightlabel,
|
:xlab => :xlabel,
|
||||||
:y2label => :yrightlabel,
|
:ylab => :ylabel,
|
||||||
:leg => :legend,
|
:yrlab => :yrightlabel,
|
||||||
:bg => :background_color,
|
:ylabr => :yrightlabel,
|
||||||
:bgcolor => :background_color,
|
:y2lab => :yrightlabel,
|
||||||
:bg_color => :background_color,
|
:ylab2 => :yrightlabel,
|
||||||
:background => :background_color,
|
:ylabelright => :yrightlabel,
|
||||||
:fg => :foreground_color,
|
:ylabel2 => :yrightlabel,
|
||||||
:fgcolor => :foreground_color,
|
:y2label => :yrightlabel,
|
||||||
:fg_color => :foreground_color,
|
:leg => :legend,
|
||||||
:foreground => :foreground_color,
|
:bg => :background_color,
|
||||||
:regression => :smooth,
|
:bgcolor => :background_color,
|
||||||
:reg => :smooth,
|
:bg_color => :background_color,
|
||||||
:xlim => :xlims,
|
:background => :background_color,
|
||||||
:xlimit => :xlims,
|
:background_colour => :background_color,
|
||||||
:xlimits => :xlims,
|
:fg => :foreground_color,
|
||||||
:ylim => :ylims,
|
:fgcolor => :foreground_color,
|
||||||
:ylimit => :ylims,
|
:fg_color => :foreground_color,
|
||||||
:ylimits => :ylims,
|
:foreground => :foreground_color,
|
||||||
:xtick => :xticks,
|
:foreground_colour => :foreground_color,
|
||||||
:ytick => :yticks,
|
:regression => :smooth,
|
||||||
:windowsize => :size,
|
:reg => :smooth,
|
||||||
:wsize => :size,
|
:xlim => :xlims,
|
||||||
:wtitle => :windowtitle,
|
:xlimit => :xlims,
|
||||||
:gui => :show,
|
:xlimits => :xlims,
|
||||||
:display => :show,
|
:ylim => :ylims,
|
||||||
:palette => :color_palette,
|
:ylimit => :ylims,
|
||||||
:xlink => :linkx,
|
:ylimits => :ylims,
|
||||||
:ylink => :linky,
|
:xtick => :xticks,
|
||||||
|
:ytick => :yticks,
|
||||||
|
:windowsize => :size,
|
||||||
|
:wsize => :size,
|
||||||
|
:wtitle => :windowtitle,
|
||||||
|
:gui => :show,
|
||||||
|
:display => :show,
|
||||||
|
:palette => :color_palette,
|
||||||
|
:xlink => :linkx,
|
||||||
|
:ylink => :linky,
|
||||||
)
|
)
|
||||||
|
|
||||||
# add all pluralized forms to the _keyAliases dict
|
# add all pluralized forms to the _keyAliases dict
|
||||||
@ -406,16 +413,27 @@ function processLineArg(d::Dict, arg)
|
|||||||
elseif trueOrAllTrue(a -> get(_styleAliases, a, a) in _allStyles, arg)
|
elseif trueOrAllTrue(a -> get(_styleAliases, a, a) in _allStyles, arg)
|
||||||
d[:linestyle] = arg
|
d[:linestyle] = arg
|
||||||
|
|
||||||
|
elseif typeof(arg) <: Stroke
|
||||||
|
arg.width == nothing || (d[:linewidth] = arg.width)
|
||||||
|
arg.color == nothing || (d[:linecolor] = arg.color == :auto ? :auto : colorscheme(arg.color))
|
||||||
|
arg.alpha == nothing || (d[:linealpha] = arg.alpha)
|
||||||
|
arg.style == nothing || (d[:linestyle] = arg.style)
|
||||||
|
|
||||||
|
elseif typeof(arg) <: Brush
|
||||||
|
arg.size == nothing || (d[:fillrange] = arg.size)
|
||||||
|
arg.color == nothing || (d[:fillcolor] = arg.color == :auto ? :auto : colorscheme(arg.color))
|
||||||
|
arg.alpha == nothing || (d[:fillalpha] = arg.alpha)
|
||||||
|
|
||||||
# linewidth
|
# linewidth
|
||||||
elseif trueOrAllTrue(a -> typeof(a) <: Integer, arg)
|
elseif trueOrAllTrue(a -> typeof(a) <: Integer, arg)
|
||||||
d[:linewidth] = arg
|
d[:linewidth] = arg
|
||||||
|
|
||||||
# lineopacity
|
# linealpha
|
||||||
elseif trueOrAllTrue(a -> typeof(a) <: Real && a >= 0 && a <= 1, arg)
|
elseif trueOrAllTrue(a -> typeof(a) <: Real && a >= 0 && a <= 1, arg)
|
||||||
d[:lineopacity] = arg
|
d[:linealpha] = arg
|
||||||
|
|
||||||
# color
|
# color
|
||||||
elseif !handleColors!(d, arg, :color)
|
elseif !handleColors!(d, arg, :linecolor)
|
||||||
warn("Skipped line arg $arg.")
|
warn("Skipped line arg $arg.")
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -429,14 +447,29 @@ function processMarkerArg(d::Dict, arg)
|
|||||||
d[:markershape] = arg
|
d[:markershape] = arg
|
||||||
elseif trueOrAllTrue(a -> isa(a, Shape), arg)
|
elseif trueOrAllTrue(a -> isa(a, Shape), arg)
|
||||||
d[:markershape] = arg
|
d[:markershape] = arg
|
||||||
|
|
||||||
|
# stroke style
|
||||||
|
elseif trueOrAllTrue(a -> get(_styleAliases, a, a) in _allStyles, arg)
|
||||||
|
d[:markerstrokestyle] = arg
|
||||||
|
|
||||||
|
elseif typeof(arg) <: Stroke
|
||||||
|
arg.width == nothing || (d[:markerstrokewidth] = arg.width)
|
||||||
|
arg.color == nothing || (d[:markerstrokecolor] = arg.color == :auto ? :auto : colorscheme(arg.color))
|
||||||
|
arg.alpha == nothing || (d[:markerstrokealpha] = arg.alpha)
|
||||||
|
arg.style == nothing || (d[:markerstrokestyle] = arg.style)
|
||||||
|
|
||||||
|
elseif typeof(arg) <: Brush
|
||||||
|
arg.size == nothing || (d[:markersize] = arg.size)
|
||||||
|
arg.color == nothing || (d[:markercolor] = arg.color == :auto ? :auto : colorscheme(arg.color))
|
||||||
|
arg.alpha == nothing || (d[:markeralpha] = arg.alpha)
|
||||||
|
|
||||||
# markersize
|
# markersize
|
||||||
elseif trueOrAllTrue(a -> typeof(a) <: Integer, arg)
|
elseif trueOrAllTrue(a -> typeof(a) <: Integer, arg)
|
||||||
d[:markersize] = arg
|
d[:markersize] = arg
|
||||||
|
|
||||||
# lineopacity
|
# linealpha
|
||||||
elseif trueOrAllTrue(a -> typeof(a) <: Real && a >= 0 && a <= 1, arg)
|
elseif trueOrAllTrue(a -> typeof(a) <: Real && a >= 0 && a <= 1, arg)
|
||||||
d[:markeropacity] = arg
|
d[:markeralpha] = arg
|
||||||
|
|
||||||
# markercolor
|
# markercolor
|
||||||
elseif !handleColors!(d, arg, :markercolor)
|
elseif !handleColors!(d, arg, :markercolor)
|
||||||
@ -447,7 +480,13 @@ end
|
|||||||
|
|
||||||
|
|
||||||
function processFillArg(d::Dict, arg)
|
function processFillArg(d::Dict, arg)
|
||||||
if !handleColors!(d, arg, :fillcolor)
|
|
||||||
|
if typeof(arg) <: Brush
|
||||||
|
arg.size == nothing || (d[:fillrange] = arg.size)
|
||||||
|
arg.color == nothing || (d[:fillcolor] = arg.color == :auto ? :auto : colorscheme(arg.color))
|
||||||
|
arg.alpha == nothing || (d[:fillalpha] = arg.alpha)
|
||||||
|
|
||||||
|
elseif !handleColors!(d, arg, :fillcolor)
|
||||||
d[:fillrange] = arg
|
d[:fillrange] = arg
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -488,6 +527,8 @@ function preprocessArgs!(d::Dict)
|
|||||||
end
|
end
|
||||||
delete!(d, :fill)
|
delete!(d, :fill)
|
||||||
|
|
||||||
|
# convert into strokes and brushes
|
||||||
|
|
||||||
# handle subplot links
|
# handle subplot links
|
||||||
if haskey(d, :link)
|
if haskey(d, :link)
|
||||||
l = d[:link]
|
l = d[:link]
|
||||||
@ -628,7 +669,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
# build the argument dictionary for a series
|
# build the argument dictionary for a series
|
||||||
function getSeriesArgs(pkg::PlottingPackage, initargs::Dict, kw, commandIndex::Int, plotIndex::Int, globalIndex::Int) # TODO, pass in initargs, not plt
|
function getSeriesArgs(pkg::PlottingPackage, plotargs::Dict, kw, commandIndex::Int, plotIndex::Int, globalIndex::Int) # TODO, pass in plotargs, not plt
|
||||||
kwdict = Dict(kw)
|
kwdict = Dict(kw)
|
||||||
d = Dict()
|
d = Dict()
|
||||||
|
|
||||||
@ -653,17 +694,24 @@ function getSeriesArgs(pkg::PlottingPackage, initargs::Dict, kw, commandIndex::I
|
|||||||
aliasesAndAutopick(d, :markershape, _markerAliases, supportedMarkers(pkg), plotIndex)
|
aliasesAndAutopick(d, :markershape, _markerAliases, supportedMarkers(pkg), plotIndex)
|
||||||
|
|
||||||
# update color
|
# update color
|
||||||
d[:color] = getSeriesRGBColor(d[:color], initargs, plotIndex)
|
d[:linecolor] = getSeriesRGBColor(d[:linecolor], plotargs, plotIndex)
|
||||||
|
|
||||||
# update markercolor
|
# update markercolor
|
||||||
mc = d[:markercolor]
|
c = d[:markercolor]
|
||||||
mc = (mc == :match ? d[:color] : getSeriesRGBColor(mc, initargs, plotIndex))
|
c = (c == :match ? d[:linecolor] : getSeriesRGBColor(c, plotargs, plotIndex))
|
||||||
d[:markercolor] = mc
|
d[:markercolor] = c
|
||||||
|
|
||||||
|
# update markerstrokecolor
|
||||||
|
c = d[:markerstrokecolor]
|
||||||
|
c = (c == :match ? plotargs[:foreground_color] : getSeriesRGBColor(c, plotargs, plotIndex))
|
||||||
|
d[:markerstrokecolor] = c
|
||||||
|
|
||||||
# update fillcolor
|
# update fillcolor
|
||||||
mc = d[:fillcolor]
|
c = d[:fillcolor]
|
||||||
mc = (mc == :match ? d[:color] : getSeriesRGBColor(mc, initargs, plotIndex))
|
c = (c == :match ? d[:linecolor] : getSeriesRGBColor(c, plotargs, plotIndex))
|
||||||
d[:fillcolor] = mc
|
d[:fillcolor] = c
|
||||||
|
|
||||||
|
# TODO: rebuild
|
||||||
|
|
||||||
# set label
|
# set label
|
||||||
label = d[:label]
|
label = d[:label]
|
||||||
|
|||||||
@ -88,7 +88,7 @@ function _add_series(::BokehPackage, plt::Plot; kw...)
|
|||||||
|
|
||||||
glyph = Bokeh.Bokehjs.Glyph(
|
glyph = Bokeh.Bokehjs.Glyph(
|
||||||
glyphtype = bokeh_glyph_type(d),
|
glyphtype = bokeh_glyph_type(d),
|
||||||
linecolor = bokehcolor(d[:color]), # shape's stroke or line color
|
linecolor = bokehcolor(d[:linecolor]), # shape's stroke or line color
|
||||||
linewidth = d[:linewidth], # shape's stroke width or line width
|
linewidth = d[:linewidth], # shape's stroke width or line width
|
||||||
fillcolor = bokehcolor(d[:markercolor]),
|
fillcolor = bokehcolor(d[:markercolor]),
|
||||||
size = ceil(Int, d[:markersize] * 2.5), # magic number 2.5 to keep in same scale as other backends
|
size = ceil(Int, d[:markersize] * 2.5), # magic number 2.5 to keep in same scale as other backends
|
||||||
|
|||||||
@ -36,9 +36,9 @@ function getLineGeom(d::Dict)
|
|||||||
elseif lt == :steppre
|
elseif lt == :steppre
|
||||||
Gadfly.Geom.step(direction = :vh)
|
Gadfly.Geom.step(direction = :vh)
|
||||||
elseif lt == :hline
|
elseif lt == :hline
|
||||||
Gadfly.Geom.hline(color = getColor(d[:color]), size = d[:linewidth] * Gadfly.px)
|
Gadfly.Geom.hline(color = getColor(d[:linecolor]), size = d[:linewidth] * Gadfly.px)
|
||||||
elseif lt == :vline
|
elseif lt == :vline
|
||||||
Gadfly.Geom.vline(color = getColor(d[:color]), size = d[:linewidth] * Gadfly.px)
|
Gadfly.Geom.vline(color = getColor(d[:linecolor]), size = d[:linewidth] * Gadfly.px)
|
||||||
elseif lt == :contour
|
elseif lt == :contour
|
||||||
Gadfly.Geom.contour(levels = d[:nlevels])
|
Gadfly.Geom.contour(levels = d[:nlevels])
|
||||||
else
|
else
|
||||||
@ -46,24 +46,11 @@ function getLineGeom(d::Dict)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function getGadflyLineTheme(d::Dict)
|
function get_extra_theme_args(d::Dict, k::Symbol)
|
||||||
|
|
||||||
lc = getColor(d[:color])
|
|
||||||
α = d[:lineopacity]
|
|
||||||
if α != nothing
|
|
||||||
lc = RGBA(lc, α)
|
|
||||||
end
|
|
||||||
|
|
||||||
fc = getColor(d[:fillcolor])
|
|
||||||
α = d[:fillopacity]
|
|
||||||
if α != nothing
|
|
||||||
fc = RGBA(fc, α)
|
|
||||||
end
|
|
||||||
|
|
||||||
# gracefully handles old Gadfly versions
|
# gracefully handles old Gadfly versions
|
||||||
extra_theme_args = Dict()
|
extra_theme_args = Dict()
|
||||||
try
|
try
|
||||||
extra_theme_args[:line_style] = Gadfly.get_stroke_vector(d[:linestyle])
|
extra_theme_args[:line_style] = Gadfly.get_stroke_vector(d[k])
|
||||||
catch err
|
catch err
|
||||||
if string(err) == "UndefVarError(:get_stroke_vector)"
|
if string(err) == "UndefVarError(:get_stroke_vector)"
|
||||||
Base.warn_once("Gadfly.get_stroke_vector failed... do you have an old version of Gadfly?")
|
Base.warn_once("Gadfly.get_stroke_vector failed... do you have an old version of Gadfly?")
|
||||||
@ -71,6 +58,23 @@ function getGadflyLineTheme(d::Dict)
|
|||||||
rethrow()
|
rethrow()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
extra_theme_args
|
||||||
|
end
|
||||||
|
|
||||||
|
function getGadflyLineTheme(d::Dict)
|
||||||
|
|
||||||
|
lc = getColor(d[:linecolor])
|
||||||
|
α = d[:linealpha]
|
||||||
|
if α != nothing
|
||||||
|
lc = RGBA(lc, α)
|
||||||
|
end
|
||||||
|
|
||||||
|
fc = getColor(d[:fillcolor])
|
||||||
|
α = d[:fillalpha]
|
||||||
|
if α != nothing
|
||||||
|
fc = RGBA(fc, α)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
Gadfly.Theme(;
|
Gadfly.Theme(;
|
||||||
default_color = lc,
|
default_color = lc,
|
||||||
@ -79,7 +83,7 @@ function getGadflyLineTheme(d::Dict)
|
|||||||
lowlight_color = x->RGB(fc), # fill/ribbon
|
lowlight_color = x->RGB(fc), # fill/ribbon
|
||||||
lowlight_opacity = alpha(fc), # fill/ribbon
|
lowlight_opacity = alpha(fc), # fill/ribbon
|
||||||
bar_highlight = RGB(lc), # bars
|
bar_highlight = RGB(lc), # bars
|
||||||
extra_theme_args...
|
get_extra_theme_args(d, :linestyle)...
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -129,32 +133,33 @@ function getMarkerGeom(d::Dict)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function getGadflyMarkerTheme(d::Dict, initargs::Dict)
|
function getGadflyMarkerTheme(d::Dict, plotargs::Dict)
|
||||||
c = getColor(d[:markercolor])
|
c = getColor(d[:markercolor])
|
||||||
α = d[:markeropacity]
|
α = d[:markeralpha]
|
||||||
if α != nothing
|
if α != nothing
|
||||||
c = RGBA(RGB(c), α)
|
c = RGBA(RGB(c), α)
|
||||||
end
|
end
|
||||||
|
|
||||||
fg = getColor(initargs[:foreground_color])
|
# fg = getColor(plotargs[:foreground_color])
|
||||||
Gadfly.Theme(
|
Gadfly.Theme(;
|
||||||
default_color = c,
|
default_color = c,
|
||||||
default_point_size = d[:markersize] * Gadfly.px,
|
default_point_size = d[:markersize] * Gadfly.px,
|
||||||
discrete_highlight_color = c -> RGB(fg),
|
discrete_highlight_color = c -> RGB(getColor(d[:markerstrokecolor])),
|
||||||
highlight_width = d[:linewidth] * Gadfly.px,
|
highlight_width = d[:markerstrokewidth] * Gadfly.px,
|
||||||
|
# get_extra_theme_args(d, :markerstrokestyle)...
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
function addGadflyMarker!(plt::Plot, d::Dict, initargs::Dict, geoms...)
|
function addGadflyMarker!(plt::Plot, d::Dict, plotargs::Dict, geoms...)
|
||||||
gfargs = vcat(geoms...,
|
gfargs = vcat(geoms...,
|
||||||
getGadflyMarkerTheme(d, initargs),
|
getGadflyMarkerTheme(d, plotargs),
|
||||||
getMarkerGeom(d))
|
getMarkerGeom(d))
|
||||||
kwargs = Dict()
|
kwargs = Dict()
|
||||||
|
|
||||||
# handle continuous color scales for the markers
|
# handle continuous color scales for the markers
|
||||||
z = d[:z]
|
z = d[:z]
|
||||||
if z != nothing && typeof(z) <: AVec
|
if z != nothing && typeof(z) <: AVec
|
||||||
kwargs[:color] = z
|
kwargs[:linecolor] = z
|
||||||
if !isa(d[:markercolor], ColorGradient)
|
if !isa(d[:markercolor], ColorGradient)
|
||||||
d[:markercolor] = colorscheme(:bluesreds)
|
d[:markercolor] = colorscheme(:bluesreds)
|
||||||
end
|
end
|
||||||
@ -170,7 +175,7 @@ end
|
|||||||
function addToGadflyLegend(plt::Plot, d::Dict)
|
function addToGadflyLegend(plt::Plot, d::Dict)
|
||||||
|
|
||||||
# add the legend?
|
# add the legend?
|
||||||
if plt.initargs[:legend]
|
if plt.plotargs[:legend]
|
||||||
gplt = getGadflyContext(plt)
|
gplt = getGadflyContext(plt)
|
||||||
|
|
||||||
# add the legend if needed
|
# add the legend if needed
|
||||||
@ -185,7 +190,7 @@ function addToGadflyLegend(plt::Plot, d::Dict)
|
|||||||
# since gadfly will call unique(colors), but doesn't also merge the rows that match
|
# since gadfly will call unique(colors), but doesn't also merge the rows that match
|
||||||
# Should ensure from this side that colors which are the same are merged together
|
# Should ensure from this side that colors which are the same are merged together
|
||||||
|
|
||||||
c = getColor(d[d[:markershape] == :none ? :color : :markercolor])
|
c = getColor(d[d[:markershape] == :none ? :linecolor : :markercolor])
|
||||||
foundit = false
|
foundit = false
|
||||||
|
|
||||||
# extend the label if we found this color
|
# extend the label if we found this color
|
||||||
@ -239,7 +244,7 @@ function addGadflySeries!(plt::Plot, d::Dict)
|
|||||||
|
|
||||||
# markers
|
# markers
|
||||||
if d[:markershape] != :none
|
if d[:markershape] != :none
|
||||||
prepend!(layers, addGadflyMarker!(plt, d, plt.initargs, smooth...))
|
prepend!(layers, addGadflyMarker!(plt, d, plt.plotargs, smooth...))
|
||||||
end
|
end
|
||||||
|
|
||||||
lt in (:hist, :heatmap, :hexbin, :contour) || addToGadflyLegend(plt, d)
|
lt in (:hist, :heatmap, :hexbin, :contour) || addToGadflyLegend(plt, d)
|
||||||
@ -258,7 +263,7 @@ end
|
|||||||
# z = d[:z]
|
# z = d[:z]
|
||||||
|
|
||||||
# # handle line segments of different colors
|
# # handle line segments of different colors
|
||||||
# cscheme = d[:color]
|
# cscheme = d[:linecolor]
|
||||||
# if isa(cscheme, ColorVector)
|
# if isa(cscheme, ColorVector)
|
||||||
# # create a color scale, and set the color group to the index of the color
|
# # create a color scale, and set the color group to the index of the color
|
||||||
# push!(gplt.scales, Gadfly.Scale.color_discrete_manual(cscheme.v...))
|
# push!(gplt.scales, Gadfly.Scale.color_discrete_manual(cscheme.v...))
|
||||||
@ -270,7 +275,7 @@ end
|
|||||||
# cs = collect(repmat(csindices', 2, 1))[1:end-1]
|
# cs = collect(repmat(csindices', 2, 1))[1:end-1]
|
||||||
# grp = collect(repmat((1:length(d[:y]))', 2, 1))[1:end-1]
|
# grp = collect(repmat((1:length(d[:y]))', 2, 1))[1:end-1]
|
||||||
# d[:x], d[:y] = map(createSegments, (d[:x], d[:y]))
|
# d[:x], d[:y] = map(createSegments, (d[:x], d[:y]))
|
||||||
# colorgroup = [(:color, cs), (:group, grp)]
|
# colorgroup = [(:linecolor, cs), (:group, grp)]
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
@ -416,9 +421,9 @@ end
|
|||||||
function updateGadflyPlotTheme(plt::Plot, d::Dict)
|
function updateGadflyPlotTheme(plt::Plot, d::Dict)
|
||||||
kwargs = Dict()
|
kwargs = Dict()
|
||||||
|
|
||||||
# # get the full initargs, overriding any new settings
|
# # get the full plotargs, overriding any new settings
|
||||||
# # TODO: should this be part of the main `plot` command in plot.jl???
|
# # TODO: should this be part of the main `plot` command in plot.jl???
|
||||||
# d = merge!(plt.initargs, d)
|
# d = merge!(plt.plotargs, d)
|
||||||
|
|
||||||
# hide the legend?
|
# hide the legend?
|
||||||
if !get(d, :legend, true)
|
if !get(d, :legend, true)
|
||||||
@ -582,8 +587,8 @@ function buildGadflySubplotContext(subplt::Subplot)
|
|||||||
end
|
end
|
||||||
|
|
||||||
setGadflyDisplaySize(w,h) = Compose.set_default_graphic_size(w * Compose.px, h * Compose.px)
|
setGadflyDisplaySize(w,h) = Compose.set_default_graphic_size(w * Compose.px, h * Compose.px)
|
||||||
setGadflyDisplaySize(plt::Plot) = setGadflyDisplaySize(plt.initargs[:size]...)
|
setGadflyDisplaySize(plt::Plot) = setGadflyDisplaySize(plt.plotargs[:size]...)
|
||||||
setGadflyDisplaySize(subplt::Subplot) = setGadflyDisplaySize(getinitargs(subplt, 1)[:size]...)
|
setGadflyDisplaySize(subplt::Subplot) = setGadflyDisplaySize(getplotargs(subplt, 1)[:size]...)
|
||||||
# -------------------------------------------------------------------------
|
# -------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
@ -610,14 +615,14 @@ end
|
|||||||
|
|
||||||
|
|
||||||
function Base.display(::PlotsDisplay, plt::Plot{GadflyPackage})
|
function Base.display(::PlotsDisplay, plt::Plot{GadflyPackage})
|
||||||
setGadflyDisplaySize(plt.initargs[:size]...)
|
setGadflyDisplaySize(plt.plotargs[:size]...)
|
||||||
display(plt.o)
|
display(plt.o)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function Base.display(::PlotsDisplay, subplt::Subplot{GadflyPackage})
|
function Base.display(::PlotsDisplay, subplt::Subplot{GadflyPackage})
|
||||||
setGadflyDisplaySize(getinitargs(subplt,1)[:size]...)
|
setGadflyDisplaySize(getplotargs(subplt,1)[:size]...)
|
||||||
ctx = buildGadflySubplotContext(subplt)
|
ctx = buildGadflySubplotContext(subplt)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -74,7 +74,7 @@ end
|
|||||||
|
|
||||||
function showSubplotObject(subplt::Subplot{ImmersePackage})
|
function showSubplotObject(subplt::Subplot{ImmersePackage})
|
||||||
# create the Gtk window with vertical box vsep
|
# create the Gtk window with vertical box vsep
|
||||||
d = getinitargs(subplt,1)
|
d = getplotargs(subplt,1)
|
||||||
w,h = d[:size]
|
w,h = d[:size]
|
||||||
vsep = Gtk.GtkBoxLeaf(:v)
|
vsep = Gtk.GtkBoxLeaf(:v)
|
||||||
win = Gtk.GtkWindowLeaf(vsep, d[:windowtitle], w, h)
|
win = Gtk.GtkWindowLeaf(vsep, d[:windowtitle], w, h)
|
||||||
@ -137,7 +137,7 @@ function Base.display(::PlotsDisplay, plt::Plot{ImmersePackage})
|
|||||||
|
|
||||||
fig, gplt = plt.o
|
fig, gplt = plt.o
|
||||||
if fig == nothing
|
if fig == nothing
|
||||||
fig = createImmerseFigure(plt.initargs)
|
fig = createImmerseFigure(plt.plotargs)
|
||||||
Gtk.on_signal_destroy((x...) -> (Immerse.dropfig(Immerse._display, fig.figno); plt.o = (nothing,gplt)), fig.canvas)
|
Gtk.on_signal_destroy((x...) -> (Immerse.dropfig(Immerse._display, fig.figno); plt.o = (nothing,gplt)), fig.canvas)
|
||||||
plt.o = (fig, gplt)
|
plt.o = (fig, gplt)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -107,7 +107,7 @@ function getPyPlotFunction(plt::Plot, axis::Symbol, linetype::Symbol)
|
|||||||
|
|
||||||
# in the 2-axis case we need to get: <rightaxis>[:<func>]
|
# in the 2-axis case we need to get: <rightaxis>[:<func>]
|
||||||
ax = getAxis(plt, axis)
|
ax = getAxis(plt, axis)
|
||||||
ax[:set_ylabel](plt.initargs[:yrightlabel])
|
ax[:set_ylabel](plt.plotargs[:yrightlabel])
|
||||||
fmap = @compat Dict(
|
fmap = @compat Dict(
|
||||||
:hist => :hist,
|
:hist => :hist,
|
||||||
:sticks => :bar,
|
:sticks => :bar,
|
||||||
@ -140,7 +140,7 @@ function handleSmooth(plt::Plot{PyPlotPackage}, ax, d::Dict, smooth::Bool)
|
|||||||
xs, ys = regressionXY(d[:x], d[:y])
|
xs, ys = regressionXY(d[:x], d[:y])
|
||||||
ax[:plot](xs, ys,
|
ax[:plot](xs, ys,
|
||||||
# linestyle = getPyPlotLineStyle(:path, :dashdot),
|
# linestyle = getPyPlotLineStyle(:path, :dashdot),
|
||||||
color = getPyPlotColor(d[:color]),
|
color = getPyPlotColor(d[:linecolor]),
|
||||||
linewidth = 2
|
linewidth = 2
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
@ -202,7 +202,7 @@ function _add_series(pkg::PyPlotPackage, plt::Plot; kw...)
|
|||||||
error("linetype $(lt) is unsupported in PyPlot. Choose from: $(supportedTypes(pkg))")
|
error("linetype $(lt) is unsupported in PyPlot. Choose from: $(supportedTypes(pkg))")
|
||||||
end
|
end
|
||||||
|
|
||||||
color = getPyPlotColor(d[:color], d[:lineopacity])
|
color = getPyPlotColor(d[:linecolor], d[:linealpha])
|
||||||
|
|
||||||
|
|
||||||
if lt == :sticks
|
if lt == :sticks
|
||||||
@ -243,10 +243,10 @@ function _add_series(pkg::PyPlotPackage, plt::Plot; kw...)
|
|||||||
|
|
||||||
elseif lt in (:heatmap, :hexbin)
|
elseif lt in (:heatmap, :hexbin)
|
||||||
extra_kwargs[:gridsize] = d[:nbins]
|
extra_kwargs[:gridsize] = d[:nbins]
|
||||||
extra_kwargs[:cmap] = getPyPlotColorMap(d[:color])
|
extra_kwargs[:cmap] = getPyPlotColorMap(d[:linecolor])
|
||||||
|
|
||||||
elseif lt == :contour
|
elseif lt == :contour
|
||||||
extra_kwargs[:cmap] = getPyPlotColorMap(d[:color])
|
extra_kwargs[:cmap] = getPyPlotColorMap(d[:linecolor])
|
||||||
extra_kwargs[:linewidths] = d[:linewidth]
|
extra_kwargs[:linewidths] = d[:linewidth]
|
||||||
extra_kwargs[:linestyles] = getPyPlotLineStyle(lt, d[:linestyle])
|
extra_kwargs[:linestyles] = getPyPlotLineStyle(lt, d[:linestyle])
|
||||||
# TODO: will need to call contourf to fill in the contours
|
# TODO: will need to call contourf to fill in the contours
|
||||||
@ -261,14 +261,14 @@ function _add_series(pkg::PyPlotPackage, plt::Plot; kw...)
|
|||||||
c = d[:markercolor]
|
c = d[:markercolor]
|
||||||
if isa(c, ColorGradient) && d[:z] != nothing
|
if isa(c, ColorGradient) && d[:z] != nothing
|
||||||
extra_kwargs[:c] = convert(Vector{Float64}, d[:z])
|
extra_kwargs[:c] = convert(Vector{Float64}, d[:z])
|
||||||
extra_kwargs[:cmap] = getPyPlotColorMap(c, d[:markeropacity])
|
extra_kwargs[:cmap] = getPyPlotColorMap(c, d[:markeralpha])
|
||||||
else
|
else
|
||||||
extra_kwargs[:c] = getPyPlotColor(c, d[:markeropacity])
|
extra_kwargs[:c] = getPyPlotColor(c, d[:markeralpha])
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
extra_kwargs[:markersize] = d[:markersize]
|
extra_kwargs[:markersize] = d[:markersize]
|
||||||
extra_kwargs[:markerfacecolor] = getPyPlotColor(d[:markercolor], d[:markeropacity])
|
extra_kwargs[:markerfacecolor] = getPyPlotColor(d[:markercolor], d[:markeralpha])
|
||||||
extra_kwargs[:markeredgecolor] = getPyPlotColor(plt.initargs[:foreground_color])
|
extra_kwargs[:markeredgecolor] = getPyPlotColor(plt.plotargs[:foreground_color])
|
||||||
extra_kwargs[:markeredgewidth] = d[:linewidth]
|
extra_kwargs[:markeredgewidth] = d[:linewidth]
|
||||||
extra_kwargs[:drawstyle] = getPyPlotStepStyle(lt)
|
extra_kwargs[:drawstyle] = getPyPlotStepStyle(lt)
|
||||||
end
|
end
|
||||||
@ -276,7 +276,7 @@ function _add_series(pkg::PyPlotPackage, plt::Plot; kw...)
|
|||||||
|
|
||||||
# set these for all types
|
# set these for all types
|
||||||
if lt != :contour
|
if lt != :contour
|
||||||
extra_kwargs[:color] = color
|
extra_kwargs[:linecolor] = color
|
||||||
extra_kwargs[:linewidth] = d[:linewidth]
|
extra_kwargs[:linewidth] = d[:linewidth]
|
||||||
extra_kwargs[:label] = d[:label]
|
extra_kwargs[:label] = d[:label]
|
||||||
end
|
end
|
||||||
@ -291,7 +291,7 @@ function _add_series(pkg::PyPlotPackage, plt::Plot; kw...)
|
|||||||
surf = d[:surface]'
|
surf = d[:surface]'
|
||||||
handle = plotfunc(x, y, surf, d[:nlevels]; extra_kwargs...)
|
handle = plotfunc(x, y, surf, d[:nlevels]; extra_kwargs...)
|
||||||
if d[:fillrange] != nothing
|
if d[:fillrange] != nothing
|
||||||
handle = ax[:contourf](x, y, surf, d[:nlevels]; cmap = getPyPlotColorMap(d[:fillcolor], d[:fillopacity]))
|
handle = ax[:contourf](x, y, surf, d[:nlevels]; cmap = getPyPlotColorMap(d[:fillcolor], d[:fillalpha]))
|
||||||
end
|
end
|
||||||
handle
|
handle
|
||||||
elseif lt in _3dTypes
|
elseif lt in _3dTypes
|
||||||
@ -305,16 +305,16 @@ function _add_series(pkg::PyPlotPackage, plt::Plot; kw...)
|
|||||||
handleSmooth(plt, ax, d, d[:smooth])
|
handleSmooth(plt, ax, d, d[:smooth])
|
||||||
|
|
||||||
# add the colorbar legend
|
# add the colorbar legend
|
||||||
if plt.initargs[:legend] && haskey(extra_kwargs, :cmap)
|
if plt.plotargs[:legend] && haskey(extra_kwargs, :cmap)
|
||||||
PyPlot.colorbar(d[:serieshandle])
|
PyPlot.colorbar(d[:serieshandle])
|
||||||
end
|
end
|
||||||
|
|
||||||
# this sets the bg color inside the grid
|
# this sets the bg color inside the grid
|
||||||
ax[:set_axis_bgcolor](getPyPlotColor(plt.initargs[:background_color]))
|
ax[:set_axis_bgcolor](getPyPlotColor(plt.plotargs[:background_color]))
|
||||||
|
|
||||||
fillrange = d[:fillrange]
|
fillrange = d[:fillrange]
|
||||||
if fillrange != nothing && lt != :contour
|
if fillrange != nothing && lt != :contour
|
||||||
fillcolor = getPyPlotColor(d[:fillcolor], d[:fillopacity])
|
fillcolor = getPyPlotColor(d[:fillcolor], d[:fillalpha])
|
||||||
if typeof(fillrange) <: @compat(Union{Real, AVec})
|
if typeof(fillrange) <: @compat(Union{Real, AVec})
|
||||||
ax[:fill_between](d[:x], fillrange, d[:y], facecolor = fillcolor)
|
ax[:fill_between](d[:x], fillrange, d[:y], facecolor = fillcolor)
|
||||||
else
|
else
|
||||||
@ -351,11 +351,11 @@ function Base.setindex!(plt::Plot{PyPlotPackage}, xy::Tuple, i::Integer)
|
|||||||
end
|
end
|
||||||
|
|
||||||
ax = series[:axes]
|
ax = series[:axes]
|
||||||
if plt.initargs[:xlims] == :auto
|
if plt.plotargs[:xlims] == :auto
|
||||||
xmin, xmax = ax[:get_xlim]()
|
xmin, xmax = ax[:get_xlim]()
|
||||||
ax[:set_xlim](min(xmin, minimum(xy[1])), max(xmax, maximum(xy[1])))
|
ax[:set_xlim](min(xmin, minimum(xy[1])), max(xmax, maximum(xy[1])))
|
||||||
end
|
end
|
||||||
if plt.initargs[:ylims] == :auto
|
if plt.plotargs[:ylims] == :auto
|
||||||
ymin, ymax = ax[:get_ylim]()
|
ymin, ymax = ax[:get_ylim]()
|
||||||
ax[:set_ylim](min(ymin, minimum(xy[2])), max(ymax, maximum(xy[2])))
|
ax[:set_ylim](min(ymin, minimum(xy[2])), max(ymax, maximum(xy[2])))
|
||||||
end
|
end
|
||||||
@ -443,13 +443,13 @@ function _update_plot(plt::Plot{PyPlotPackage}, d::Dict)
|
|||||||
|
|
||||||
|
|
||||||
# guides
|
# guides
|
||||||
sz = get(d, :guidefont, plt.initargs[:guidefont]).pointsize
|
sz = get(d, :guidefont, plt.plotargs[:guidefont]).pointsize
|
||||||
ax[:title][:set_fontsize](sz)
|
ax[:title][:set_fontsize](sz)
|
||||||
ax[:xaxis][:label][:set_fontsize](sz)
|
ax[:xaxis][:label][:set_fontsize](sz)
|
||||||
ax[:yaxis][:label][:set_fontsize](sz)
|
ax[:yaxis][:label][:set_fontsize](sz)
|
||||||
|
|
||||||
# ticks
|
# ticks
|
||||||
sz = get(d, :tickfont, plt.initargs[:tickfont]).pointsize
|
sz = get(d, :tickfont, plt.plotargs[:tickfont]).pointsize
|
||||||
for sym in (:get_xticklabels, :get_yticklabels)
|
for sym in (:get_xticklabels, :get_yticklabels)
|
||||||
for lab in ax[sym]()
|
for lab in ax[sym]()
|
||||||
lab[:set_fontsize](sz)
|
lab[:set_fontsize](sz)
|
||||||
@ -508,8 +508,8 @@ end
|
|||||||
function _create_subplot(subplt::Subplot{PyPlotPackage}, isbefore::Bool)
|
function _create_subplot(subplt::Subplot{PyPlotPackage}, isbefore::Bool)
|
||||||
l = subplt.layout
|
l = subplt.layout
|
||||||
|
|
||||||
w,h = map(px2inch, getinitargs(subplt,1)[:size])
|
w,h = map(px2inch, getplotargs(subplt,1)[:size])
|
||||||
bgcolor = getPyPlotColor(getinitargs(subplt,1)[:background_color])
|
bgcolor = getPyPlotColor(getplotargs(subplt,1)[:background_color])
|
||||||
fig = PyPlot.figure(; figsize = (w,h), facecolor = bgcolor, dpi = 96)
|
fig = PyPlot.figure(; figsize = (w,h), facecolor = bgcolor, dpi = 96)
|
||||||
|
|
||||||
nr = nrows(l)
|
nr = nrows(l)
|
||||||
@ -536,7 +536,7 @@ function subplot(plts::AVec{Plot{PyPlotPackage}}, layout::SubplotLayout, d::Dict
|
|||||||
n = sum([plt.n for plt in plts])
|
n = sum([plt.n for plt in plts])
|
||||||
|
|
||||||
pkg = PyPlotPackage()
|
pkg = PyPlotPackage()
|
||||||
newplts = Plot{PyPlotPackage}[plot(pkg; subplot=true, plt.initargs...) for plt in plts]
|
newplts = Plot{PyPlotPackage}[plot(pkg; subplot=true, plt.plotargs...) for plt in plts]
|
||||||
|
|
||||||
subplt = Subplot(nothing, newplts, PyPlotPackage(), p, n, layout, d, true, false, false, (r,c) -> (nothing,nothing))
|
subplt = Subplot(nothing, newplts, PyPlotPackage(), p, n, layout, d, true, false, false, (r,c) -> (nothing,nothing))
|
||||||
|
|
||||||
@ -572,14 +572,14 @@ end
|
|||||||
|
|
||||||
# function addPyPlotLegend(plt::Plot)
|
# function addPyPlotLegend(plt::Plot)
|
||||||
function addPyPlotLegend(plt::Plot, ax)
|
function addPyPlotLegend(plt::Plot, ax)
|
||||||
if plt.initargs[:legend]
|
if plt.plotargs[:legend]
|
||||||
# gotta do this to ensure both axes are included
|
# gotta do this to ensure both axes are included
|
||||||
args = filter(x -> !(x[:linetype] in (:hist,:hexbin,:heatmap,:hline,:vline,:contour, :path3d, :scatter3d)), plt.seriesargs)
|
args = filter(x -> !(x[:linetype] in (:hist,:hexbin,:heatmap,:hline,:vline,:contour, :path3d, :scatter3d)), plt.seriesargs)
|
||||||
if length(args) > 0
|
if length(args) > 0
|
||||||
ax[:legend]([d[:serieshandle] for d in args],
|
ax[:legend]([d[:serieshandle] for d in args],
|
||||||
[d[:label] for d in args],
|
[d[:label] for d in args],
|
||||||
loc="best",
|
loc="best",
|
||||||
fontsize = plt.initargs[:legendfont].pointsize
|
fontsize = plt.plotargs[:legendfont].pointsize
|
||||||
# framealpha = 0.6
|
# framealpha = 0.6
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
@ -589,7 +589,7 @@ end
|
|||||||
function finalizePlot(plt::Plot{PyPlotPackage})
|
function finalizePlot(plt::Plot{PyPlotPackage})
|
||||||
ax = getLeftAxis(plt)
|
ax = getLeftAxis(plt)
|
||||||
addPyPlotLegend(plt, ax)
|
addPyPlotLegend(plt, ax)
|
||||||
updateAxisColors(ax, getPyPlotColor(plt.initargs[:foreground_color]))
|
updateAxisColors(ax, getPyPlotColor(plt.plotargs[:foreground_color]))
|
||||||
PyPlot.draw()
|
PyPlot.draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -598,7 +598,7 @@ function finalizePlot(subplt::Subplot{PyPlotPackage})
|
|||||||
for (i,plt) in enumerate(subplt.plts)
|
for (i,plt) in enumerate(subplt.plts)
|
||||||
ax = getLeftAxis(plt)
|
ax = getLeftAxis(plt)
|
||||||
addPyPlotLegend(plt, ax)
|
addPyPlotLegend(plt, ax)
|
||||||
updateAxisColors(ax, getPyPlotColor(plt.initargs[:foreground_color]))
|
updateAxisColors(ax, getPyPlotColor(plt.plotargs[:foreground_color]))
|
||||||
end
|
end
|
||||||
PyPlot.draw()
|
PyPlot.draw()
|
||||||
end
|
end
|
||||||
|
|||||||
@ -154,7 +154,7 @@ function addLineMarker(plt::Plot{QwtPackage}, d::Dict)
|
|||||||
ishorizontal = (d[:linetype] == :hline)
|
ishorizontal = (d[:linetype] == :hline)
|
||||||
marker[:setLineStyle](ishorizontal ? 1 : 2)
|
marker[:setLineStyle](ishorizontal ? 1 : 2)
|
||||||
marker[ishorizontal ? :setYValue : :setXValue](yi)
|
marker[ishorizontal ? :setYValue : :setXValue](yi)
|
||||||
qcolor = Qwt.convertRGBToQColor(getColor(d[:color]))
|
qcolor = Qwt.convertRGBToQColor(getColor(d[:linecolor]))
|
||||||
linestyle = plt.o.widget[:getLineStyle](string(d[:linestyle]))
|
linestyle = plt.o.widget[:getLineStyle](string(d[:linestyle]))
|
||||||
marker[:setLinePen](Qwt.QT.QPen(qcolor, d[:linewidth], linestyle))
|
marker[:setLinePen](Qwt.QT.QPen(qcolor, d[:linewidth], linestyle))
|
||||||
marker[:attach](plt.o.widget)
|
marker[:attach](plt.o.widget)
|
||||||
@ -228,7 +228,7 @@ function _create_subplot(subplt::Subplot{QwtPackage}, isbefore::Bool)
|
|||||||
# i += rowcnt
|
# i += rowcnt
|
||||||
# end
|
# end
|
||||||
subplt.o = Qwt.vsplitter(rows...)
|
subplt.o = Qwt.vsplitter(rows...)
|
||||||
# Qwt.resizewidget(subplt.o, getinitargs(subplt,1)[:size]...)
|
# Qwt.resizewidget(subplt.o, getplotargs(subplt,1)[:size]...)
|
||||||
# Qwt.moveToLastScreen(subplt.o) # hack so it goes to my center monitor... sorry
|
# Qwt.moveToLastScreen(subplt.o) # hack so it goes to my center monitor... sorry
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|||||||
@ -3,11 +3,11 @@ supportedArgs(::GadflyPackage) = [
|
|||||||
:annotation,
|
:annotation,
|
||||||
# :axis,
|
# :axis,
|
||||||
:background_color,
|
:background_color,
|
||||||
:color,
|
:linecolor,
|
||||||
:color_palette,
|
:color_palette,
|
||||||
:fillrange,
|
:fillrange,
|
||||||
:fillcolor,
|
:fillcolor,
|
||||||
:fillopacity,
|
:fillalpha,
|
||||||
:foreground_color,
|
:foreground_color,
|
||||||
:group,
|
:group,
|
||||||
:label,
|
:label,
|
||||||
@ -16,11 +16,14 @@ supportedArgs(::GadflyPackage) = [
|
|||||||
:linestyle,
|
:linestyle,
|
||||||
:linetype,
|
:linetype,
|
||||||
:linewidth,
|
:linewidth,
|
||||||
:lineopacity,
|
:linealpha,
|
||||||
:markershape,
|
:markershape,
|
||||||
:markercolor,
|
:markercolor,
|
||||||
:markersize,
|
:markersize,
|
||||||
:markeropacity,
|
:markeralpha,
|
||||||
|
:markerstrokewidth,
|
||||||
|
:markerstrokecolor,
|
||||||
|
# :markerstrokestyle,
|
||||||
:n,
|
:n,
|
||||||
:nbins,
|
:nbins,
|
||||||
:nc,
|
:nc,
|
||||||
@ -77,7 +80,7 @@ supportedArgs(::PyPlotPackage) = [
|
|||||||
:annotation,
|
:annotation,
|
||||||
:axis,
|
:axis,
|
||||||
:background_color,
|
:background_color,
|
||||||
:color,
|
:linecolor,
|
||||||
:color_palette,
|
:color_palette,
|
||||||
:fillrange,
|
:fillrange,
|
||||||
:fillcolor,
|
:fillcolor,
|
||||||
@ -92,6 +95,9 @@ supportedArgs(::PyPlotPackage) = [
|
|||||||
:markershape,
|
:markershape,
|
||||||
:markercolor,
|
:markercolor,
|
||||||
:markersize,
|
:markersize,
|
||||||
|
# :markerstrokewidth,
|
||||||
|
# :markerstrokecolor,
|
||||||
|
# :markerstrokestyle,
|
||||||
:n,
|
:n,
|
||||||
:nbins,
|
:nbins,
|
||||||
:nc,
|
:nc,
|
||||||
@ -123,9 +129,9 @@ supportedArgs(::PyPlotPackage) = [
|
|||||||
:grid,
|
:grid,
|
||||||
:surface,
|
:surface,
|
||||||
:nlevels,
|
:nlevels,
|
||||||
:fillopacity,
|
:fillalpha,
|
||||||
:lineopacity,
|
:linealpha,
|
||||||
:markeropacity,
|
:markeralpha,
|
||||||
]
|
]
|
||||||
supportedAxes(::PyPlotPackage) = _allAxes
|
supportedAxes(::PyPlotPackage) = _allAxes
|
||||||
supportedTypes(::PyPlotPackage) = [:none, :line, :path, :steppre, :steppost, :sticks, :scatter, :heatmap, :hexbin, :hist, :bar, :hline, :vline, :contour, :path3d, :scatter3d]
|
supportedTypes(::PyPlotPackage) = [:none, :line, :path, :steppre, :steppost, :sticks, :scatter, :heatmap, :hexbin, :hist, :bar, :hline, :vline, :contour, :path3d, :scatter3d]
|
||||||
@ -145,7 +151,7 @@ supportedArgs(::QwtPackage) = [
|
|||||||
# :args,
|
# :args,
|
||||||
:axis,
|
:axis,
|
||||||
:background_color,
|
:background_color,
|
||||||
:color,
|
:linecolor,
|
||||||
:color_palette,
|
:color_palette,
|
||||||
:fillrange,
|
:fillrange,
|
||||||
:fillcolor,
|
:fillcolor,
|
||||||
@ -162,6 +168,9 @@ supportedArgs(::QwtPackage) = [
|
|||||||
:markershape,
|
:markershape,
|
||||||
:markercolor,
|
:markercolor,
|
||||||
:markersize,
|
:markersize,
|
||||||
|
# :markerstrokewidth,
|
||||||
|
# :markerstrokecolor,
|
||||||
|
# :markerstrokestyle,
|
||||||
:n,
|
:n,
|
||||||
:nbins,
|
:nbins,
|
||||||
:nc,
|
:nc,
|
||||||
@ -201,7 +210,7 @@ supportedArgs(::UnicodePlotsPackage) = [
|
|||||||
# :args,
|
# :args,
|
||||||
# :axis,
|
# :axis,
|
||||||
# :background_color,
|
# :background_color,
|
||||||
# :color,
|
# :linecolor,
|
||||||
# :fill,
|
# :fill,
|
||||||
# :foreground_color,
|
# :foreground_color,
|
||||||
:group,
|
:group,
|
||||||
@ -216,6 +225,9 @@ supportedArgs(::UnicodePlotsPackage) = [
|
|||||||
:markershape,
|
:markershape,
|
||||||
# :markercolor,
|
# :markercolor,
|
||||||
# :markersize,
|
# :markersize,
|
||||||
|
# :markerstrokewidth,
|
||||||
|
# :markerstrokecolor,
|
||||||
|
# :markerstrokestyle,
|
||||||
# :n,
|
# :n,
|
||||||
:nbins,
|
:nbins,
|
||||||
# :nc,
|
# :nc,
|
||||||
@ -259,7 +271,7 @@ supportedArgs(::WinstonPackage) = [
|
|||||||
# :args,
|
# :args,
|
||||||
# :axis,
|
# :axis,
|
||||||
# :background_color,
|
# :background_color,
|
||||||
:color,
|
:linecolor,
|
||||||
:color_palette,
|
:color_palette,
|
||||||
:fillrange,
|
:fillrange,
|
||||||
:fillcolor,
|
:fillcolor,
|
||||||
@ -276,6 +288,9 @@ supportedArgs(::WinstonPackage) = [
|
|||||||
:markershape,
|
:markershape,
|
||||||
:markercolor,
|
:markercolor,
|
||||||
:markersize,
|
:markersize,
|
||||||
|
# :markerstrokewidth,
|
||||||
|
# :markerstrokecolor,
|
||||||
|
# :markerstrokestyle,
|
||||||
# :n,
|
# :n,
|
||||||
:nbins,
|
:nbins,
|
||||||
# :nc,
|
# :nc,
|
||||||
@ -318,11 +333,11 @@ supportedArgs(::BokehPackage) = [
|
|||||||
# :annotation,
|
# :annotation,
|
||||||
# :axis,
|
# :axis,
|
||||||
# :background_color,
|
# :background_color,
|
||||||
:color,
|
:linecolor,
|
||||||
# :color_palette,
|
# :color_palette,
|
||||||
# :fillrange,
|
# :fillrange,
|
||||||
# :fillcolor,
|
# :fillcolor,
|
||||||
# :fillopacity,
|
# :fillalpha,
|
||||||
# :foreground_color,
|
# :foreground_color,
|
||||||
:group,
|
:group,
|
||||||
# :label,
|
# :label,
|
||||||
@ -331,11 +346,14 @@ supportedArgs(::BokehPackage) = [
|
|||||||
:linestyle,
|
:linestyle,
|
||||||
:linetype,
|
:linetype,
|
||||||
:linewidth,
|
:linewidth,
|
||||||
# :lineopacity,
|
# :linealpha,
|
||||||
:markershape,
|
:markershape,
|
||||||
:markercolor,
|
:markercolor,
|
||||||
:markersize,
|
:markersize,
|
||||||
# :markeropacity,
|
# :markeralpha,
|
||||||
|
# :markerstrokewidth,
|
||||||
|
# :markerstrokecolor,
|
||||||
|
# :markerstrokestyle,
|
||||||
# :n,
|
# :n,
|
||||||
# :nbins,
|
# :nbins,
|
||||||
# :nc,
|
# :nc,
|
||||||
|
|||||||
@ -9,7 +9,7 @@ function rebuildUnicodePlot!(plt::Plot)
|
|||||||
|
|
||||||
# figure out the plotting area xlim = [xmin, xmax] and ylim = [ymin, ymax]
|
# figure out the plotting area xlim = [xmin, xmax] and ylim = [ymin, ymax]
|
||||||
sargs = plt.seriesargs
|
sargs = plt.seriesargs
|
||||||
iargs = plt.initargs
|
iargs = plt.plotargs
|
||||||
|
|
||||||
# get the x/y limits
|
# get the x/y limits
|
||||||
if get(iargs, :xlims, :auto) == :auto
|
if get(iargs, :xlims, :auto) == :auto
|
||||||
@ -97,7 +97,7 @@ function addUnicodeSeries!(o, d::Dict, addlegend::Bool, xlim, ylim)
|
|||||||
label = addlegend ? d[:label] : ""
|
label = addlegend ? d[:label] : ""
|
||||||
|
|
||||||
# if we happen to pass in allowed color symbols, great... otherwise let UnicodePlots decide
|
# if we happen to pass in allowed color symbols, great... otherwise let UnicodePlots decide
|
||||||
color = d[:color] in UnicodePlots.autoColors ? d[:color] : :auto
|
color = d[:linecolor] in UnicodePlots.autoColors ? d[:linecolor] : :auto
|
||||||
|
|
||||||
# add the series
|
# add the series
|
||||||
func(o, x, y; color = color, name = label, style = stepstyle)
|
func(o, x, y; color = color, name = label, style = stepstyle)
|
||||||
@ -116,8 +116,8 @@ function _create_plot(pkg::UnicodePlotsPackage; kw...)
|
|||||||
plt = Plot(nothing, pkg, 0, Dict(kw), Dict[])
|
plt = Plot(nothing, pkg, 0, Dict(kw), Dict[])
|
||||||
|
|
||||||
# do we want to give a new default size?
|
# do we want to give a new default size?
|
||||||
if !haskey(plt.initargs, :size) || plt.initargs[:size] == _plotDefaults[:size]
|
if !haskey(plt.plotargs, :size) || plt.plotargs[:size] == _plotDefaults[:size]
|
||||||
plt.initargs[:size] = (60,20)
|
plt.plotargs[:size] = (60,20)
|
||||||
end
|
end
|
||||||
|
|
||||||
plt
|
plt
|
||||||
@ -138,7 +138,7 @@ end
|
|||||||
function _update_plot(plt::Plot{UnicodePlotsPackage}, d::Dict)
|
function _update_plot(plt::Plot{UnicodePlotsPackage}, d::Dict)
|
||||||
for k in (:title, :xlabel, :ylabel, :xlims, :ylims)
|
for k in (:title, :xlabel, :ylabel, :xlims, :ylims)
|
||||||
if haskey(d, k)
|
if haskey(d, k)
|
||||||
plt.initargs[k] = d[k]
|
plt.plotargs[k] = d[k]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -68,7 +68,7 @@ function _add_series(::WinstonPackage, plt::Plot; kw...)
|
|||||||
|
|
||||||
|
|
||||||
e = Dict()
|
e = Dict()
|
||||||
e[:color] = getColor(d[:color])
|
e[:color] = getColor(d[:linecolor])
|
||||||
e[:linewidth] = d[:linewidth]
|
e[:linewidth] = d[:linewidth]
|
||||||
e[:kind] = winston_linestyle[d[:linestyle]]
|
e[:kind] = winston_linestyle[d[:linestyle]]
|
||||||
e[:symbolkind] = winston_marker[d[:markershape]]
|
e[:symbolkind] = winston_marker[d[:markershape]]
|
||||||
@ -198,7 +198,7 @@ end
|
|||||||
# ----------------------------------------------------------------
|
# ----------------------------------------------------------------
|
||||||
|
|
||||||
function addWinstonLegend(plt::Plot, wplt)
|
function addWinstonLegend(plt::Plot, wplt)
|
||||||
if plt.initargs[:legend]
|
if plt.plotargs[:legend]
|
||||||
Winston.legend(wplt, [sd[:label] for sd in plt.seriesargs])
|
Winston.legend(wplt, [sd[:label] for sd in plt.seriesargs])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -219,9 +219,9 @@ function Base.display(::PlotsDisplay, plt::Plot{WinstonPackage})
|
|||||||
error("Gtk is the only supported display for Winston in Plots. Set `output_surface = gtk` in src/Winston.ini")
|
error("Gtk is the only supported display for Winston in Plots. Set `output_surface = gtk` in src/Winston.ini")
|
||||||
end
|
end
|
||||||
# initialize window
|
# initialize window
|
||||||
w,h = plt.initargs[:size]
|
w,h = plt.plotargs[:size]
|
||||||
canvas = Gtk.GtkCanvasLeaf()
|
canvas = Gtk.GtkCanvasLeaf()
|
||||||
window = Gtk.GtkWindowLeaf(canvas, plt.initargs[:windowtitle], w, h)
|
window = Gtk.GtkWindowLeaf(canvas, plt.plotargs[:windowtitle], w, h)
|
||||||
plt.o = (window, canvas, wplt)
|
plt.o = (window, canvas, wplt)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -353,10 +353,10 @@ function handlePlotColors(::PlottingPackage, d::Dict)
|
|||||||
end
|
end
|
||||||
|
|
||||||
# converts a symbol or string into a colorant (Colors.RGB), and assigns a color automatically
|
# converts a symbol or string into a colorant (Colors.RGB), and assigns a color automatically
|
||||||
function getSeriesRGBColor(c, initargs::Dict, n::Int)
|
function getSeriesRGBColor(c, plotargs::Dict, n::Int)
|
||||||
|
|
||||||
if c == :auto
|
if c == :auto
|
||||||
c = autopick(initargs[:color_palette], n)
|
c = autopick(plotargs[:color_palette], n)
|
||||||
end
|
end
|
||||||
|
|
||||||
# c should now be a subtype of ColorScheme
|
# c should now be a subtype of ColorScheme
|
||||||
|
|||||||
@ -136,17 +136,21 @@ end
|
|||||||
|
|
||||||
# -----------------------------------------------------------------------
|
# -----------------------------------------------------------------------
|
||||||
|
|
||||||
immutable Stroke{T<:Real, C<:ColorScheme}
|
immutable Stroke
|
||||||
width::T
|
width
|
||||||
color::C
|
color
|
||||||
style::Symbol
|
alpha
|
||||||
|
style
|
||||||
end
|
end
|
||||||
|
|
||||||
function stroke(args...; α::Real = -1.0)
|
function stroke(args...; alpha = nothing)
|
||||||
# defaults
|
# defaults
|
||||||
width = 1
|
# width = 1
|
||||||
color = colorant"black"
|
# color = colorant"black"
|
||||||
style = :solid
|
# style = :solid
|
||||||
|
width = nothing
|
||||||
|
color = nothing
|
||||||
|
style = nothing
|
||||||
|
|
||||||
for arg in args
|
for arg in args
|
||||||
T = typeof(arg)
|
T = typeof(arg)
|
||||||
@ -166,10 +170,54 @@ function stroke(args...; α::Real = -1.0)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Stroke(width, color, style)
|
Stroke(width, color, alpha, style)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
immutable Brush
|
||||||
|
size # fillrange, markersize, or any other sizey attribute
|
||||||
|
color
|
||||||
|
alpha
|
||||||
|
end
|
||||||
|
|
||||||
|
function brush(args...; alpha = nothing)
|
||||||
|
# defaults
|
||||||
|
# sz = 1
|
||||||
|
# color = colorant"black"
|
||||||
|
size = nothing
|
||||||
|
color = nothing
|
||||||
|
|
||||||
|
for arg in args
|
||||||
|
T = typeof(arg)
|
||||||
|
|
||||||
|
if T <: Colorant
|
||||||
|
color = arg
|
||||||
|
elseif T <: @compat Union{Symbol,AbstractString}
|
||||||
|
try
|
||||||
|
color = parse(Colorant, string(arg))
|
||||||
|
end
|
||||||
|
elseif typeof(arg) <: Real
|
||||||
|
size = arg
|
||||||
|
else
|
||||||
|
warn("Unused brush arg: $arg ($(typeof(arg)))")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Brush(size, color, alpha)
|
||||||
|
end
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------
|
||||||
|
|
||||||
|
"type which represents z-values for colors and sizes (and anything else that might come up)"
|
||||||
|
immutable ZValues
|
||||||
|
values::Vector{Float64}
|
||||||
|
zrange::Tuple{Float64,Float64}
|
||||||
|
end
|
||||||
|
|
||||||
|
function zvalues{T<:Real}(values::AVec{T}, zrange::Tuple{T,T} = (minimum(values), maximum(values)))
|
||||||
|
ZValues(collect(float(values)), map(Float64, zrange))
|
||||||
|
end
|
||||||
|
|
||||||
# -----------------------------------------------------------------------
|
# -----------------------------------------------------------------------
|
||||||
|
|
||||||
type OHLC{T<:Real}
|
type OHLC{T<:Real}
|
||||||
|
|||||||
22
src/plot.jl
22
src/plot.jl
@ -22,7 +22,7 @@ Base.print(io::IO, plt::Plot) = print(io, string(plt))
|
|||||||
Base.show(io::IO, plt::Plot) = print(io, string(plt))
|
Base.show(io::IO, plt::Plot) = print(io, string(plt))
|
||||||
|
|
||||||
getplot(plt::Plot) = plt
|
getplot(plt::Plot) = plt
|
||||||
getinitargs(plt::Plot, idx::Int = 1) = plt.initargs
|
getplotargs(plt::Plot, idx::Int = 1) = plt.plotargs
|
||||||
convertSeriesIndex(plt::Plot, n::Int) = n
|
convertSeriesIndex(plt::Plot, n::Int) = n
|
||||||
|
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
@ -94,8 +94,8 @@ function plot!(plt::Plot, args...; kw...)
|
|||||||
|
|
||||||
# if we were able to extract guide information from the series inputs, then update the plot
|
# if we were able to extract guide information from the series inputs, then update the plot
|
||||||
# @show xmeta, ymeta
|
# @show xmeta, ymeta
|
||||||
updateDictWithMeta(d, plt.initargs, xmeta, true)
|
updateDictWithMeta(d, plt.plotargs, xmeta, true)
|
||||||
updateDictWithMeta(d, plt.initargs, ymeta, false)
|
updateDictWithMeta(d, plt.plotargs, ymeta, false)
|
||||||
|
|
||||||
# now we can plot the series
|
# now we can plot the series
|
||||||
for (i,di) in enumerate(seriesArgList)
|
for (i,di) in enumerate(seriesArgList)
|
||||||
@ -121,9 +121,9 @@ function plot!(plt::Plot, args...; kw...)
|
|||||||
|
|
||||||
# add title, axis labels, ticks, etc
|
# add title, axis labels, ticks, etc
|
||||||
if !haskey(d, :subplot)
|
if !haskey(d, :subplot)
|
||||||
merge!(plt.initargs, d)
|
merge!(plt.plotargs, d)
|
||||||
dumpdict(plt.initargs, "Updating plot items")
|
dumpdict(plt.plotargs, "Updating plot items")
|
||||||
_update_plot(plt, plt.initargs)
|
_update_plot(plt, plt.plotargs)
|
||||||
end
|
end
|
||||||
|
|
||||||
_update_plot_pos_size(plt, d)
|
_update_plot_pos_size(plt, d)
|
||||||
@ -168,13 +168,13 @@ _before_add_series(plt::Plot) = nothing
|
|||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
|
|
||||||
# should we update the x/y label given the meta info during input slicing?
|
# should we update the x/y label given the meta info during input slicing?
|
||||||
function updateDictWithMeta(d::Dict, initargs::Dict, meta::Symbol, isx::Bool)
|
function updateDictWithMeta(d::Dict, plotargs::Dict, meta::Symbol, isx::Bool)
|
||||||
lsym = isx ? :xlabel : :ylabel
|
lsym = isx ? :xlabel : :ylabel
|
||||||
if initargs[lsym] == default(lsym)
|
if plotargs[lsym] == default(lsym)
|
||||||
d[lsym] = string(meta)
|
d[lsym] = string(meta)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
updateDictWithMeta(d::Dict, initargs::Dict, meta, isx::Bool) = nothing
|
updateDictWithMeta(d::Dict, plotargs::Dict, meta, isx::Bool) = nothing
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
|
|
||||||
@ -275,7 +275,7 @@ function createKWargsList(plt::PlottingObject, x, y; kw...)
|
|||||||
numUncounted = get(d, :numUncounted, 0)
|
numUncounted = get(d, :numUncounted, 0)
|
||||||
n = plt.n + i + numUncounted
|
n = plt.n + i + numUncounted
|
||||||
dumpdict(d, "before getSeriesArgs")
|
dumpdict(d, "before getSeriesArgs")
|
||||||
d = getSeriesArgs(plt.backend, getinitargs(plt, n), d, i + numUncounted, convertSeriesIndex(plt, n), n)
|
d = getSeriesArgs(plt.backend, getplotargs(plt, n), d, i + numUncounted, convertSeriesIndex(plt, n), n)
|
||||||
dumpdict(d, "after getSeriesArgs")
|
dumpdict(d, "after getSeriesArgs")
|
||||||
d[:x], d[:y] = computeXandY(xs[mod1(i,mx)], ys[mod1(i,my)])
|
d[:x], d[:y] = computeXandY(xs[mod1(i,mx)], ys[mod1(i,my)])
|
||||||
|
|
||||||
@ -363,7 +363,7 @@ end
|
|||||||
|
|
||||||
# special handling... xmin/xmax with function(s)
|
# special handling... xmin/xmax with function(s)
|
||||||
function createKWargsList(plt::PlottingObject, f::FuncOrFuncs, xmin::Real, xmax::Real; kw...)
|
function createKWargsList(plt::PlottingObject, f::FuncOrFuncs, xmin::Real, xmax::Real; kw...)
|
||||||
width = plt.initargs[:size][1]
|
width = plt.plotargs[:size][1]
|
||||||
x = collect(linspace(xmin, xmax, width)) # we don't need more than the width
|
x = collect(linspace(xmin, xmax, width)) # we don't need more than the width
|
||||||
createKWargsList(plt, x, f; kw...)
|
createKWargsList(plt, x, f; kw...)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -128,7 +128,7 @@ Base.print(io::IO, subplt::Subplot) = print(io, string(subplt))
|
|||||||
Base.show(io::IO, subplt::Subplot) = print(io, string(subplt))
|
Base.show(io::IO, subplt::Subplot) = print(io, string(subplt))
|
||||||
|
|
||||||
getplot(subplt::Subplot, idx::Int = subplt.n) = subplt.plts[mod1(idx, subplt.p)]
|
getplot(subplt::Subplot, idx::Int = subplt.n) = subplt.plts[mod1(idx, subplt.p)]
|
||||||
getinitargs(subplt::Subplot, idx::Int) = getplot(subplt, idx).initargs
|
getplotargs(subplt::Subplot, idx::Int) = getplot(subplt, idx).plotargs
|
||||||
convertSeriesIndex(subplt::Subplot, n::Int) = ceil(Int, n / subplt.p)
|
convertSeriesIndex(subplt::Subplot, n::Int) = ceil(Int, n / subplt.p)
|
||||||
|
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
@ -225,19 +225,19 @@ function _preprocess_subplot(subplt::Subplot, d::Dict)
|
|||||||
preprocessArgs!(d)
|
preprocessArgs!(d)
|
||||||
dumpdict(d, "After subplot! preprocessing")
|
dumpdict(d, "After subplot! preprocessing")
|
||||||
|
|
||||||
# get the full initargs, overriding any new settings
|
# get the full plotargs, overriding any new settings
|
||||||
# TODO: subplt.initargs should probably be merged sooner and actually used
|
# TODO: subplt.plotargs should probably be merged sooner and actually used
|
||||||
# for color selection, etc. (i.e. if we overwrite the subplot palettes to [:heat :rainbow])
|
# for color selection, etc. (i.e. if we overwrite the subplot palettes to [:heat :rainbow])
|
||||||
# then we need to overwrite plt[1].initargs[:color_palette] to :heat before it's actually used
|
# then we need to overwrite plt[1].plotargs[:color_palette] to :heat before it's actually used
|
||||||
# for color selection!
|
# for color selection!
|
||||||
|
|
||||||
# first merge the new args into the subplot's initargs. then process the plot args and merge
|
# first merge the new args into the subplot's plotargs. then process the plot args and merge
|
||||||
# those into the plot's initargs. (example... `palette = [:blues :reds]` goes into subplt.initargs,
|
# those into the plot's plotargs. (example... `palette = [:blues :reds]` goes into subplt.plotargs,
|
||||||
# then the ColorGradient for :blues/:reds is merged into plot 1/2 initargs, which is then used for color selection)
|
# then the ColorGradient for :blues/:reds is merged into plot 1/2 plotargs, which is then used for color selection)
|
||||||
for i in 1:length(subplt.layout)
|
for i in 1:length(subplt.layout)
|
||||||
subplt.plts[i].initargs = getPlotArgs(backend(), merge(subplt.plts[i].initargs, d), i)
|
subplt.plts[i].plotargs = getPlotArgs(backend(), merge(subplt.plts[i].plotargs, d), i)
|
||||||
end
|
end
|
||||||
merge!(subplt.initargs, d)
|
merge!(subplt.plotargs, d)
|
||||||
|
|
||||||
# process links. TODO: extract to separate function
|
# process links. TODO: extract to separate function
|
||||||
for s in (:linkx, :linky, :linkfunc)
|
for s in (:linkx, :linky, :linkfunc)
|
||||||
@ -256,7 +256,7 @@ function _postprocess_subplot(subplt::Subplot, d::Dict)
|
|||||||
|
|
||||||
# add title, axis labels, ticks, etc
|
# add title, axis labels, ticks, etc
|
||||||
for (i,plt) in enumerate(subplt.plts)
|
for (i,plt) in enumerate(subplt.plts)
|
||||||
di = plt.initargs
|
di = plt.plotargs
|
||||||
dumpdict(di, "Updating sp $i")
|
dumpdict(di, "Updating sp $i")
|
||||||
_update_plot(plt, di)
|
_update_plot(plt, di)
|
||||||
end
|
end
|
||||||
@ -333,7 +333,7 @@ function subplot!(subplt::Subplot, args...; kw...)
|
|||||||
delete!(di, k)
|
delete!(di, k)
|
||||||
end
|
end
|
||||||
dumpdict(di, "subplot! kwList $i")
|
dumpdict(di, "subplot! kwList $i")
|
||||||
dumpdict(plt.initargs, "plt.initargs before plotting")
|
dumpdict(plt.plotargs, "plt.plotargs before plotting")
|
||||||
|
|
||||||
_add_series_subplot(plt; di...)
|
_add_series_subplot(plt; di...)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -13,7 +13,7 @@ type Plot{T<:PlottingPackage} <: PlottingObject{T}
|
|||||||
n::Int # number of series
|
n::Int # number of series
|
||||||
|
|
||||||
# store these just in case
|
# store these just in case
|
||||||
initargs::Dict
|
plotargs::Dict
|
||||||
seriesargs::Vector{Dict} # args for each series
|
seriesargs::Vector{Dict} # args for each series
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -38,8 +38,8 @@ type Subplot{T<:PlottingPackage, L<:SubplotLayout} <: PlottingObject{T}
|
|||||||
p::Int # number of plots
|
p::Int # number of plots
|
||||||
n::Int # number of series
|
n::Int # number of series
|
||||||
layout::L
|
layout::L
|
||||||
# initargs::Vector{Dict}
|
# plotargs::Vector{Dict}
|
||||||
initargs::Dict
|
plotargs::Dict
|
||||||
initialized::Bool
|
initialized::Bool
|
||||||
linkx::Bool
|
linkx::Bool
|
||||||
linky::Bool
|
linky::Bool
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user