Sibbs Gambling
Sibbs Gambling

Reputation: 20415

How to plot two stem plots and two box plots in one figure in MATLAB?

I have two vectors

A=[0.1 0.1 0.2 0.2 0.3 0.3 0.3 0.3 0.4 0.5 0.5]
B=[0.7 0.7 0.8 0.8 0.9 0.9 0.9 0.9 1 1 1]

How to plot their stem plots and box plots at the same time?

The y-axis should be the probability of the stem plots.

What I am looking for is something like this.

enter image description here

Upvotes: 1

Views: 2223

Answers (1)

Isaac
Isaac

Reputation: 3616

Drawing the box-plots can be accomplished with

boxplot([A B], [ones(size(A)) 2*ones(size(B))], ...
    'orientation', 'horizontal', 'positions', [1 1]);

After which you can add the stem plots with

hold on
stem(xa, ya);
stem(xb, yb);

where I'm not sure exactly what you are asking for for x and y.

Upvotes: 1

Related Questions