dsbisht
dsbisht

Reputation: 1035

How to change the 'marker' position in MATLAB plots?

I am plotting a boxplot with mean as a marker point.

Here I have fixed the position of each boxlot as I have to insert another series of boxplot next to the first one.

I can play with the position of boxplots, but I am not getting how to fix the marker points at the desired location (within the boxplots).

enter image description here

Here is what I am trying,

pos = 1.3:1:8.3;  

boxplot(data(2:71,[32,31,30,50,62,85,86,34]),...
    'colors','b','positions',pos,'width',0.18,...
    'symbol', 'bd', 'OutlierSize',4);
hold on  

plot(mean(RF(2:71,[32,31,30,50,62,85,86,34])),'-md','linestyle', 'none')

Markers should be placed at pos = 1.3:1:8.3 same as boxplots.

How to do this?

Upvotes: 0

Views: 505

Answers (1)

Suever
Suever

Reputation: 65430

If you want to place your markers at specific x locations you will need to explicitly put them there because by default, MATLAB will use 1:numel(y) as the default x locations if only the y values are provided.

pos = 1.3:1:8.3;
plot(pos, mean(RF(2:71,[32,31,30,50,62,85,86,34])),'-md','linestyle', 'none')

Upvotes: 1

Related Questions