How to plot 2 variables on a plane

后端 未结 1 1149
误落风尘
误落风尘 2021-01-25 15:11

Let\'s say I have an equation:

x**2 + y**2 - 4 = 0

How can I see the circle using sympy, matplotplib or another python solution?

相关标签:
1条回答
  • 2021-01-25 15:38

    Yes KillianDS, I now understand this is a duplicate of Is it possible to plot implicit equations using Matplotlib?

    Though I still don't know how to do it in sympy. The answer for matplotlib would be:

    import matplotlib.pyplot
    from numpy import arange
    from numpy import meshgrid
    
    delta = 0.025
    xrange = arange(-3.0, 3.0, delta)
    yrange = arange(-2.0, 2.0, delta)
    X, Y = meshgrid(xrange,yrange)
    F = X**2 + Y**2 -4
    G = 0
    matplotlib.pyplot.contour(X,Y,(F-G),[0])
    matplotlib.pyplot.show()
    

    I'm still having trouble, but I'll post it in a different question.

    0 讨论(0)
提交回复
热议问题