I am plotting probability plots, but I want different colors for different data. All data are of different size ?

11 次查看(过去 30 天)
figure;
probplot('lognormal', Loadingtime_4);
hold on;
probplot('lognormal', Loadingtime_5);
hold on;
probplot('lognormal', Loadingtime_6);
xlabel('Loading Duration (secs)');
set(gca, 'XScale', 'log'); % Set the x-axis to use a logarithmic scale
xticks([10 50 100 500 1000 10000]);
xticklabels({'10', '50','100', '500', '1000', '10000'});
grid on;
legend('Lognormal Distribution','Data Drift 4,5 & 6','Location','southeast')
title('Lognormal')

采纳的回答

Walter Roberson
Walter Roberson 2023-10-19
https://www.mathworks.com/help/stats/probplot.html#bu27cw3-1 is an example that shows adding a line to a probplot(), and one of the steps it shows is changing the color
h = probplot(gca,t,p);
h.Color = 'r';
You can use that same technique to give different colors to your different probplot()
  7 个评论
Muhammad Tariq
Muhammad Tariq 2023-10-22
The only problem is that when I do it on my matlab it still gives the same color for all. I don't know what is the problem
%Using Random data
figure;
p1 = probplot('lognormal', randi(1000,1,100));
hold on;
p2 = probplot('lognormal', randi(100,1,100));
hold on;
p3 = probplot('lognormal', randi(500,1,100));
%color the function lines
p1(2).Color = p1(1).Color;
p2(2).Color = p2(1).Color;
p3(2).Color = p3(1).Color;
xlabel('Loading Duration (secs)');
set(gca, 'XScale', 'log'); % Set the x-axis to use a logarithmic scale
xticks([10 50 100 500 1000 10000]);
xticklabels({'10', '50','100', '500', '1000', '10000'});
grid on;
%legend('Lognormal Distribution','Data Drift 4,5 & 6','Location','southeast')
title('Lognormal')
Muhammad Tariq
Muhammad Tariq 2023-10-22
%%
%Using Random data
figure;
p1 = probplot('lognormal', randi(1000,1,100));
hold on;
p2 = probplot('lognormal', randi(100,1,100));
hold on;
p3 = probplot('lognormal', randi(500,1,100));
%color the function lines
p1(1).Color = 'r';
p2(1).Color = 'b';
p3(1).Color = 'g';
p1(2).Color = 'r';
p2(2).Color = 'b';
p3(2).Color = 'g';
xlabel('Loading Duration (secs)');
set(gca, 'XScale', 'log'); % Set the x-axis to use a logarithmic scale
xticks([10 50 100 500 1000 10000]);
xticklabels({'10', '50','100', '500', '1000', '10000'});
grid on;
legend('Lognormal Distribution','Data 1','Lognormal Distribution','Data 2','Lognormal Distribution','Data 3,''Location','best')
title('Lognormal').
%%
I needed to change it to this and now it works

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Axis Labels 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by