Adding text to axis label.
19 views (last 30 days)
Show older comments
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 Comments
Answers (2)
Image Analyst
on 15 Jan 2020
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 Comments
See Also
Categories
Find more on Annotations 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!