How to mark the shadded area in the scatter plot
11 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi,
I want to show a scatter plot with some shadded region in a lighter shade. I tried with 'fill' and 'patch' command but unfortunately its not working.
I want two shaded regions, 1. between maximum and average, and 2. between minimum and average.
I attach the code and the figure.
Thanks
t = Max100(:,1);
z = Max100(:,2);
plot(t,z,'d','Markersize',8,'MarkerFaceColor',[0 0.4470 0.7410],'MarkerEdgeColor',[0 0.4470 0.7410])
hold on
g = av100(:,1);
h = av100(:,2);
plot(g,h,'d','Markersize',8,'MarkerFaceColor',[0.9290 0.6940 0.1250],'MarkerEdgeColor',[0.9290 0.6940 0.1250])
hold on
c = min100(:,1);
d = min100(:,2);
plot(c,d,'d','Markersize',8,'MarkerFaceColor',[0.8500 0.3250 0.0980],'MarkerEdgeColor',[0.8500 0.3250 0.0980])
legend ('Maximum','Average', 'Minimum','FontSize',14, FontName='Arial')
0 Commenti
Risposte (2)
Sandeep Mishra
il 14 Giu 2023
Hello Tayyaba,
I understood that you are plotting three plots "Maximum", "Average" and "Minimum" and want to shade the regions between Maximum - Average and Average - Minimum plots.
In MATLAB, the "fill" function provides you the functionality to plot filled polygonal regions as patches with vertices at the (x,y) locations specified by X and Y.
You can implement the fill function like the below example.
% Maximum plot
t = [1 2 3 4 5 6 7 8];
z = nthroot(t, 2.8);
maxPlot = plot(t,z,'d','Markersize',8,'MarkerFaceColor',[0 0.4470 0.7410],'MarkerEdgeColor',[0 0.4470 0.7410]);
% Average plot
hold on
g = [1 2 3 4 5 6 7 8];
h = nthroot(g, 3);
avgPlot = plot(g,h,'d','Markersize',8,'MarkerFaceColor',[0.9290 0.6940 0.1250],'MarkerEdgeColor',[0.9290 0.6940 0.1250]);
% Filling the region between Maximum and Average plot with blue color
fill([g fliplr(t)], [z fliplr(h)], 'b');
% Minimum plot
c = [1 2 3 4 5 6 7 8];
d = nthroot(c, 3.2);
minPlot = plot(c,d,'d','Markersize',8,'MarkerFaceColor',[0.8500 0.3250 0.0980],'MarkerEdgeColor',[0.8500 0.3250 0.0980]);
% Filling the region between Average and Minimum plot with green color
fill([g fliplr(c)], [h fliplr(d)], 'g')
% Adding plots, labels, and text parameters to legend
legend ([maxPlot, avgPlot, minPlot],'Maximum','Average', 'Minimum','FontSize',14, FontName='Arial')
hold off
You can refer to the below documentation to learn more about "fill" in MATLAB
0 Commenti
Vedere anche
Categorie
Scopri di più su Polygons in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!