user2230101
user2230101

Reputation: 495

Plot bar chart with specific range of x axis in MATLAB

I would like to plot a bar chart like below in MATLAB. Any one know which function should I use? Many thanks in advance!

  1. The bar is specified with range in x (some may be wider than others).
  2. There is no line between two bars (red cross in the figure).
  3. X axis is in log scale.

bar

Upvotes: 0

Views: 315

Answers (1)

Max
Max

Reputation: 335

why don't you try to do it with the plot or semilogx function?

x = [0.1 0.18 0.18 0.32 0.32 0.56 0.56 1.0];
y = [30 30 25 25 110 110 80 80];
semilogx(x,y);

matlab figure

and if you want the x ticks like in your figure you can set them on the axis object:

ax = gca;
ax.XTick = unique(x);
ax.XTickLabel = unique(x);

matlab fig with xticks

Upvotes: 2

Related Questions