I am trying to plot some data using bar chart and it works fine, but the problem is that the difference is not recognizable from the graph as shown below, so I need to change the y axis scale to be exponential so the difference between the data can appear .. any help??
This is my code:
x = [0.1 1 10 100 1000 10000];
y = [2.66 24.58 81.72 87.90 87.99 88.00];
xplot = 1:numel(x);
figure;
bar(xplot,y);
set(gca,'XTick', xplot);
set(gca,'XTickLabel', x);
ylim([0 100]);
If you want the y
-axis to look more uniform, consider changing the scale to a semi-logarithmic plot, or transforming your y
data through a log
transformation:
y
-axis to log
scale:Simply obtain the current axes and set the YScale
to log
:
x = [0.1 1 10 100 1000 10000];
y = [2.66 24.58 81.72 87.90 87.99 88.00];
xplot = 1:numel(x);
figure;
bar(xplot,y);
set(gca,'XTick', xplot);
set(gca,'XTickLabel', x);
set(gca,'YScale','log'); %// NEW
%ylim([0 100]); %// Remove as we don't need it
This is what I get for the graph:
Be mindful that the y
-axis doesn't change its data - only the way you present it. The ticks are placed in a semi-logarithmic basis where from the bottom, we go from 1, 2, 3, up to 10 (10^1
), next we go 20, 30, 40, up to 100 (10^2
), then we go 200, 300, 400, up to 1000 (10^3
) and so forth. You can certainly see a pattern in the ticks, as we are increasing on a semi-logarithmic basis.
y
-data to log
:Just take your y
data and run it through log
:
x = [0.1 1 10 100 1000 10000];
y = [2.66 24.58 81.72 87.90 87.99 88.00];
xplot = 1:numel(x);
figure;
bar(xplot,log(y)); %// NEW
set(gca,'XTick', xplot);
set(gca,'XTickLabel', x);
%ylim([0 100]); %// Remove as we don't need it
This is what we get:
Be mindful that the y
-axis has changed its units. You can leave a disclaimer saying that your data was log
transformed.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments