fixes for push/append/set_xy
This commit is contained in:
parent
4a96122067
commit
7022ce7553
@ -1084,13 +1084,69 @@ end
|
|||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
|
|
||||||
|
# # set the lims for each axis using the axis extrema, overriding if needed
|
||||||
|
# # TODO: most of this is the same for all backends!
|
||||||
|
# function set_lims!(sp::Subplot{PyPlotBackend})
|
||||||
|
# ax = sp.o
|
||||||
|
# ax == nothing && return
|
||||||
|
# for letter in (:x, :y, :z)
|
||||||
|
# axis = sp.attr[symbol(letter,:axis)]
|
||||||
|
# # get the extrema
|
||||||
|
# lims = copy(axis[:extrema])
|
||||||
|
# # if d[:lims] != :auto, update lim when `isfinite`
|
||||||
|
# lims_override = axis[:lims]
|
||||||
|
# if lims_override != :auto
|
||||||
|
# if isfinite(lims_override[1])
|
||||||
|
# lims[1] = lims_override[1]
|
||||||
|
# end
|
||||||
|
# if isfinite(lims_override[2])
|
||||||
|
# lims[2] = lims_override[2]
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
# # ax[:set_<>lim](lims)
|
||||||
|
# # TODO: check for polar, set tlim/rlim instead
|
||||||
|
# func = symbol(:set_, letter, :lim)
|
||||||
|
# if haskey(ax, func)
|
||||||
|
# ax[func](lims...)
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
|
||||||
|
function set_lims!(sp::Subplot{PyPlotBackend}, axis::Axis)
|
||||||
|
lims = copy(axis[:extrema])
|
||||||
|
# if d[:lims] != :auto, update lim when `isfinite`
|
||||||
|
lims_override = axis[:lims]
|
||||||
|
if lims_override != :auto
|
||||||
|
if isfinite(lims_override[1])
|
||||||
|
lims[1] = lims_override[1]
|
||||||
|
end
|
||||||
|
if isfinite(lims_override[2])
|
||||||
|
lims[2] = lims_override[2]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
# TODO: check for polar, set tlim/rlim instead
|
||||||
|
|
||||||
|
# pyplot's set_xlim (or y/z) method:
|
||||||
|
sp.o[symbol(:set_, axis[:letter], :lim)](lims...)
|
||||||
|
end
|
||||||
|
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
|
|
||||||
# TODO: d[:serieshandle] should really be a list of handles... then we should set
|
# get_axis and update_limits! should be moved to subplots.jl? or axes.jl?
|
||||||
# the x/y data for each handle (for example, plot and scatter)
|
|
||||||
|
get_axis(sp::Subplot, letter::Symbol) = sp.attr[symbol(letter, :axis)]
|
||||||
|
|
||||||
|
function update_limits!(sp::Subplot{PyPlotBackend}, series::Series, letters)
|
||||||
|
for letter in letters
|
||||||
|
axis = get_axis(sp, letter)
|
||||||
|
expand_extrema!(axis, series.d[letter])
|
||||||
|
set_lims!(sp, axis)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function setxy!{X,Y}(plt::Plot{PyPlotBackend}, xy::Tuple{X,Y}, i::Integer)
|
function setxy!{X,Y}(plt::Plot{PyPlotBackend}, xy::Tuple{X,Y}, i::Integer)
|
||||||
d = plt.series_list[i].d
|
series = plt.series_list[i]
|
||||||
|
d = series.d
|
||||||
d[:x], d[:y] = xy
|
d[:x], d[:y] = xy
|
||||||
for handle in d[:serieshandle]
|
for handle in d[:serieshandle]
|
||||||
try
|
try
|
||||||
@ -1100,18 +1156,26 @@ function setxy!{X,Y}(plt::Plot{PyPlotBackend}, xy::Tuple{X,Y}, i::Integer)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
# set_lims!(plt, plt.series_list[i])
|
# set_lims!(plt, plt.series_list[i])
|
||||||
|
# expand_extrema!(axis, d[letter])
|
||||||
|
# set_lims!(d[:subplot])
|
||||||
|
update_limits!(d[:subplot], series, (:x,:y))
|
||||||
plt
|
plt
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function setxyz!{X,Y,Z}(plt::Plot{PyPlotBackend}, xyz::Tuple{X,Y,Z}, i::Integer)
|
function setxyz!{X,Y,Z}(plt::Plot{PyPlotBackend}, xyz::Tuple{X,Y,Z}, i::Integer)
|
||||||
d = plt.series_list[i].d
|
# d = plt.series_list[i].d
|
||||||
|
series = plt.series_list[i]
|
||||||
|
d = series.d
|
||||||
d[:x], d[:y], d[:z] = xyz
|
d[:x], d[:y], d[:z] = xyz
|
||||||
|
# d[:x], d[:y], d[:z] = xyz
|
||||||
for handle in d[:serieshandle]
|
for handle in d[:serieshandle]
|
||||||
handle[:set_data](d[:x], d[:y])
|
handle[:set_data](d[:x], d[:y])
|
||||||
handle[:set_3d_properties](d[:z])
|
handle[:set_3d_properties](d[:z])
|
||||||
end
|
end
|
||||||
# set_lims!(plt, plt.series_list[i])
|
# set_lims!(plt, plt.series_list[i])
|
||||||
|
# set_lims!(d[:subplot])
|
||||||
|
update_limits!(d[:subplot], series, (:x,:y,:z))
|
||||||
plt
|
plt
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
18
src/plot.jl
18
src/plot.jl
@ -534,14 +534,14 @@ annotations(anns) = Any[anns]
|
|||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
|
|
||||||
function Base.copy(plt::Plot)
|
# function Base.copy(plt::Plot)
|
||||||
backend(plt.backend)
|
# backend(plt.backend)
|
||||||
plt2 = plot(; plt.plotargs...)
|
# plt2 = plot(; plt.plotargs...)
|
||||||
for sargs in plt.seriesargs
|
# for sargs in plt.seriesargs
|
||||||
sargs = filter((k,v) -> haskey(_series_defaults,k), sargs)
|
# sargs = filter((k,v) -> haskey(_series_defaults,k), sargs)
|
||||||
plot!(plt2; sargs...)
|
# plot!(plt2; sargs...)
|
||||||
end
|
# end
|
||||||
plt2
|
# plt2
|
||||||
end
|
# end
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
|
|||||||
12
src/utils.jl
12
src/utils.jl
@ -472,20 +472,20 @@ tovec(v::AbstractVector) = v
|
|||||||
tovec(v::Void) = zeros(0)
|
tovec(v::Void) = zeros(0)
|
||||||
|
|
||||||
function getxy(plt::Plot, i::Integer)
|
function getxy(plt::Plot, i::Integer)
|
||||||
d = plt.seriesargs[i]
|
d = plt.series_list[i].d
|
||||||
tovec(d[:x]), tovec(d[:y])
|
tovec(d[:x]), tovec(d[:y])
|
||||||
end
|
end
|
||||||
function getxyz(plt::Plot, i::Integer)
|
function getxyz(plt::Plot, i::Integer)
|
||||||
d = plt.seriesargs[i]
|
d = plt.series_list[i].d
|
||||||
tovec(d[:x]), tovec(d[:y]), tovec(d[:z])
|
tovec(d[:x]), tovec(d[:y]), tovec(d[:z])
|
||||||
end
|
end
|
||||||
|
|
||||||
function setxy!{X,Y}(plt::Plot, xy::Tuple{X,Y}, i::Integer)
|
function setxy!{X,Y}(plt::Plot, xy::Tuple{X,Y}, i::Integer)
|
||||||
d = plt.seriesargs[i]
|
d = plt.series_list[i].d
|
||||||
d[:x], d[:y] = xy
|
d[:x], d[:y] = xy
|
||||||
end
|
end
|
||||||
function setxyz!{X,Y,Z}(plt::Plot, xyz::Tuple{X,Y,Z}, i::Integer)
|
function setxyz!{X,Y,Z}(plt::Plot, xyz::Tuple{X,Y,Z}, i::Integer)
|
||||||
d = plt.seriesargs[i]
|
d = plt.series_list[i].d
|
||||||
d[:x], d[:y], d[:z] = xyz
|
d[:x], d[:y], d[:z] = xyz
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -657,9 +657,9 @@ mm2px(mm::Real) = float(px / MM_PER_PX)
|
|||||||
|
|
||||||
|
|
||||||
"Smallest x in plot"
|
"Smallest x in plot"
|
||||||
xmin(plt::Plot) = minimum([minimum(d[:x]) for d in plt.seriesargs])
|
xmin(plt::Plot) = minimum([minimum(series.d[:x]) for series in plt.series_list])
|
||||||
"Largest x in plot"
|
"Largest x in plot"
|
||||||
xmax(plt::Plot) = maximum([maximum(d[:x]) for d in plt.seriesargs])
|
xmax(plt::Plot) = maximum([maximum(series.d[:x]) for series in plt.series_list])
|
||||||
|
|
||||||
"Extrema of x-values in plot"
|
"Extrema of x-values in plot"
|
||||||
Base.extrema(plt::Plot) = (xmin(plt), xmax(plt))
|
Base.extrema(plt::Plot) = (xmin(plt), xmax(plt))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user