Pre-determine plot ranges?
13 views (last 30 days)
Given two vectors of the same length is there a way to determine the axes ranges that would result if the data were plotted without plotting the data?
I am looking to update xlim and ylim manually after the plotted data is changed* but with out relying on the automatic resizing as there are other things plotted that I dont want to be used in determining the plot ranges. Also I would rather not redraw the entire figure with just the modified data then redraw the larger thing.
(plotted data is changed*: I am manipulating the XData and YData parameter of plotted data directly with a handle.)
Adam Danz on 21 Aug 2019
Edited: Adam Danz on 21 Aug 2019
If vector1 and vector1 are the x and y values to be plotted, the xlim and ylim for a tight axis would be,
If you'd like to access those values from the line object handle 'h',
If you'd like to add 5% of the data range on each side so your max and min data points are not on the axis edges,
xlim([min(x),max(x)] + [-1,1]*.05*range(x))
ylim([min(y),max(y)] + [-1,1]*.05*range(y))