This commit is contained in:
parent
85f0a87213
commit
6fe87c4c69
@ -28,6 +28,7 @@ supported_args(::GRBackend) = merge_with_base_supported([
|
||||
:aspect_ratio,
|
||||
:normalize, :weights,
|
||||
:inset_subplots,
|
||||
:bar_width,
|
||||
])
|
||||
supported_types(::GRBackend) = [
|
||||
:path, :scatter,
|
||||
|
||||
@ -248,10 +248,11 @@ function setup_atom()
|
||||
# @eval import Atom, Media
|
||||
@eval import Atom
|
||||
|
||||
# connects the render function
|
||||
for T in (GadflyBackend,ImmerseBackend,PyPlotBackend,GRBackend)
|
||||
Atom.Media.media(Plot{T}, Atom.Media.Plot)
|
||||
end
|
||||
# # connects the render function
|
||||
# for T in (GadflyBackend,ImmerseBackend,PyPlotBackend,GRBackend)
|
||||
# Atom.Media.media(Plot{T}, Atom.Media.Plot)
|
||||
# end
|
||||
Atom.Media.media(Plot, Atom.Media.Graphical)
|
||||
# Atom.Media.media{T <: Union{GadflyBackend,ImmerseBackend,PyPlotBackend,GRBackend}}(Plot{T}, Atom.Media.Plot)
|
||||
|
||||
# Atom.displaysize(::Plot) = (535, 379)
|
||||
@ -259,9 +260,15 @@ function setup_atom()
|
||||
|
||||
# this is like "display"... sends an html div with the plot to the PlotPane
|
||||
function Atom.Media.render(pane::Atom.PlotPane, plt::Plot)
|
||||
@show "here"
|
||||
Atom.Media.render(pane, Atom.div(Atom.d(), Atom.HTML(stringmime(MIME("text/html"), plt))))
|
||||
end
|
||||
|
||||
# # force text/plain to output to the PlotPane
|
||||
# function Base.writemime(io::IO, ::MIME"text/plain", plt::Plot)
|
||||
# # writemime(io::IO, MIME("text/html"), plt)
|
||||
# Atom.Media.render(pane)
|
||||
# end
|
||||
|
||||
# function Atom.Media.render(pane::Atom.PlotPane, plt::Plot{PlotlyBackend})
|
||||
# html = Media.render(pane, Atom.div(Atom.d(), Atom.HTML(stringmime(MIME("text/html"), plt))))
|
||||
|
||||
@ -399,25 +399,21 @@ end
|
||||
end
|
||||
|
||||
nx, ny = length(x), length(y)
|
||||
edges = if nx == ny
|
||||
# x is centers, calc the edges
|
||||
# TODO: use bar_width, etc
|
||||
midpoints = x
|
||||
halfwidths = diff(midpoints) * 0.5
|
||||
Float64[if i == 1
|
||||
midpoints[1] - halfwidths[1]
|
||||
elseif i == ny+1
|
||||
midpoints[i-1] + halfwidths[i-2]
|
||||
else
|
||||
midpoints[i-1] + halfwidths[i-1]
|
||||
end for i=1:ny+1]
|
||||
elseif nx == ny + 1
|
||||
# x is edges
|
||||
centers = if nx == ny
|
||||
x
|
||||
elseif nx == ny + 1
|
||||
diff(x) + x[1:end-1]
|
||||
else
|
||||
error("bar recipe: x must be same length as y (centers), or one more than y (edges).\n\t\tlength(x)=$(length(x)), length(y)=$(length(y))")
|
||||
end
|
||||
|
||||
bw = d[:bar_width]
|
||||
hw = if bw == nothing
|
||||
0.5mean(diff(centers))
|
||||
else
|
||||
Float64[0.5cycle(bw,i) for i=1:length(centers)]
|
||||
end
|
||||
|
||||
# make fillto a vector... default fills to 0
|
||||
fillto = d[:fillrange]
|
||||
if fillto == nothing
|
||||
@ -427,9 +423,12 @@ end
|
||||
# create the bar shapes by adding x/y segments
|
||||
xseg, yseg = Segments(), Segments()
|
||||
for i=1:ny
|
||||
ci = centers[i]
|
||||
hwi = cycle(hw,i)
|
||||
yi = y[i]
|
||||
fi = cycle(fillto,i)
|
||||
push!(xseg, edges[i], edges[i], edges[i+1], edges[i+1])
|
||||
push!(yseg, y[i], fi, fi, y[i])
|
||||
push!(xseg, ci-hwi, ci-hwi, ci+hwi, ci+hwi, ci-hwi)
|
||||
push!(yseg, yi, fi, fi, yi, yi)
|
||||
end
|
||||
|
||||
# switch back
|
||||
@ -442,7 +441,7 @@ end
|
||||
seriestype := :shape
|
||||
()
|
||||
end
|
||||
@deps bar path
|
||||
@deps bar shape
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Histograms
|
||||
@ -569,7 +568,7 @@ notch_width(q2, q4, N) = 1.58 * (q4-q2)/sqrt(N)
|
||||
glabels = sort(collect(unique(x)))
|
||||
warning = false
|
||||
outliers_x, outliers_y = zeros(0), zeros(0)
|
||||
for glabel in glabels
|
||||
for (i,glabel) in enumerate(glabels)
|
||||
# filter y
|
||||
values = y[filter(i -> cycle(x,i) == glabel, 1:length(y))]
|
||||
|
||||
@ -587,10 +586,11 @@ notch_width(q2, q4, N) = 1.58 * (q4-q2)/sqrt(N)
|
||||
|
||||
# make the shape
|
||||
center = discrete_value!(d[:subplot][:xaxis], glabel)[1]
|
||||
l, m, r = center - _box_halfwidth, center, center + _box_halfwidth
|
||||
hw = d[:bar_width] == nothing ? _box_halfwidth : 0.5cycle(d[:bar_width], i)
|
||||
l, m, r = center - hw, center, center + hw
|
||||
|
||||
# internal nodes for notches
|
||||
L, R = center - 0.5 * _box_halfwidth, center + 0.5 * _box_halfwidth
|
||||
L, R = center - 0.5 * hw, center + 0.5 * hw
|
||||
|
||||
# outliers
|
||||
if Float64(range) != 0.0 # if the range is 0.0, the whiskers will extend to the data
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user