working on axis limit fixes
This commit is contained in:
parent
6c7b113de5
commit
32e816b713
@ -165,7 +165,7 @@ const _series_defaults = KW(
|
|||||||
:levels => 15,
|
:levels => 15,
|
||||||
:orientation => :vertical,
|
:orientation => :vertical,
|
||||||
:bar_position => :overlay, # for bar plots and histograms: could also be stack (stack up) or dodge (side by side)
|
:bar_position => :overlay, # for bar plots and histograms: could also be stack (stack up) or dodge (side by side)
|
||||||
:bar_width => 0.8,
|
:bar_width => nothing,
|
||||||
:bar_edges => false,
|
:bar_edges => false,
|
||||||
:xerror => nothing,
|
:xerror => nothing,
|
||||||
:yerror => nothing,
|
:yerror => nothing,
|
||||||
|
|||||||
52
src/axes.jl
52
src/axes.jl
@ -130,6 +130,58 @@ function expand_extrema!{N<:Number}(axis::Axis, v::AVec{N})
|
|||||||
ex
|
ex
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function expand_extrema!(sp::Subplot, d::KW)
|
||||||
|
# first expand for the data
|
||||||
|
for letter in (:x, :y, :z)
|
||||||
|
data = d[letter]
|
||||||
|
axis = sp.attr[Symbol(letter, "axis")]
|
||||||
|
if eltype(data) <: Number
|
||||||
|
expand_extrema!(axis, data)
|
||||||
|
elseif isa(data, Surface) && eltype(data.surf) <: Number
|
||||||
|
expand_extrema!(axis, data)
|
||||||
|
elseif data != nothing
|
||||||
|
# TODO: need more here... gotta track the discrete reference value
|
||||||
|
# as well as any coord offset (think of boxplot shape coords... they all
|
||||||
|
# correspond to the same x-value)
|
||||||
|
# @show letter,eltype(data),typeof(data)
|
||||||
|
d[letter], d[Symbol(letter,"_discrete_indices")] = discrete_value!(axis, data)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# # expand for fillrange/bar_width
|
||||||
|
# fillaxis, baraxis = sp.attr[:yaxis], sp.attr[:xaxis]
|
||||||
|
# if isvertical(d)
|
||||||
|
# fillaxis, baraxis = baraxis, fillaxis
|
||||||
|
# end
|
||||||
|
|
||||||
|
# expand for fillrange
|
||||||
|
vert = isvertical(d)
|
||||||
|
fr = d[:fillrange]
|
||||||
|
if fr == nothing && d[:seriestype] == :bar
|
||||||
|
fr = 0.0
|
||||||
|
end
|
||||||
|
expand_extrema!(sp.attr[vert ? :yaxis : :xaxis], fr)
|
||||||
|
# @show d[:fillrange] d[:bar_width]
|
||||||
|
|
||||||
|
# expand for bar_width
|
||||||
|
if d[:seriestype] == :bar
|
||||||
|
dsym = vert ? :x : :y
|
||||||
|
data = d[dsym]
|
||||||
|
|
||||||
|
bw = d[:bar_width]
|
||||||
|
if bw == nothing
|
||||||
|
bw = d[:bar_width] = mean(diff(data))
|
||||||
|
end
|
||||||
|
@show data bw
|
||||||
|
|
||||||
|
axis = sp.attr[Symbol(dsym, :axis)]
|
||||||
|
expand_extrema!(axis, maximum(data) + 0.5maximum(bw))
|
||||||
|
expand_extrema!(axis, minimum(data) - 0.5minimum(bw))
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
# -------------------------------------------------------------------------
|
# -------------------------------------------------------------------------
|
||||||
|
|
||||||
# push the limits out slightly
|
# push the limits out slightly
|
||||||
|
|||||||
@ -633,14 +633,14 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
for axis_idx = 1:num_axes
|
for axis_idx = 1:num_axes
|
||||||
xmin, xmax, ymin, ymax = extrema[axis_idx,:]
|
xmin, xmax, ymin, ymax = extrema[axis_idx,:]
|
||||||
if scale & GR.OPTION_X_LOG == 0
|
if scale & GR.OPTION_X_LOG == 0
|
||||||
xmin, xmax = GR.adjustlimits(xmin, xmax)
|
# xmin, xmax = GR.adjustlimits(xmin, xmax)
|
||||||
majorx = 5
|
majorx = 5
|
||||||
xtick = GR.tick(xmin, xmax) / majorx
|
xtick = GR.tick(xmin, xmax) / majorx
|
||||||
else
|
else
|
||||||
xtick = majorx = 1
|
xtick = majorx = 1
|
||||||
end
|
end
|
||||||
if scale & GR.OPTION_Y_LOG == 0
|
if scale & GR.OPTION_Y_LOG == 0
|
||||||
ymin, ymax = GR.adjustlimits(ymin, ymax)
|
# ymin, ymax = GR.adjustlimits(ymin, ymax)
|
||||||
majory = 5
|
majory = 5
|
||||||
ytick = GR.tick(ymin, ymax) / majory
|
ytick = GR.tick(ymin, ymax) / majory
|
||||||
else
|
else
|
||||||
|
|||||||
@ -40,7 +40,7 @@ supportedArgs(::PyPlotBackend) = [
|
|||||||
supportedAxes(::PyPlotBackend) = _allAxes
|
supportedAxes(::PyPlotBackend) = _allAxes
|
||||||
supportedTypes(::PyPlotBackend) = [
|
supportedTypes(::PyPlotBackend) = [
|
||||||
:none, :line, :path, :steppre, :steppost, :shape,
|
:none, :line, :path, :steppre, :steppost, :shape,
|
||||||
:scatter, :histogram2d, :hexbin, :histogram, :density,
|
:scatter, :histogram2d, :hexbin, #:histogram, #:density,
|
||||||
:bar, :sticks, #:box, :violin, :quiver,
|
:bar, :sticks, #:box, :violin, :quiver,
|
||||||
:hline, :vline, :heatmap, :pie, :image,
|
:hline, :vline, :heatmap, :pie, :image,
|
||||||
:contour, :contour3d, :path3d, :scatter3d, :surface, :wireframe
|
:contour, :contour3d, :path3d, :scatter3d, :surface, :wireframe
|
||||||
@ -507,7 +507,11 @@ function _series_added(plt::Plot{PyPlotBackend}, series::Series)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if st == :bar
|
if st == :bar
|
||||||
extrakw[isvertical(d) ? :width : :height] = d[:bar_width]
|
bw = d[:bar_width]
|
||||||
|
if bw == nothing
|
||||||
|
bw = mean(diff(isvertical(d) ? x : y))
|
||||||
|
end
|
||||||
|
extrakw[isvertical(d) ? :width : :height] = bw
|
||||||
fr = get(d, :fillrange, nothing)
|
fr = get(d, :fillrange, nothing)
|
||||||
if fr != nothing
|
if fr != nothing
|
||||||
extrakw[:bottom] = fr
|
extrakw[:bottom] = fr
|
||||||
@ -568,21 +572,21 @@ function _series_added(plt::Plot{PyPlotBackend}, series::Series)
|
|||||||
push!(handles, handle)
|
push!(handles, handle)
|
||||||
end
|
end
|
||||||
|
|
||||||
if st == :histogram
|
# if st == :histogram
|
||||||
handle = ax[:hist](y;
|
# handle = ax[:hist](y;
|
||||||
label = d[:label],
|
# label = d[:label],
|
||||||
zorder = plt.n,
|
# zorder = plt.n,
|
||||||
color = pyfillcolor(d),
|
# color = pyfillcolor(d),
|
||||||
edgecolor = pylinecolor(d),
|
# edgecolor = pylinecolor(d),
|
||||||
linewidth = d[:linewidth],
|
# linewidth = d[:linewidth],
|
||||||
bins = d[:bins],
|
# bins = d[:bins],
|
||||||
normed = d[:normalize],
|
# normed = d[:normalize],
|
||||||
weights = d[:weights],
|
# weights = d[:weights],
|
||||||
orientation = (isvertical(d) ? "vertical" : "horizontal"),
|
# orientation = (isvertical(d) ? "vertical" : "horizontal"),
|
||||||
histtype = (d[:bar_position] == :stack ? "barstacked" : "bar")
|
# histtype = (d[:bar_position] == :stack ? "barstacked" : "bar")
|
||||||
)[3]
|
# )[3]
|
||||||
push!(handles, handle)
|
# push!(handles, handle)
|
||||||
end
|
# end
|
||||||
|
|
||||||
if st == :histogram2d
|
if st == :histogram2d
|
||||||
handle = ax[:hist2d](x, y;
|
handle = ax[:hist2d](x, y;
|
||||||
|
|||||||
34
src/plot.jl
34
src/plot.jl
@ -171,24 +171,26 @@ function _apply_series_recipe(plt::Plot, d::KW)
|
|||||||
end
|
end
|
||||||
|
|
||||||
# adjust extrema and discrete info
|
# adjust extrema and discrete info
|
||||||
if st != :image
|
if !(st in (:image, :histogram, :histogram2d))
|
||||||
for letter in (:x, :y, :z)
|
expand_extrema!(sp, d)
|
||||||
data = d[letter]
|
# for letter in (:x, :y, :z)
|
||||||
axis = sp.attr[Symbol(letter, "axis")]
|
# data = d[letter]
|
||||||
if eltype(data) <: Number
|
# axis = sp.attr[Symbol(letter, "axis")]
|
||||||
expand_extrema!(axis, data)
|
# if eltype(data) <: Number
|
||||||
elseif isa(data, Surface) && eltype(data.surf) <: Number
|
# expand_extrema!(axis, data)
|
||||||
expand_extrema!(axis, data)
|
# elseif isa(data, Surface) && eltype(data.surf) <: Number
|
||||||
elseif data != nothing
|
# expand_extrema!(axis, data)
|
||||||
# TODO: need more here... gotta track the discrete reference value
|
# elseif data != nothing
|
||||||
# as well as any coord offset (think of boxplot shape coords... they all
|
# # TODO: need more here... gotta track the discrete reference value
|
||||||
# correspond to the same x-value)
|
# # as well as any coord offset (think of boxplot shape coords... they all
|
||||||
# @show letter,eltype(data),typeof(data)
|
# # correspond to the same x-value)
|
||||||
d[letter], d[Symbol(letter,"_discrete_indices")] = discrete_value!(axis, data)
|
# # @show letter,eltype(data),typeof(data)
|
||||||
end
|
# d[letter], d[Symbol(letter,"_discrete_indices")] = discrete_value!(axis, data)
|
||||||
end
|
# end
|
||||||
|
# end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
# add the series!
|
# add the series!
|
||||||
warnOnUnsupportedArgs(plt.backend, d)
|
warnOnUnsupportedArgs(plt.backend, d)
|
||||||
warnOnUnsupported(plt.backend, d)
|
warnOnUnsupported(plt.backend, d)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user