make a data plot
2 views (last 30 days)
Show older comments
Ioannis Vourvachakis
on 16 Dec 2021
Commented: Ioannis Vourvachakis
on 16 Dec 2021
Hello! I want to make a plot like this, but I don't know exactly how.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/836095/image.png)
More specifically,I want to plot the possible values of flux variability for some reactions.
Could someone guide me? Thank you.
3 Comments
Accepted Answer
John D'Errico
on 16 Dec 2021
Edited: John D'Errico
on 16 Dec 2021
Easier than you think.
First, write a little function that will plot a bar of fixed height, between two points on the x axis. It might look like the function called xbar below.
Next, call that function repeatedly, once for each horizontal bar.
Finally, change the y axis to have a different set of tick labels. It looks like you will need to set the YTickLabel property on the axes. For example:
plot(rand(1,5))
H = get(gca);
H.YTickLabel
Now you can reset those tick mark lables as desired. And they need not be numbers.
function xbar(y,xlo,xhi,barcolor)
% On the current figure, creates a horizontal bar
% of unit height, between y and y+1, and between xlo and xhi
% this can be as simple as one call to fill.
barpolyx = [xlo,xhi,xhi,xlo];
barpolyy = [y,y,y+1,y+1];
fill(barpolyx,barpolyy,barcolor)
end
Should be pretty simple. Spend some time learning to use the basic tools.
4 Comments
John D'Errico
on 16 Dec 2021
Wait. You were the one who implied you knew that.
I have no idea what it means to have ALL of the values shown. But surely you might be able to choose two percentiles of your data. Perhaps the 5 and 95% points from the data, thus excluding a few outliers. Or the 1% and 99% points. Or just the max and the min. Your choice.
help prctile
help min
help max
More Answers (1)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!