pcolor and contour in the same map

38 Ansichten (letzte 30 Tage)
Miguel andres
Miguel andres am 9 Mai 2020
Beantwortet: Georgy Shapiro am 1 Nov. 2022
Hey all,
My problem is that I want to overlay to a pcolor of velocities in a curvilinear grid, the contour of another array that contains the batimetry ( I just one the line of 0 meters)
When I try just to hold on one figure and plot the otherone, the colorbar change and the contour line doesn't appear.
Thak you in advice,
Miguel.
  2 Kommentare
Tommy
Tommy am 9 Mai 2020
Can you provide what you've tried so far?
Miguel andres
Miguel andres am 9 Mai 2020
Yeah, here it is. Where peak_mod_atl and bat_final are 40x144. I want to plot the contour of the coast and some depths.
peak_vel_atl=pcolor(lon,lat,peak_mod_atl);colormap jet; colorbar
peak_vel_atl,EdgeAlpha=0
shading interp
hold on
contour_bat=contour(bat_final,[0,0],'k')

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Ameer Hamza
Ameer Hamza am 9 Mai 2020
Bearbeitet: Ameer Hamza am 9 Mai 2020
This shows an example of overlaying contour and pcolor. You need to use the FaceAlpha property to make the surface make by pcolor transparent
x = linspace(-1,1);
y = linspace(-1,1);
[X, Y] = meshgrid(x, y);
Z = X.^2 + Y.^2;
pcolorData = sin(X) + cos(Y);
figure;
ax = axes();
hold(ax);
c = contour(X, Y, Z);
p = pcolor(X, Y, pcolorData);
p.FaceAlpha = 0.2;
colorbar;
  2 Kommentare
Miguel andres
Miguel andres am 9 Mai 2020
Thak you really much. But my problem is that the datas for the contour and the pcolor are different.
Ameer Hamza
Ameer Hamza am 9 Mai 2020
I also used different data for both. Are you getting unexpected output?

Melden Sie sich an, um zu kommentieren.


Georgy Shapiro
Georgy Shapiro am 1 Nov. 2022
A simple way to overlay a contour plot over pcolor can be seen from this example
p=pcolor(peaks(250));shading flat; colorbar; caxis ([-8 8 ])
hold on
contour(peaks(150),'k','LineWidth',0.5,'Show','on');
Here the data used in pcolor and contour are different and unrelated. If you wish to highlight your pcolor plot with the same data used for contours you can do it like this
p=pcolor(peaks(250));shading flat; colorbar; caxis ([-8 8 ])
hold on
contour(peaks(250),'k','LineWidth',0.5);

Kategorien

Mehr zu Contour Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by