From 730025e144b1d5e208eedb496787fd79a5df452a Mon Sep 17 00:00:00 2001 From: Thomas Breloff Date: Wed, 22 Jun 2016 11:45:30 -0400 Subject: [PATCH] recoded violin; removed try/catch around apply_recipe; default values for xtick/ytick in GR --- src/backends/gr.jl | 1 + src/plot.jl | 13 +++++++------ src/recipes.jl | 27 +++++++++++++++++++-------- 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/backends/gr.jl b/src/backends/gr.jl index 6c7d8694..7f7c7903 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -483,6 +483,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) data_lims = gr_xy_axislims(sp) xmin, xmax, ymin, ymax = data_lims scale = 0 + xtick, ytick = 1, 1 if xmax > xmin && ymax > ymin # NOTE: for log axes, the major_x and major_y - if non-zero (omit labels) - control the minor grid lines (1 = draw 9 minor grid lines, 2 = no minor grid lines) # NOTE: for log axes, the x_tick and y_tick - if non-zero (omit axes) - only affect the output appearance (1 = nomal, 2 = scientiic notation) diff --git a/src/plot.jl b/src/plot.jl index 05073033..8b9fdbd2 100644 --- a/src/plot.jl +++ b/src/plot.jl @@ -225,12 +225,13 @@ function _apply_series_recipe(plt::Plot, d::KW) else # get a sub list of series for this seriestype - datalist = try - RecipesBase.apply_recipe(d, Val{st}, d[:x], d[:y], d[:z]) - catch - warn("Exception during apply_recipe(Val{$st}, ...) with types ($(typeof(d[:x])), $(typeof(d[:y])), $(typeof(d[:z])))") - rethrow() - end + datalist = RecipesBase.apply_recipe(d, Val{st}, d[:x], d[:y], d[:z]) + # datalist = try + # RecipesBase.apply_recipe(d, Val{st}, d[:x], d[:y], d[:z]) + # catch + # warn("Exception during apply_recipe(Val{$st}, ...) with types ($(typeof(d[:x])), $(typeof(d[:y])), $(typeof(d[:z])))") + # rethrow() + # end # assuming there was no error, recursively apply the series recipes for data in datalist diff --git a/src/recipes.jl b/src/recipes.jl index 15f9ffe1..33c15701 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -750,18 +750,24 @@ else end -# function apply_series_recipe(d::KW, ::Type{Val{:violin}}) @recipe function f(::Type{Val{:violin}}, x, y, z; trim=true) delete!(d, :trim) # create a list of shapes, where each shape is a single boxplot - shapes = Shape[] - groupby = extractGroupArgs(x) + # shapes = Shape[] + xsegs, ysegs = Segments(), Segments() + # groupby = extractGroupArgs(x) + glabels = sort(collect(unique(x))) - for (i, glabel) in enumerate(groupby.groupLabels) + # for (i, glabel) in enumerate(groupby.groupLabels) + for glabel in glabels # get the edges and widths - y = d[:y][groupby.groupIds[i]] - widths, centers = violin_coords(y, trim=trim) + # gids = groupby.groupIds[i] + # y = eltype(y)[yi for (i,yi) in e] + # y = y[filter(i -> cycle(x,i) == glabel, 1:length(y))] + + # y = d[:y][groupby.groupIds[i]] + widths, centers = violin_coords(y[filter(i -> cycle(x,i) == glabel, 1:length(y))], trim=trim) isempty(widths) && continue # normalize @@ -771,11 +777,16 @@ end xcenter = discrete_value!(d[:subplot][:xaxis], glabel)[1] xcoords = vcat(widths, -reverse(widths)) + xcenter ycoords = vcat(centers, reverse(centers)) - push!(shapes, Shape(xcoords, ycoords)) + # push!(shapes, Shape(xcoords, ycoords)) + + push!(xsegs, xcoords) + push!(ysegs, ycoords) end seriestype := :shape - d[:x], d[:y] = shape_coords(shapes) + # d[:x], d[:y] = shape_coords(shapes) + x := xsegs.pts + y := ysegs.pts () end @deps violin shape