def multifield(whichone): x, y = symbols('x,y') myPlot = plots.MyStandardPlot() myPlot.ygraph(0.5 * exp(x * x / 2), [x, -1, 1], color=1) myPlot.ygraph(0.25 * exp(-x * x / 2), [x, -1, 1], color=2) myPlot.ygraph(x, [x, -1, 1], color=3) myPlot.ygraph(-sqrt(0.25**2 - x**2), [x, -0.25, 0.25], color=4) myPlot.ygraph(-sqrt(0.5**2 + x**2), [x, -0.9, 0.9], color=5) myPlot.text(0.95, 0.70, 'A') myPlot.text(0.88, 0.95, 'C') myPlot.text(0.95, 0.22, 'B') myPlot.text(0.92, -0.95, 'E') myPlot.text(0.32, 0, 'D') if whichone == 4: myPlot.slopefield(x * y, [x, -1, 1], [y, -1, 1], samples=25) elif whichone == 2: myPlot.slopefield(-x * y, [x, -1, 1], [y, -1, 1], samples=25) elif whichone == 3: myPlot.slopefield(x - y + 1, [x, -1, 1], [y, -1, 1], samples=25) elif whichone == 1: myPlot.slopefield(-x / sqrt(0.5**2 + x**2), [x, -1, 1], [y, -1, 1], samples=25) myPlot.xticks([-1, 0, 1]) myPlot.yticks([-1, 0, 1]) myPlot.yaxis('left') myPlot.xaxis('bottom') # myPlot.show() myPlot.saveas('slope' + str(whichone).zfill(2) + '.png') myPlot.destroy()
import plots from sympy import * x = Symbol('x') myPlot = plots.MyStandardPlot() myPlot.yfillbetween([exp(-x**2), 0], (x, -0.5, 0.5), samples=400) myPlot.ygraph(exp(-x**2), (x, -2, 2), color=-1) myPlot.xticks([]) myPlot.yticks([]) myPlot.yaxis("left") myPlot.mathlabel(1.2, 0.5, r'f(x)') myPlot.mathlabel(-0.5, -0.14, 'c') myPlot.mathlabel(0.5, -0.14, 'd') myPlot.arrow(-0.95, -0.4, -0.9, 0) myPlot.arrow(0.95, -0.4, 0.9, 0) myPlot.text(0, -0.4, r'possible values of $X$') myPlot.canvas.text(-2.4, 0.75, 'likelihood', fontsize=12, rotation=90) #myPlot.mathlabel(0.0,1.2,r'y=\sqrt{1+x^2}') myPlot.ylim(-0.5, 1.1) #myPlot.resize() myPlot.show() myPlot.saveas('probability01.png') myPlot.destroy() quit()