Adding text to axis label.
조회 수: 19 (최근 30일)
이전 댓글 표시
I have several codes that read in data from Excel files based on parameter mneumonics. Those mneumonics are used to search another Excel file for a more descriptive parameter name. For example mneumonic ADCIAS_PCM2 will retieve INDICATED AIRSPEED (KTS) as a plot axis label. That axis label is universal and I use it for my x-axis. I want to add text at each end of the x-axis for REARWARD (at the negative x-axis end) and FORWARD (at the positive x-axis end). The current plot goes from -50 to +50. I used the following lines and they work, but the problem arises if the y-axis scaling is different the text will be higher or lower relative to the x-axis. How can I add this text such that it will stay inline with the xlabel?
text(-50,-0.1,'RWD','FontSize',8,'FontWeight','bold');
text( 47,-0.1,'FWD','FontSize',8,'FontWeight','bold');
댓글 수: 0
답변 (2개)
Image Analyst
2020년 1월 15일
Use the xlabel() and ylabel() commands instead.
xlabel('RWD','FontSize',8, 'FontWeight','bold');
If you want to use text() because you want the text to be in some box somewhere on the graph, then you'll have to replace those numbers for x and y in text() with something based on xlim() and ylim(). For example
% Place text 40% of the way over in x and 60% up in y.
caption = sprintf('The direction is %s', directionString);
xl = xlim;
yl = ylim;
xt = xl(1) + 0.4 * (xl(2) - xl(1));
yt = yl(1) + 0.6 * (yl(2) - yl(1));
text(xt, yt, caption,'FontSize',8, 'FontWeight','bold', 'Horizontal Alignment', 'left');
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!