# How to plot 2D from 3D This post is a wiki. Anyone with karma >750 is welcome to improve it.

I have the following code that gives a 3D graph.

f(m,p)=16*p^4*m^4-8*(18*p^10 - 54*p^9 + 59*p^8 + 130*p^7 - 209*p^6 - 98*p^5 + 407*p^4 + 362*p^3 + 49*p^2 - 16*p + 8)*m^2+(9*( p + 1 )^2*(p^4 - 2*p^3 + 2*p^2 + 2*p + 1)*(4*p^8 - 52*p^7 + 373*p^6 + 68*p^5 - 445*p^4 + 72*p^3 + 163*p^2 - 48*p + 9))
G = plot3d(f, (-5,5), (-10,10))
G.show(zmax=5)


How to get a 2D plot of this graph on m and p plane? I tried changing plot3d to plot2d but it did not work.

edit retag close merge delete

1

The code above does not work for me. What exactly do you mean by a 2D plot? Do you mean a contour plot?

@fidbc yes i meant contour plot. by using plot3d i had a 3 dimensional region. but i want it 2 dimensional involving m and p plane.

Sort by » oldest newest most voted If you want a contour plot just use it, for example:

contour_plot(f, (m,-5,5), (p,-10,10), fill=False, plot_points=150, cmap='Spectral', contours=10)

more