
How can I shade an area of my graph between two vertical lines?
5 views (last 30 days)
Show older comments
Hello, I am trying to shade an area under the curve of a lognormal pdf between two vertical lines. Here is the code to help you generate the problem:
pd = makedist('Lognormal','mu',3.323167914007358,'sigma',0.241878609884653)
r = random(pd,1000,1); % generate 1000 numbers from the distribution
ix = linspace(min(r),max(r)); % to scale the graph
y = pdf(pd, ix);
figure
plot(ix,y)
hold on;
line([20, 20], ylim, 'LineWidth', 2, 'Color', 'r');
hold on;
line([24, 24], ylim, 'LineWidth', 2, 'Color', 'r');
This is the picture of the plot above:

I tried searching, but the best answer I have come up with fills the area between the lines all the way to the top of the graph, while I want it to end at the curve. Also, I want the lines to stop at the curve, not stretch beyond it. Here is a google picture of what I am trying to achieve:

0 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on 2-D and 3-D 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!