Predetermine axis limits without plotting
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
ANKUR KUMAR
2021-3-1
编辑:ANKUR KUMAR
2021-3-1
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)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!