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)
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)

View File

@ -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

View File

@ -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