Make the Y-axis scale exponentially in bar chart matlab

SMH

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?? bar chart

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]);
rayryeng

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:

Option #1 - Change 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:

enter image description here

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.

Option #2 - Transform your 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:

enter image description here

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.

edited at
0

Comments

0 comments
Login to comment

Related

Android : Bar chart changing y axis scale with achartengine

Is it possible to make a table with y axis labels of Highcharts bar chart?

How can I scale Y axis when changing dataset in this NVD3 multi bar chart?

How to make a bar chart on range of values on x-axis and count on the range on y-axis in python?

How to make a bar-chart by using two variables on x-axis and a grouped variable on y-axis?

Matlab - Bar chart with two plots and two axis

Make dotplot scale y axis as for histogram

Zingchart bar chart starting at y axis -50

Y axis in single stacked bar chart

weird y-axis dodged bar chart

Horizontal bar chart y axis alignment

Indicating a range for the Y axis in a bar chart

How can I make a bar chart starting from the 0 point of the y axis and not from the bottom of the svg?

Make Y-axis start at 1 instead of 0 within ggplot bar chart

Stacked bar chart swap x-axis and y-axis

make bar plot with multiple y axis

Altair Layer Chart Y Axis Not Resolving to Same Scale

chart.js not allowing y axis steps with logarithmic scale

VBA Chart set a manuel Y-Axis Scale

Python Plotly Line Chart with a Dataframe: Wrong scale on the y-axis

Plot bar chart with specific range of x axis in MATLAB

How to change y-axis in 'plotyy' to natural log scale in matlab

Waffle Bar Chart with scale

Likert Scale Bar chart

How to make custom y-axis scale in base R

R: ggplot stacked bar chart with counts on y axis but percentage as label

Python - Floating Bar Chart with y axis set at 0

d3 multiple y axis for multiple bar chart

Get unique max value for each y-axis in a bar chart