contourf plot over circular domain
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello,
I am using the following code in Matlab R2007b to produce a contourf plot of a function that is defined on the unit disk.
[th,rad] = meshgrid((0:5:360)*pi/180,0:0.01:1);
[X,Y] = pol2cart(th,rad);
Z = (1-X)./(X.^2+Y.^2-X+1);
F = sqrt((1-Z+Z.*X).^2+(Z.*Y).^2);
v = linspace(0,1,21); v = v(1:end-1);
v = [v 0.97 0.99 1];
contourf(X,Y,F,v)
axis square
colormap(gray)
colorbar
Everything works fine except for an unwanted black horizontal line (x,0) for 0 <= x <= 1 that appears on the figure. I assume this has something to do with how I am defining my domain. Any tips on how to remove this line would be greatly appreciated. Thanks.
0 comentarios
Respuestas (2)
the cyclist
el 12 de En. de 2012
Here are a couple ways:
1. You could turn off the the display of those lines (i.e the contours themselves), and then plot a circle around the perimeter to help differentiate the lighter areas from the background:
set(get(gca,'Children'),'LineStyle','none')
hc=circle(0,0,1,72);
set(hc,'Color','k')
Here I used the following simple function to draw the circle (I think I got it from the FEX ages ago):
function h = circle(x,y,r,nsegments)
if nargin<4
nsegments=50;
end
hold on
th = 0:2*pi/nsegments:2*pi;
xunit = r * cos(th) + x;
yunit = r * sin(th) + y;
h = plot(xunit, yunit);
hold off
end
2. You could just deemphasize the lines by making them the dotted style:
set(get(gca,'Children'),'LineStyle',':')
0 comentarios
tomas
el 18 de Jul. de 2014
Hello,
I'm dealing with the same problem - unwanted horizontal line. Proposed procedure has effect on all lines but unfortunately the rest of isolines are desired. Have you solved this problem or is there anybody who can help?
Thanks in advance!
1 comentario
Killian Miller
el 19 de Jul. de 2014
Editada: Killian Miller
el 19 de Jul. de 2014
Ver también
Categorías
Más información sobre Data Distribution 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!