Borrar filtros
Borrar filtros

How to Add Border to Single Color Region in pcolor Plot

12 visualizaciones (últimos 30 días)
Zakir Hussain Shaik
Zakir Hussain Shaik el 4 de Mzo. de 2024
Respondida: Voss el 4 de Mzo. de 2024
I'm currently working with a pcolor plot in MATLAB, where the top-right side area is represented by a single color. I'm seeking assistance on how to draw a border around this particular region.
Attached are three figures:
Figure 1: The original pcolor plot.
I want the border coordinates for all '0' values extracted from my matrix, represented as coordinates in xc and yc variables. This will allow me to plot the border over the existing pcolor plot. The desired border appearance is illustrated below:
Figure 2: The plot needed.
The data matrix of the variabel I am plotting looks of the form:
Figure 3: Screenshot data matrix
I have also attached data file for reference.
The code to display the plot:
[X,Y] = meshgrid(1:100,1:10); figure
h = pcolor(X',Y',medianVarianceAll2);
colormap(jet)
colorbar
%% If I obtain xc and yc variables, I should be able to execute:
[X,Y] = meshgrid(1:100,1:10); figure
h = pcolor(X',Y',medianVarianceAll2);
colormap(jet)
colorbar
hold on
plot(xc,yc,'linewidth',2,'r');
I'm looking for guidance on how to identify and outline the single color region in the plot. Any suggestions or code snippets would be greatly appreciated. Thank you in advance for your help!

Respuesta aceptada

Voss
Voss el 4 de Mzo. de 2024
load TestData
[m,n] = size(medianVarianceAll2);
[X,Y] = meshgrid(1:m,1:n);
figure
h = pcolor(X',Y',medianVarianceAll2);
colormap(jet)
colorbar
is_zero = medianVarianceAll2.' == 0;
Xz = X(is_zero);
Yz = Y(is_zero);
idx = boundary([Xz,Yz]);
[xc,yc] = stairs(Xz(idx),Yz(idx));
hold on
plot(xc,yc,'r','linewidth',2);

Más respuestas (0)

Categorías

Más información sobre Scatter Plots en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by