Plotting confidence interval with bar plot
Show older comments
Hi all,
I have the following graph, and I want to plot the mean and standard deviation (in grey) such that the these lines fit exactly to my x-axis bars. I would really like the grey shaded region to be a straight horizontal line in the region behind hte bars themselves, and only "slope" in the spaces between. Is there a way that I can do this?
4 Comments
Gaurav Garg
on 9 Jun 2020
Hey Amy!!
it's very unclear by 'these lines fit exactly to my x-axis bars' because the plot of mean doesn't need to be a line and would plot the means on each point.
Could you elaborate a little more on your question, and also give an example (if possible) for better understanding?
Amy Hassett
on 9 Jun 2020
Gaurav Garg
on 9 Jun 2020
How are you plotting the black line and grey shaded area?
Amy Hassett
on 10 Jun 2020
Accepted Answer
More Answers (1)
Gaurav Garg
on 12 Jun 2020
0 votes
Hey Amy,
The grey shaded region seem to have varying y-values for the respective x-values.
What is evident from your code is that norm_WT_std2_SH_allInfo is an array of dimensions m*3, and borders of the shaded region are plotted using the second and third columns of the array. So, I would suggest you to look into the values in this array and change them (if needed) to make your grey shaded region to be a straight horizontal region.
The needed changes can be understood as -
You can plot any line parallel to x-axis if the y-value at each x-point for the line is 0.
Categories
Find more on Line Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!