Search code examples
plotmaple

Contour Plot in Maple


I'm trying to plot contours in Maple, but the 2d contour plot output is not pretty. I tried the following command:

with(plots):
contourplot(-(1/2)*y^2-(1/2)*x^2-(1-.3)/sqrt((x+.3)^2+y^2)+((-1)*.3)/sqrt((x-1+.3)^2+y^2), 
            x = -1.5 .. 1.5, y = -1.5 .. 1.5, axes = boxed)

and the plot is so much uglier than the 3d one:

contourplot3d(-(1/2)*y^2-(1/2)*x^2-(1-.3)/sqrt((x+.3)^2+y^2)+((-1)*.3)/sqrt((x-1+.3)^2+y^2), 
              x = -1.5 .. 1.5, y = -1.5 .. 1.5, view = -2 .. -1.3, axes = boxed)

Is there any way I can get the same detail in the 2d one as there is in the 3d one.

Thanks in advance!


Solution

  • By supplying (only a modest number) of specific contour values in a desired range you can get a useful result without incurring too much computational cost.

    Note that in your call to contourplot3d above you specified a range of -2 to -1.3, through the view option. Below contours are specified for the range -2.5 to -1.3. (But it would also look as useful as the 3D call for a range from -2 to -1.3.)

    The essential problem is that, for the default of a small number of contour levels, the contourplot command is taking them mostly in a range that doesn't produce the nice "even" spread. A more costly solution would be to simply ramp up the number of contours to be something high, eg, contours=100. But the call below only makes 13 contour levels.

    plots:-contourplot( -(1/2)*y^2-(1/2)*x^2-(1-.3)/sqrt((x+.3)^2+y^2)
                        +((-1)*.3)/sqrt((x-1+.3)^2+y^2),
                        x=-2.25..2.25, y=-2.25..2.25, axes=boxed,
                        contours=[seq(-2.5..-1.3,0.1)], grid=[80,80],
                        coloring=["Niagara Azure","Orange"] );
    

    enter image description here