Plotting the same distribution function in two different ways return two different graphs
2 views (last 30 days)
Show older comments
Hello,
I use the following code to plot a CDF (FvR)
% Plot the estimated and actual distribution functions.
figure;
set(gcf,'DefaultLineLineWidth',1.25)
vR = sort(vR);
FvR = sort(FvR);
plot([vR(1);vR],[0 FvR],':');
hold on
set(gca,'LineWidth',1.25)
legend('Single-Index-Estimated CDF',4)
axis ([0.5 max(vR) 0 1])
and I get the following graph
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/147967/image.png)
while when I use
plot(FvR)
I get:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/147968/image.png)
The two graphs are very different. I believe that the only real difference in the code is that in the first one I declared both axis, so I don't understand why I have two distributions that look so different.
Thank you!
0 Comments
Accepted Answer
Jon
on 12 Aug 2015
In your first plot, you are plotting using the following code:
plot([vR(1);vR],[0 FvR],':');
In your second plot, you are (effectively) plotting using the following code:
plot(1:length(FvR),FvR)
The x-axes are different, hence the different plots.
0 Comments
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!