Why doesn't the patch command fill homogeneously the region between two arrays?
Show older comments
I've done a fitting with lscov, calculated the confidence intervals and tried to plot the resulting line and use the patch command to paint the region limiting the confidence intervals of the fitting. Translating, I have three arrays, one is the fitting, and I want to color the region between the other two, like shown in the image (A). What I obtain is the image (B), not only in the figure environment, but also in the generated pdf.
The image looks better if I define a thinner axis with around 6000 points, but then the pdf takes ages to be generated (it weights >100MB) and sometimes the figure environment doesn't even load.
What could be happening here?

Example code used to generate (B):
x = 1:100:6000 ;
A = [1000 1500 3000 5000].' ;
B = [5 7 12 17].' ;
C = [2 3 2 1].' ;
[f,s] = lscov(A,B,1./C.^2) ;
figure,errorbar(A,B,C), hold on,
plot(x,x*f,'-r','LineWidth',1), hold on,
patch([x; flipud(x)], [x*(f-s); flipud(x*(f+s))],[1.0 0.0 0.0], ...
'EdgeColor',[1.0 0.0 0.0],'facealpha',0.3,'edgealpha',0.05), hold on,
xlim([0 6000]),
ylim([0 20]),
2 Comments
Rik
on 1 Jul 2022
The image your code produces does not look like the B image you posted. It is not clear to me how you would get that with this code.
Federico Geser
on 1 Jul 2022
Accepted Answer
More Answers (0)
Categories
Find more on Polygons 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!
