フィルターのクリア

Why is MATLAB 2015A placing the text box in the wrong location?

1 回表示 (過去 30 日間)
Brad
Brad 2015 年 5 月 28 日
コメント済み: Walter Roberson 2015 年 5 月 30 日
My group just upgraded to MATLAB 2015A. I've been running some previously developed scripts to ensure compatibility. In the process of doing so, I ran across a problem I can't solve. The following .png file shows the location of a text box assocaited with a plot.
The code used to generate this plot is as follows;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Plot Altitude - TALO / Linear
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
figure('Name','Event Altitude','numbertitle','off');
axes('Position', [0.04 0.07 1.16 0.884]);
% Plot Pre-Burnout altitudes, if they exist
if size(Pre_Altitude1) > 0
h = plot(Pre_TALO_Time1, Pre_Altitude1, '-o', 'MarkerSize', 15);
set(h(1), 'Color', 'r', 'MarkerFaceColor', 'r');
end
hold on;
% Plot Post-Burnout altitudes, if they exist
if size(Post_Altitude1) > 0
h = plot(Post_TALO_Time1, Post_Altitude1, '-d', 'MarkerSize', 15);
set(h(1), 'Color', 'r', 'MarkerFaceColor', 'r');
end
% Only hold all current axes and connect the data sets if the size of
% Pre-Altitude1 and Post-Altitude 1 is > 0
if size(Pre_Altitude1) & size(Post_Altitude1) > 0 % Use '&' since Pre/Post Altitude are arrays
aa = [Pre_TALO_Time1(end), Post_TALO_Time1(1)];
bb = [Pre_Altitude1(end), Post_Altitude1(1)];
plot(aa, bb, 'r-', 'LineWidth', 1);
end
% Plot the burnout message data points, if they exist
if size(BO_TALO_Time1) > 0
hold all;
h = plot(BO_TALO_Time1, BO_Altitude1, '*');
set(h(1), 'Color', 'b', 'MarkerFaceColor', 'b', 'MarkerSize', 15 );
end
% Add the title, legend, and classifications
title(Event_Title, 'Fontsize', 20, 'fontweight', 'b');
% The following is used to create a standard icon in the legend
% regardless of the combination of data sets (Pre-BO, BO, Post-BO)
plt1=plot(-100,-100,'-', 'Color', 'r');
legend(plt1,{Source1}, 'Location', 'NortheastOutside');
set(legend, 'FontSize', 20);
text('String', '\bfCLASS\rm', 'Position', [-0.0485291954 1.0517297 0], 'Fontsize', 20, 'Units', 'normalized', 'Color', [1 0 0], 'EdgeColor', 'black'); % upper left
Max_TALO_X_Values = [max(Pre_TALO_Time1) max(BO_TALO_Time1) max(Post_TALO_Time1)];
Max_TALO_X = max(Max_TALO_X_Values);
set(gca, 'XLim', [0 10*ceil(max(Max_TALO_X)/10)]);
Max_Y_Values = [max(Pre_Altitude1) max(BO_Altitude1) max(Post_Altitude1)];
Max_Y = max(Max_Y_Values);
set(gca, 'YLim', [0 10*ceil(max(Max_Y)/10)]);
ylim('auto');
xlabel('TALO (Sec)', 'fontsize', 20, 'fontweight', 'b');
ylabel('Altitude (Km)', 'fontsize', 20, 'fontweight', 'b');
set(gca, 'Fontsize', 16);
grid on;
box on;
% Add the trajectory flag annotation box
str = {'\bullet L Point', '\ast B Point', '\diamondsuitZ Point'};
annotation('textbox', [0.880 0.450 0.110 0.104], 'Interpreter', 'tex', 'String', str, 'FontSize', 16, 'Color', [1 0 0], 'FitBoxToText', 'on');
The text box should be near the upper left corner of the plot.
Why is MATLAB not placing it here?
Thank you.

採用された回答

Mike Garrity
Mike Garrity 2015 年 5 月 28 日
If you mean the text object with the string 'CLASS', then I think that it's the order of the Position and Units properties on your PV-pair list.
This:
text('String', '\bfCLASS\rm', 'Position', [-0.049 1.052 0], 'Units', 'normalized')
means place the text at [-.049 1.052 0] in the default units (which is data), and then convert the units to normalized.
This:
text('String', '\bfCLASS\rm', 'Units', 'normalized', 'Position', [-0.049 1.052 0])
means set the units to normalized and set the position to [-.049 1.052 0], which is the upper left corner.
I'm not sure why the order would have been reversed in this case, but I have seen a few bugs where the old graphics system processed the args in the wrong order. Perhaps you had hit one of those.
  2 件のコメント
Brad
Brad 2015 年 5 月 29 日
Mike, nice catch! In each of the previous version sof MATLAB, I've never seen this as an issue. I've tested this out on 4 different M-files now and get consistent results. I suspect you are correct. Thanks.
Walter Roberson
Walter Roberson 2015 年 5 月 30 日
It always was defined this way (or at least for quite a number of years), so I have been careful to write it with Units first. But it was something that didn't seem to matter in practice, so it was easy to get into bad habits.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by