Dibbs
Dibbs

Reputation: 149

MATLAB Bar Graph: How to combine bar graphs?

Sorry for this simple question, but I am having trouble figuring out how to combine bar graphs on MATLAB. Right now, I have the following two bar graphs which I am trying to combine:

First

first

Second

enter image description here

All I want to do is combine the two graphs such that all the information stays the same and the only difference is that all the sigmas and gammas are on the same x-axis. Can someone please help me or show me a reference where I could find the answer to this question?

Thank you

Upvotes: 1

Views: 3800

Answers (1)

Wasi Ahmad
Wasi Ahmad

Reputation: 37691

Check out the examples on Bar graph in Matlab. You can either use group of bars or stacked bars but i guess what you need is group of bars. I am one example here.

Example: Use bar(...) to get the type of results you want. Consider the following code with results shown below:

% Make some play data:
x = randn(100,3);
[y, b] = hist(x);

% You can plot on your own bar chart:
figure(82);
bar(b,y,'grouped');
title('Grouped bar chart');

% Consider stack for the other type:
figure(83);
bar(b,y,'stacked');
title('Stacked bar chart');

enter image description here

enter image description here

You can also use hist(...):

% Bust histogram will work here:
figure(44);
hist(x);
title('Histogram Automatically Grouping');

enter image description here

Update

You can plot a single bar graph by combining the data of both the bar plots you have. You can set the x-axis values as you want. See this example. To set axis values in Bar graph, you can see this video tutorial.

Upvotes: 3

Related Questions