Highlighten specific x-axis values
古いコメントを表示
Hey guys !
I need some help to plot a small figure for my thesis. I think the question is quite simple but however I have not found a solution yet...
What I want to do is to plot my figure with its x-axis that ranges from 0 to 5 in steps of 0.5. Now I want to add 2 specific values (say 1.1 and 3.387) to the x-axis and label them as f_1 and f_2. I tried using xtick but it did not work. Here's my code:
% Values
x_max = 0.22;
v_max = 1.6;
a_max = 35;
f_1 = v_max/(x_max*2*pi);
f_2 = a_max/(v_max*2*pi);
a_1 = x_max * (2*pi*f_1)^2;
a_2 = a_max;
% Curves
f_c1 = [0 f_1];
y_c1 = [0 a_1];
f_c2 = [f_1 f_2];
y_c2 = [a_1 a_2];
f_c3 = [f_2 5];
y_c3 = [a_max a_max];
% Plot
figure
hold on
grid on
box on
xlabel('Frequency [Hz]')
ylabel('Acceleration [m/s^2]')
title('Dynamic Operating Space')
set(gca,'xtick', [f_1 f_2], 'xticklabel', {'f_1'; 'f_2'})
% Characteristic Frequencies
plot([f_1 f_1], [0 40], '--', 'color', 'red')
plot([f_2 f_2], [0 40], '--', 'color', 'red')
% Dynamic Curves
plot(f_c1, y_c1, 'LineWidth', 2, 'color', 'black')
plot(f_c2, y_c2, 'LineWidth', 2, 'color', 'black')
plot(f_c3, y_c3, 'LineWidth', 2, 'color', 'black')
an_1 = text(0.3, 5.5,'x_{max} = 0.22m');
set(an_1,'Rotation',45)
%set(an_1,'FontSize',12)
% ar_1 = area(f_c1, y_c1);
% set(ar_1, 'FaceColor', [1 0.5 0]);
an_2 = text(2, 22.5,'v_{max} = 1.6m/s');
set(an_2,'Rotation',45)
an_3 = text(4, 36.5,'a_{max} = 35m/s^2');
This is what I got:

If the x-axis would now display the full range in addition to above f_1 and f_2 I'd be very happy.
Any clue ?
Additionally, is there any way to grey out the area under the curves ?
Thank you !
3 件のコメント
darova
2019 年 12 月 30 日
If you want to see numbers just don't force MATLAB to display symbols
set(gca,'xtick', [f_1 f_2])%, 'xticklabel', {'f_1'; 'f_2'})
To paint some area use patch
Aladin Djuhera
2019 年 12 月 30 日
darova
2019 年 12 月 30 日
This is what your code produces on my PC

採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Graphics Performance についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!