Plot a a matrix by columns but with a different marker for the data at its end

2 views (last 30 days)
I am trying to plot a set of data by introducing the following command
plot11=errorbar(matsizered',matsigmasred',materrred','d','MarkerSize',5)
set(gca,'XScale','log');
xlabel('L/l_e')
ylabel('\sigma_{extinction}')
set(plot11, {'MarkerFaceColor'}, get(plot11,'Color'))
Where matsizered,matsigmasred,materrred are 5x6 matrixes. By doing so, I get the following figure
The question is, can I have the 5 points are the right with an X marker while the other points are still represented by a diamond marker? Thank you very much

Accepted Answer

Dana
Dana on 4 Sep 2020
Edited: Dana on 4 Sep 2020
figure
hold on % we need this so that successive plotting commands don't overwrite the previous ones
% only plot error bars for the first 5 columns of your matrices
plot11=errorbar(matsizered(:,1:5)',matsigmasred(:,1:5)',materrred(:,1:5)','d','MarkerSize',5)
hax = gca; % current axis handle
hax.ColorOrderIndex=1; % re-set color order for current axis
% plot the remaining error bars individually in order to get the right colors
for j = 1:5
errorbar(matsizered(j,6),matsigmasred(j,6),materrred(j,6),'x','MarkerSize',5)
end
set(plot11, {'MarkerFaceColor'}, get(plot11,'Color'))
set(gca,'XScale','log');
xlabel('L/l_e')
ylabel('\sigma_{extinction}')

More Answers (0)

Categories

Find more on Line Plots in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!