diff options
author | tiagocoutinho <tiagocoutinho@users.sourceforge.net> | 2012-07-10 15:58:39 +0000 |
---|---|---|
committer | tiagocoutinho <tiagocoutinho@users.sourceforge.net> | 2012-07-10 15:58:39 +0000 |
commit | e30711b4835c56b5ed361828507610c76374c3c5 (patch) | |
tree | c663190e9ad47004a85825ce7a567a5d55f619a8 /src/sardana/macroserver/macros/examples/plotting.py | |
parent | 367bb413328f082eec2079b6c56b559ce068e4ae (diff) |
fix plotting feature
git-svn-id: file:///home/cpascual/src/sdnongit/svnbck/sardana/share/Sardana/trunk@20879 c480fdf4-a248-4bb0-8e4a-34cd1ef68f4f
Diffstat (limited to 'src/sardana/macroserver/macros/examples/plotting.py')
-rw-r--r-- | src/sardana/macroserver/macros/examples/plotting.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/sardana/macroserver/macros/examples/plotting.py b/src/sardana/macroserver/macros/examples/plotting.py new file mode 100644 index 00000000..e32237bf --- /dev/null +++ b/src/sardana/macroserver/macros/examples/plotting.py @@ -0,0 +1,24 @@ +import math +from numpy import linspace +from scipy.integrate import quad +from scipy.special import j0 + +from sardana.macroserver.macro import macro + +def j0i(x): + """Integral form of J_0(x)""" + def integrand(phi): + return math.cos(x * math.sin(phi)) + return (1.0/math.pi) * quad(integrand, 0, math.pi)[0] + +@macro() +def J0_plot(self): + x = linspace(0, 20, 200) + y = j0(x) + x1 = x[::10] + y1 = map(j0i, x1) + self.pyplot.plot(x, y, label=r'$J_0(x)$') # + self.pyplot.plot(x1, y1, 'ro', label=r'$J_0^{integ}(x)$') + self.pyplot.title(r'Verify $J_0(x)=\frac{1}{\{pi}\int_0^{\pi}\cos(x \sin\phi)\,d\phi$') + self.pyplot.xlabel('$x$') + self.pyplot.legend() |