log scale not displayed correctly in horizontal bar graph

6 views (last 30 days)
Hello,
I have a horizontal bar graph with the code snippet like this:
tiledlayout(3,1,'TileSpacing','loose','Padding','loose')
y=[3254 3276-3254 4405263-3276 4500000-4405263];
def=[1];
nexttile
d1=barh(def,y,3,'stacked');
d1(1).FaceColor = colors(9,:);
d1(2).FaceColor = colors(8,:);
d1(3).FaceColor = colors(11,:);
d1(4).FaceColor = colors(1,:);
axis ([0 4500000 0 2]);
set(gca,'ytick',[],'FontSize',30);
I want to make this bar chart logarithmic. But when I add this to the last line:
set(gca,'XScale','log')
The bar become out of bounds (the whole graph is not displayed in the screen width). like this:
It would be helpful if someone could guide what could be done.
Thanks
Aksh

Accepted Answer

Voss
Voss on 9 Oct 2023

Use

axis ([1 4500000 0 2]);

or put whatever lower x-limit you want to use instead of 1. Zero cannot be rendered on log scale.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!