manually specify occourrences in bar graph

Hi everyone, i have analyzed some data and now i want to make an histogram,but i can't understand how i can do it.Let me explain, i have 4 values and for each value 2 characteristics: entropy and bandwidth: 1) first value, entropy=1.8 and bandwidth = 18 2) second value, entropy = 0.9 and bandiwidth = 26 ecc...
my aim is to have in x axes my values and y axes the characteristics' value(with different colors)
(if there are others ways to do this,it's ok)
thank you!(and forgive my english)

3 Comments

A histogram with only 4 values? Are you kidding me? Perhaps you mean some other kind of graph/plot/visualization instead of a histogram (which is an array of the frequency of occurrence, like a probability density function).
Federico
Federico on 18 Jan 2013
Edited: Federico on 18 Jan 2013
yes i need histogram's style(every x has two y that i want to representate with rectangular or somithing similar),i don't know what to use...any suggest?
Oh, you mean just a bar chart, not a histogram. Even though histograms are often plotted using a bar chart, all bar charts don't depict histograms.

Sign in to comment.

Answers (2)

values = [1 2 3 4];
entropy = [1.8 1.9 2.1 2.2];
bandwidth = [18 2 10 11];
hold on
plot(values, entropy, 'r')
plot(values, bandwidth, 'b')
hold off

1 Comment

thank you but this draws function like y = mx + q, i need at least function like x=k with a good thickness

Sign in to comment.

Thorsten
Thorsten on 21 Jan 2013
Edited: Thorsten on 22 Jan 2013
Sample values
values = [1:4];
entropy = [1.8 1.9 2.1 2.2];
bandwidth = [18 2 10 11];
Plot the bars
h = bar(values, [entropy; bandwidth]');
Color them red and blue:
set(h(1), 'FaceColor', 'r')
set(h(2), 'FaceColor', 'b')
BTW: Please edit your question and remove the histogram stuff such that others can understand my answer...

2 Comments

i suppose that values should be,e.g. values = [1 2 3 4] right? i've made a try and bar gives me this error: "??? Error using ==> bar at 54 XData cannot contain duplicate values."
True. I corrected the code above.

Sign in to comment.

Categories

Tags

Asked:

on 18 Jan 2013

Community Treasure Hunt

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

Start Hunting!