diff --git a/src/args.jl b/src/args.jl index 5dbbc35b..8f0b23ee 100644 --- a/src/args.jl +++ b/src/args.jl @@ -1143,7 +1143,8 @@ function _add_defaults!(d::KW, plt::Plot, sp::Subplot, commandIndex::Int) end # this is how many series belong to this subplot - plotIndex = count(series -> series.d[:subplot] === sp && series.d[:primary], plt.series_list) + # plotIndex = count(series -> series.d[:subplot] === sp && series.d[:primary], plt.series_list) + plotIndex = count(series -> series[:primary], sp.series_list) if get(d, :primary, true) plotIndex += 1 end diff --git a/src/backends/gr.jl b/src/backends/gr.jl index 8c9f2d2d..e2632080 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -684,9 +684,10 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) end GR.restorestate() - # TODO: can we remove? gr_set_font(xaxis[:tickfont]) - # GR.setcolormap(1000 + GR.COLORMAP_COOLWARM) + + # this needs to be here to point the colormap to the right indices + GR.setcolormap(1000 + GR.COLORMAP_COOLWARM) for (idx, series) in enumerate(series_list(sp)) st = series[:seriestype] diff --git a/src/pipeline.jl b/src/pipeline.jl index 23b273b4..958594a0 100644 --- a/src/pipeline.jl +++ b/src/pipeline.jl @@ -355,11 +355,12 @@ function _expand_subplot_extrema(sp::Subplot, d::KW, st::Symbol) end end -function _add_the_series(plt, d) +function _add_the_series(plt, sp, d) warnOnUnsupported_args(plt.backend, d) warnOnUnsupported(plt.backend, d) series = Series(d) push!(plt.series_list, series) + push!(sp.series_list, series) _series_added(plt, series) end @@ -382,7 +383,7 @@ function _process_seriesrecipe(plt::Plot, d::KW) sp = _prepare_subplot(plt, d) _prepare_annotations(sp, d) _expand_subplot_extrema(sp, d, st) - _add_the_series(plt, d) + _add_the_series(plt, sp, d) else # get a sub list of series for this seriestype diff --git a/src/subplots.jl b/src/subplots.jl index cd253a69..3400874c 100644 --- a/src/subplots.jl +++ b/src/subplots.jl @@ -3,6 +3,7 @@ function Subplot{T<:AbstractBackend}(::T; parent = RootLayout()) Subplot{T}( parent, + Series[], (20mm, 5mm, 2mm, 10mm), defaultbox, defaultbox, @@ -33,7 +34,7 @@ get_subplot(series::Series) = series.d[:subplot] get_subplot_index(plt::Plot, idx::Integer) = Int(idx) get_subplot_index(plt::Plot, sp::Subplot) = findfirst(_ -> _ === sp, plt.subplots) -series_list(sp::Subplot) = filter(series -> series.d[:subplot] === sp, sp.plt.series_list) +series_list(sp::Subplot) = sp.series_list # filter(series -> series.d[:subplot] === sp, sp.plt.series_list) function should_add_to_legend(series::Series) series.d[:primary] && series.d[:label] != "" && diff --git a/src/types.jl b/src/types.jl index 8fdb45e5..b9965eec 100644 --- a/src/types.jl +++ b/src/types.jl @@ -21,11 +21,21 @@ wrap{T}(obj::T) = InputWrapper{T}(obj) Base.isempty(wrapper::InputWrapper) = false +# ----------------------------------------------------------- + +type Series + d::KW +end + +attr(series::Series, k::Symbol) = series.d[k] +attr!(series::Series, v, k::Symbol) = (series.d[k] = v) + # ----------------------------------------------------------- # a single subplot type Subplot{T<:AbstractBackend} <: AbstractLayout parent::AbstractLayout + series_list::Vector{Series} # arguments for each series minpad::Tuple # leftpad, toppad, rightpad, bottompad bbox::BoundingBox # the canvas area which is available to this subplot plotarea::BoundingBox # the part where the data goes @@ -56,14 +66,6 @@ typealias SubplotMap Dict{Any, Subplot} # ----------------------------------------------------------- -type Series - d::KW -end - -attr(series::Series, k::Symbol) = series.d[k] -attr!(series::Series, v, k::Symbol) = (series.d[k] = v) - -# ----------------------------------------------------------- type Plot{T<:AbstractBackend} <: AbstractPlot{T} backend::T # the backend type