pyplot lim fixes
This commit is contained in:
parent
26d0dfbf3d
commit
347820867d
@ -461,30 +461,42 @@ function Base.getindex(plt::Plot{PyPlotPackage}, i::Integer)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function minmaxseries(ds, vec, axis)
|
||||||
|
lo, hi = Inf, -Inf
|
||||||
|
for d in ds
|
||||||
|
d[:axis] == axis || continue
|
||||||
|
v = d[vec]
|
||||||
|
if length(v) > 0
|
||||||
|
vlo, vhi = extrema(v)
|
||||||
|
lo = min(lo, vlo)
|
||||||
|
hi = max(hi, vhi)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
lo, hi
|
||||||
|
end
|
||||||
|
|
||||||
|
function set_lims!(plt::Plot{PyPlotPackage}, axis::Symbol)
|
||||||
|
ax = getAxis(plt, axis)
|
||||||
|
if plt.plotargs[:xlims] == :auto
|
||||||
|
ax[:set_xlim](minmaxseries(plt.seriesargs, :x, axis)...)
|
||||||
|
end
|
||||||
|
if plt.plotargs[:ylims] == :auto
|
||||||
|
ax[:set_ylim](minmaxseries(plt.seriesargs, :y, axis)...)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function Base.setindex!{X,Y}(plt::Plot{PyPlotPackage}, xy::Tuple{X,Y}, i::Integer)
|
function Base.setindex!{X,Y}(plt::Plot{PyPlotPackage}, xy::Tuple{X,Y}, i::Integer)
|
||||||
series = plt.seriesargs[i][:serieshandle]
|
d = plt.seriesargs[i]
|
||||||
|
series = d[:serieshandle]
|
||||||
x, y = xy
|
x, y = xy
|
||||||
|
d[:x], d[:y] = x, y
|
||||||
try
|
try
|
||||||
series[:set_data](x, y)
|
series[:set_data](x, y)
|
||||||
catch
|
catch
|
||||||
series[:set_offsets](hcat(x, y))
|
series[:set_offsets](hcat(x, y))
|
||||||
end
|
end
|
||||||
|
|
||||||
ax = series[:axes]
|
set_lims!(plt, d[:axis])
|
||||||
ax[:relim]()
|
|
||||||
ax[:autoscale]()
|
|
||||||
if plt.plotargs[:xlims] != :auto
|
|
||||||
# xmin, xmax = ax[:get_xlim]()
|
|
||||||
# ax[:set_xlim](min(xmin, minimum(x)), max(xmax, maximum(x)))
|
|
||||||
addPyPlotLims(ax, plt.plotargs[:xlims], true)
|
|
||||||
end
|
|
||||||
if plt.plotargs[:ylims] != :auto
|
|
||||||
# ymin, ymax = ax[:get_ylim]()
|
|
||||||
# ax[:set_ylim](min(ymin, minimum(y)), max(ymax, maximum(y)))
|
|
||||||
addPyPlotLims(ax, plt.plotargs[:ylims], false)
|
|
||||||
end
|
|
||||||
PyPlot.draw()
|
|
||||||
|
|
||||||
plt
|
plt
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user