[wip] Convenience to test matplotlib

This commit is contained in:
Romain Goyet
2020-03-11 17:54:42 -04:00
committed by Émilie Feral
parent 3df8018943
commit d71ad9b288
2 changed files with 12 additions and 12 deletions

View File

@@ -40,18 +40,13 @@ def mandelbrot(N_iteration):
# Draw a pixel colored in 'col' at position (x,y)
kandinsky.set_pixel(x,y,col))");
constexpr ScriptTemplate polynomialScriptTemplate("polynomial.py", "\x01" R"(from math import *
# roots(a,b,c) computes the solutions of the equation a*x**2+b*x+c=0
def roots(a,b,c):
delta = b*b-4*a*c
if delta == 0:
return -b/(2*a)
elif delta > 0:
x_1 = (-b-sqrt(delta))/(2*a)
x_2 = (-b+sqrt(delta))/(2*a)
return x_1, x_2
else:
return None)");
constexpr ScriptTemplate polynomialScriptTemplate("polynomial.py", "\x01" R"(from pyplot import *
x = [1,2,3,4]
y = [-1,-2,-3,-4]
scatter(x, y)
plot(y, x)
text(-1,-1,"Coucou")
show())");
const ScriptTemplate * ScriptTemplate::Empty() {
return &emptyScriptTemplate;