Good day! It is necessary to plot a mathematical function (y = f (x)) (for example, hyperbola). Now I try to implement on sympy and wand:

from wand.font import * from wand.image import * from wand.drawing import * from wand.color import * from wand import * from sympy import * def o2n(x,y): centerx = 500 centery = 450 y = -y*10+centery x = x*10+centerx print(x, y) return x,y x = symbols('x') inp = input() slv = sympify(inp) print(slv) with Drawing() as draw: with Image(width=1000, height=900,background=Color('white')) as image: old = 0 draw.line((0,image.height//2),(image.width,image.height//2)) #Ось Х draw.line((image.width//2,0),(image.width//2,image.height)) #Ось Y for j in range(-600,600): try: y=float(slv.subs(x, j)) y2=float(slv.subs(x, j+1)) draw.line(o2n(j,y),o2n(j+1,y2)) except: pass draw(image) image.save(filename='result.png') 

But it turns out not exactly (lines of hyperbola merge with the axes of coordinates). Does anyone have any ideas on this? I thought about numpy, but I didn’t find how to save all this into a picture (jpg is desirable)

  • five
    And what did not suit matplotlib? - Dmitriy Simushev

0