Generate a point/marker on a filled contour
3 views (last 30 days)
Show older comments
Hello,
I want to highlight the maximum value of a filled contour, but with the code that I wrote the marker/point won't come up or it shows up outside of the image when I use OpenGL as renderer.
The data for the code is an array A, with the dimension:[361x181] which represents the radiation of the sun at any given angle and orientation. The code should find the indices of the highest value and then plot that point over the filled contour. But I just can't seem to find the flaw in my code as Matlab doesn't give an error message.
Thanks for your answers,
Roland
B=circshift(A, [0, 1]);
set(gcf,'renderer','zbuffer');
[th,r] = meshgrid((1:361)*pi/180,1:181);
[X,Y] = pol2cart(th,r);
h = polar([0 2*pi], [0 180]);
delete(h);
ph=findall(gca,'type','patch');
set(ph,'facecolor','none','edgecolor', 'none','linewidth',1);
hold on;
contourf(X,Y,B,200),shading flat;
[r,c]=find(B==max(max(A)));
plot(r,c,'.w', 'markersize', 30);
view([90 -270]);
0 Comments
Accepted Answer
Image Analyst
on 27 Mar 2012
Roland, you didn't quite do your r,c code right. Try this:
s = load('C:\Users\Me\Documents\Temporary\Euit-1965 januari.mat')
A = s.A;
B=circshift(A, [0, 1]);
[rows columns] = size(B)
set(gcf,'renderer','zbuffer');
[th,r] = meshgrid((1:361)*pi/180,1:181);
[X,Y] = pol2cart(th,r);
h = polar([0 2*pi], [0 180]);
delete(h);
ph=findall(gca,'type','patch');
set(ph,'facecolor','none','edgecolor', 'none','linewidth',1);
hold on;
contourf(X,Y,B,200);
shading flat;
[maxValue linearIndexAtMax] = max(B(:))
[thetaAtMax, rhoAtMax] = ind2sub([rows columns], linearIndexAtMax)
hold on;
plot(thetaAtMax, rhoAtMax-360, 'w+', 'MarkerSize', 30, 'LineWidth', 3);
colorbar;
view([90 -270]);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
More Answers (2)
Walter Roberson
on 26 Mar 2012
Plot the point slightly above (Z axis) where you want to show up, using plot3().
When you mix lines and surfaces at the same Z depth, then OpenGL has its own ideas about which should show up on top, and some of the graphics drivers get the order exactly reversed. Easiest way to be sure: tweak the Z depths to get the order you want.
See Also
Categories
Find more on Contour 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!