How can I equally space a contour level
Afficher commentaires plus anciens
Please can someone help with equally spacing a contour. I tried different approach but couldn't work. I have attached the data and the figure I got. I want the contour level above and below the second red line to be equally space. This is what I tried.
xi = linspace(-0.3, 0.3, 201);
u = linspace(0, 3, 201);
contourf(u, xi, Dv1(:, :)/100000, [min(min(Dv1))/100000:0.0002:-0.00006 0.0001:0.004:0.04, 0.001, 0.0016, 0.00055, 0.00069, 0.0002 0.0015:0.0004:0.0042 0.0043:0.0005:0.02 0.013 0.05:0.05:0.5 0.074 0.87 0.68 0.063 0.073, 1.35 1.75, 2.56 1.1:1:9 10:10:max(max(Dv1))/100000] );
a = colorbar;
Label = ylabel(a,'D_v','FontSize',12,'Rotation',90);
hColourbar.Label.Position(1) = 3;
hold on
[c,h]= contour(u,xi,M1,[-2,0,2], '-r');
xlabel('u')
ylabel('\xi (Pa)')
hold off
5 commentaires
John D'Errico
le 19 Mar 2023
Modifié(e) : John D'Errico
le 19 Mar 2023
Are you asking for a second contour that lies at a fixed distance from the first contour? This is generally impossible on anything but some very specific functions, since it would require unless the contours to have very specific shapes.
For example, if the surface is perfectly planar, then the corresponding contour lines will all be perfectly linear. Now the contour lines will be parallel, and so lie at a fixed distance from each other. A second trivial case would be for any rotationally constructed surface. For exambple a paraboloid of revolution, created by revolving a simple parabola around an axis. If you do it correctly, then the contours are all perfect concentric circles, and are also easily constructed to be at a fixed distance from each other.
But most general surfaces will not offer any thing so trivial.
Given what John has pointed out, I should add that (unless specified explicitly) the level curves illustrated by contour()/contourf() are equally spaced on Z.
Given that, I have to ask what purpose requires the data to be massaged such that the level curves are equidistant in X and Y. At that point, we're no longer interested in observing the level curves of the data, but rather manipulating them -- or perhaps we're no longer interested in level curves at all.
Mohammed Hijjo
le 19 Mar 2023
To evenly space the contour levels above and below the second red line, you can follow these steps:
- Determine the range of the contour levels above and below the second red line that you want to evenly space. Let's say this range is from -0.00006 to 0.001.
- Calculate the number of contour levels you want to evenly space in this range. For example, if you want to have 10 evenly spaced contour levels, you would calculate the difference between the upper and lower bounds of the range (0.001 - (-0.00006) = 0.00106) and divide by the number of levels minus 1 (10 - 1 = 9): 0.00106 / 9 = 0.000118.
- Modify the contourf command to use this evenly spaced range of contour levels. Replace the existing range of contour levels with the following code:levels = [-0.05:0.005:-0.0001 -0.00006:0.000118:0.001 0.004:0.004:0.04 0.001, 0.0016, 0.00055, 0.00069, 0.0002 0.0015:0.0004:0.0042 0.0043:0.0005:0.02 0.013 0.05:0.05:0.5 0.074 0.87 0.68 0.063 0.073, 1.35 1.75, 2.56 1.1:1:9 10:10:max(max(Dv1))/100000];
University Glasgow
le 19 Mar 2023
John D'Errico
le 19 Mar 2023
if is it not possible, then how would we tell you how to do something that is impossible? Irresistable force, please meet immovable object.
A region in the plane where there are no contours drawn means you have a region where the surface is nearly perfectly flat over that entire region. If the surface is truy perfectly flat, then there are NO contour lines that cross through that region. But if it changes by even the slightest amount, then in theory, you could draw a contour line. But in that area, the contour lines would have a tiny difference in z-value. If you allow contour to draw contours at constant, then you will have a problem.
Remember that a contour line is the set of all points such that z(x,y)==z0, thus some specified constant.
Réponses (0)
Catégories
En savoir plus sur Vector Volume Data dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!