Predetermine axis limits without plotting

조회 수: 5 (최근 30일)
Allen
Allen 2021년 3월 1일
댓글: Allen 2021년 3월 1일
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?

답변 (1개)

ANKUR KUMAR
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)
Hope this helps, or you can take a look into this thread.
  댓글 수: 1
Allen
Allen 2021년 3월 1일
Ankur,
Thank you for your reply to this post. However, your suggestion is no different than the round and padding methods that I currently employ. The problem with this method is that for min values near zero (e.g. 1e-5) and max values much greater (e.g. 1e16). The resulting limits do not produce "clean" values on the upper and lower tick marks. By "clean", I am trying to obtain upper and lower tick mark values that also coincide with the axis limits.
I should also note that I am sometimes working with data sets that are best viewed with a linear scale, and at other times with a logarithmic scale.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by