unicodeplots lims

This commit is contained in:
Thomas Breloff 2015-09-29 12:00:48 -04:00
parent 029ad1045a
commit 54f09c58cb

View File

@ -42,11 +42,11 @@ supportedArgs(::UnicodePlotsPackage) = [
:windowtitle, :windowtitle,
:x, :x,
:xlabel, :xlabel,
# :xlims, :xlims,
# :xticks, # :xticks,
:y, :y,
:ylabel, :ylabel,
# :ylims, :ylims,
# :yrightlabel, # :yrightlabel,
# :yticks, # :yticks,
] ]
@ -69,17 +69,35 @@ function rebuildUnicodePlot!(plt::Plot)
# figure out the plotting area xlim = [xmin, xmax] and ylim = [ymin, ymax] # figure out the plotting area xlim = [xmin, xmax] and ylim = [ymin, ymax]
sargs = plt.seriesargs sargs = plt.seriesargs
xlim = [Inf, -Inf] iargs = plt.initargs
ylim = [Inf, -Inf]
for d in sargs # get the x/y limits
expandLimits!(xlim, d[:x]) if get(iargs, :xlims, :auto) == :auto
expandLimits!(ylim, d[:y]) xlim = [Inf, -Inf]
for d in sargs
expandLimits!(xlim, d[:x])
end
else
xmin, xmax = iargs[:xlims]
xlim = [xmin, xmax]
end end
if get(iargs, :ylims, :auto) == :auto
ylim = [Inf, -Inf]
for d in sargs
expandLimits!(ylim, d[:y])
end
else
ymin, ymax = iargs[:ylims]
ylim = [ymin, ymax]
end
# we set x/y to have a single point, since we need to create the plot with some data.
# since this point is at the bottom left corner of the plot, it shouldn't actually be shown
x = Float64[xlim[1]] x = Float64[xlim[1]]
y = Float64[ylim[1]] y = Float64[ylim[1]]
# create a plot window with xlim/ylim set, but the X/Y vectors are outside the bounds # create a plot window with xlim/ylim set, but the X/Y vectors are outside the bounds
iargs = plt.initargs
width, height = iargs[:size] width, height = iargs[:size]
o = UnicodePlots.createPlotWindow(x, y; width = width, o = UnicodePlots.createPlotWindow(x, y; width = width,
height = height, height = height,
@ -165,7 +183,7 @@ end
function updatePlotItems(plt::Plot{UnicodePlotsPackage}, d::Dict) function updatePlotItems(plt::Plot{UnicodePlotsPackage}, d::Dict)
for k in (:title, :xlabel, :ylabel) for k in (:title, :xlabel, :ylabel, :xlims, :ylims)
if haskey(d, k) if haskey(d, k)
plt.initargs[k] = d[k] plt.initargs[k] = d[k]
end end