recoded violin; removed try/catch around apply_recipe; default values for xtick/ytick in GR

This commit is contained in:
Thomas Breloff 2016-06-22 11:45:30 -04:00
parent 91aa1d718a
commit 730025e144
3 changed files with 27 additions and 14 deletions

View File

@ -483,6 +483,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
data_lims = gr_xy_axislims(sp) data_lims = gr_xy_axislims(sp)
xmin, xmax, ymin, ymax = data_lims xmin, xmax, ymin, ymax = data_lims
scale = 0 scale = 0
xtick, ytick = 1, 1
if xmax > xmin && ymax > ymin 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 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) # 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)

View File

@ -225,12 +225,13 @@ function _apply_series_recipe(plt::Plot, d::KW)
else else
# get a sub list of series for this seriestype # get a sub list of series for this seriestype
datalist = try datalist = RecipesBase.apply_recipe(d, Val{st}, d[:x], d[:y], d[:z])
RecipesBase.apply_recipe(d, Val{st}, d[:x], d[:y], d[:z]) # datalist = try
catch # RecipesBase.apply_recipe(d, Val{st}, d[:x], d[:y], d[:z])
warn("Exception during apply_recipe(Val{$st}, ...) with types ($(typeof(d[:x])), $(typeof(d[:y])), $(typeof(d[:z])))") # catch
rethrow() # warn("Exception during apply_recipe(Val{$st}, ...) with types ($(typeof(d[:x])), $(typeof(d[:y])), $(typeof(d[:z])))")
end # rethrow()
# end
# assuming there was no error, recursively apply the series recipes # assuming there was no error, recursively apply the series recipes
for data in datalist for data in datalist

View File

@ -750,18 +750,24 @@ else
end end
# function apply_series_recipe(d::KW, ::Type{Val{:violin}})
@recipe function f(::Type{Val{:violin}}, x, y, z; trim=true) @recipe function f(::Type{Val{:violin}}, x, y, z; trim=true)
delete!(d, :trim) delete!(d, :trim)
# create a list of shapes, where each shape is a single boxplot # create a list of shapes, where each shape is a single boxplot
shapes = Shape[] # shapes = Shape[]
groupby = extractGroupArgs(x) 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 # get the edges and widths
y = d[:y][groupby.groupIds[i]] # gids = groupby.groupIds[i]
widths, centers = violin_coords(y, trim=trim) # 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 isempty(widths) && continue
# normalize # normalize
@ -771,11 +777,16 @@ end
xcenter = discrete_value!(d[:subplot][:xaxis], glabel)[1] xcenter = discrete_value!(d[:subplot][:xaxis], glabel)[1]
xcoords = vcat(widths, -reverse(widths)) + xcenter xcoords = vcat(widths, -reverse(widths)) + xcenter
ycoords = vcat(centers, reverse(centers)) ycoords = vcat(centers, reverse(centers))
push!(shapes, Shape(xcoords, ycoords)) # push!(shapes, Shape(xcoords, ycoords))
push!(xsegs, xcoords)
push!(ysegs, ycoords)
end end
seriestype := :shape seriestype := :shape
d[:x], d[:y] = shape_coords(shapes) # d[:x], d[:y] = shape_coords(shapes)
x := xsegs.pts
y := ysegs.pts
() ()
end end
@deps violin shape @deps violin shape