How to define where x axis intercepts y axis

  • Thread starter Thread starter jemma
  • Start date Start date
  • Tags Tags
    Axis
AI Thread Summary
To create a bar plot in MATLAB where the x-axis intercepts the y-axis at 0.5, users can utilize the 'ylim' function to set the limits of the y-axis. The initial code provided sets the y-axis limits from 0 to 1. To achieve the desired effect of having bars above and below the x-axis based on their values relative to 0.5, overlaying a horizontal line at y = 0.5 is suggested. This can visually separate the bars, allowing those greater than 0.5 to appear above the x-axis and those less than 0.5 to appear below. The provided link to MATLAB documentation offers further guidance on creating and customizing plots.
jemma
Messages
35
Reaction score
0
I want to plot a bar plot using matlab.
For example:

x = [0.4 0.5 0.7 0.2 0.1 0.8]
bar(x)
ylim([0 1])

now I want the x-axis to intercept the y-axis at 0.5 so that any bars >0.5 lie above the x-axis and any bars <0.5 are below.

Is this possible?
Thanks.
 
Physics news on Phys.org
I'd look into overlaying a horizontal line on top of your bar graph:
http://www.mathworks.com/help/techdoc/creating_plots/f10-19972.html#f10-22444
 
Last edited by a moderator:

Similar threads

Replies
4
Views
2K
Replies
1
Views
2K
Replies
4
Views
2K
Replies
2
Views
3K
Replies
8
Views
2K
Replies
10
Views
3K
Replies
5
Views
2K
Replies
2
Views
2K
Replies
4
Views
5K
Back
Top