How to remove the horizontal line at 0

Hi All,
  1. How do I get rid of the horizontal line at the zero (0) mark on the y-axis in a line plot? Please see attached image below as an example. I want the horizontal line hidden.
2. How do I superimpose a barchart on a line plot?
Thank you all.

3 Comments

How do I get rid of the horizontal line at the zero (0) mark on the y-axis in a line plot?
You would have to show us the code that put it there.
Hi, thanks for the comments. I have something like this:
Plot(x,y)
y=0 is not even part of the code but for some reason it shows up in the plot.
Please save x and y to a mat file and attach the file here for us to test.
You can get that kind of output if your x values are not in strict monotonic order.

Sign in to comment.

 Accepted Answer

x=1:10;
y=randi(20,1,10)-10;
b=bar(x,y);
ax=gca;%to access axes properties
hold on
plot(x,y,'r*--')
b.ShowBaseLine='off'

1 Comment

Thank you! I had the same issue and had not found the attibute (BaseLine)!

Sign in to comment.

More Answers (0)

Products

Release

R2019b

Asked:

on 4 Feb 2021

Commented:

on 27 Aug 2024

Community Treasure Hunt

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

Start Hunting!