Predetermine axis limits without plotting
2 views (last 30 days)
Show older comments
I have a very large number of data sets (blocks) that I am currently extracting the min and max values from and plotting the results with yline in order to determine and extract the y-axis limits and major tick values. These results are used externally from MATLAB later to generate a seperate set of plot figures with consist axis scaling. This process works great as the y-axis limits and major tick values produced in this fashion are ideal. However, the issue that I have is that when trying to perfrom this task on the order of 1e4+ times it becomes cumbersome due to the need to actually have to plot the extracted extents first. This process is sped up by creating a non-visible figure, but creating, plotting, and closing the figure for each data block is still the largest task time. I have also tried using basic methods such as rounding and/or padding the extracted extents, but do not like my current approach to this since it does not always produce "clean" values for the upper and lower tick marks.
Other than plotting, does MATLAB have a built-in function that can be used to determine what the axis properties would be for a given set of values?
0 Comments
Answers (1)
ANKUR KUMAR
on 1 Mar 2021
Edited: ANKUR KUMAR
on 1 Mar 2021
You can give it a try to add small value to the maximum value of the array. It can either be 10% or 20% of the extreme.
x_vals=rand(1,10)
y_vals=rand(1,10)
threshold_coeff= 0.2 % 20 % of the extreme
x_lower=min(x_vals) - threshold_coeff*(min(x_vals))
y_lower=min(y_vals) - threshold_coeff*(min(y_vals))
x_upper=max(x_vals) + threshold_coeff*(max(x_vals))
y_upper=max(y_vals) + threshold_coeff *(max(y_vals))
You can write above equation as:
x_lower=min(x_vals)*(1-threshold_coeff)
See Also
Categories
Find more on Line Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!