Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I let my stack overflow?

I want to make a bar chart in Matlab, where one of the categories is "breaking through the roof" of the axes, over the y-axis limit, but I can't figure how to do this. When I change the upper limit to a lower value, the bar gets trucked.

What can I do?

Here is my data:

data =
   115   116    97    99   107   NaN   NaN   NaN
   111   118   101   114   102   108   111   119

I want the upper y-axis limit to be 600.

Here is what I tried:

bar(data,0.5,'stack')
ylim([0 600])

Here is a demonstration of the result:

stack not overflow

like image 726
EBH Avatar asked Mar 01 '17 23:03

EBH


People also ask

Can I accept my own answer Stack Overflow?

You must wait 2 days from the time you originally asked your question before you can accept your own answer. This gives other users a chance to answer the question in good faith, and earn the accepted answer.

How can I share my Stack Overflow profile?

The shortest option you have is https://stackoverflow.com/u/YOUR_USER_ID .

How do I post on Stack Overflow?

To post a job to StackOverflow you'll need to sign up for an account with careers.stackoverflow.com. Select 'log in' in the top right corner of the homepage, and then 'create a new account' from the page that follows. Just enter your email address and a password to complete your sign up.


1 Answers

One simple option is to set the clipping property of the axes to off.

bar(data,'stack')
colormap('lines') % make it colorfull :)
bax = gca; % get axis handle
bax.Clipping = 'off';
bax.YLim(2) = 600; % set the upper limit

For a better result, you might want to also shrink the axes a little, so the bar will stay within the figure. Also, it's nicer without boxing the axes:

top = bax.YLim(2); % before you change the limit
bax.YLim(2) = 600; % set the upper limit
bax.Position(4) = bax.Position(4)*(bax.YLim(2)/top);
box off

the result:

stack overflow

like image 192
EBH Avatar answered Sep 28 '22 08:09

EBH