Пример #1
0
#!/usr/bin/python
from os import path
import numpy as np
import wxmplot.interactive as wi

fname = 'xafs.dat'
thisdir, _ = path.split(__file__)
dat = np.loadtxt(path.join(thisdir, fname))

x = dat[:, 0]
y = dat[:, 1]

wi.plot(x, y, xlabel='E (eV)', ylabel=r'$\mu(E)$',
        label='As K edge', title='Data from %s' % fname)
Пример #2
0
#!/usr/bin/env python
from numpy import linspace, sin, random
import wxmplot.interactive as wi

x = linspace(0.0, 15.0, 151)
y = 5 * sin(4 * x) / (x * x + 6)
z = 4.8 * sin(4.3 * x) / (x * x + 8) + random.normal(size=len(x), scale=0.05)

for ix, theme in enumerate(('light', 'dark', 'matplotlib', 'seaborn', 'ggplot',
                            'bmh', 'tableau-colorblind10')):
    this = wi.plot(x,
                   y,
                   wintitle='%s theme' % theme,
                   win=ix + 1,
                   title=theme,
                   ylabel=r'$\phi(\tau)$',
                   xlabel=r'$\tau \> \rm (ms)$',
                   label='reference',
                   show_legend=True,
                   theme=theme,
                   size=(600, 450))
    wi.plot(x, z, label='signal', marker='+', win=ix + 1)
    siz = this.GetSize()
    this.SetPosition((25 + int(ix * siz[0] / 4), 25 + int(ix * siz[1] / 12)))
Пример #3
0
#!/usr/bin/env python
from numpy import linspace, sin, random
import wxmplot.interactive as wi

x = linspace(0.0, 15.0, 151)
y = 5 * sin(4 * x) / (x * x + 6)
z = 4.8 * sin(4.3 * x) / (x * x + 8) + random.normal(size=len(x), scale=0.05)

wi.plot(x,
        y,
        wintitle='wxmplot example',
        label='reference',
        ylabel=r'$\phi(\tau)$',
        xlabel=r'$\tau \> \rm (ms)$')

wi.plot(x, z, label='signal', marker='+', show_legend=True)
Пример #4
0
#!/usr/bin/python
#
# compare to plplot example at
#  http://plplot.sourceforge.net/examples.php?demo=00&lbind=Python
##
## def main(w):
##    w.plenv( 0, 100, 0, 1, 0, 0)
##    w.pllab( "x", "y=100 x#u2#d", "Simple PLplot demo of a 2D line plot" )
##    w.plline( x, y )

import numpy as np

x = np.linspace(0, 1, 101)
y = 100 * x**2

import wxmplot.interactive as wi
wi.plot(x,
        y,
        color='red',
        xlabel='x',
        ylabel=r'$y=100 x^2$',
        title="Simple PLplot demo of a 2D line plot",
        theme='dark')
Пример #5
0
#!/usr/bin/python
#
#  example plot with left and right axes with different scales
import numpy as np
import wxmplot.interactive as wi

noise = np.random.normal
n = 201
x  = np.linspace(0, 100, n)
y1 = np.sin(x/3.4)/(0.2*x+2) + noise(size=n, scale=0.1)
y2 = 92 + 65*np.cos(x/16.) * np.exp(-x*x/7e3) + noise(size=n, scale=0.3)


wi.plot(x, y1, title='Test 2 Axes with different y scales',
        xlabel='x (mm)', ylabel='y1', ymin=-0.75, ymax=0.75)
wi.plot(x, y2, y2label='y2', side='right', ymin=0)
Пример #6
0
#!/usr/bin/python
import numpy as np
import wxmplot.interactive as wi

x = np.linspace(0.0, 20.0, 201)
wi.plot(x, np.sin(x) / (x + 1), ylabel='response', xlabel='T (sec)')
Пример #7
0
# make data
import numpy as np
x = 3.6 * np.arange(101)
y1 = np.cos(np.pi * x / 180)
y2 = np.sin(np.pi * x / 180)

# dislin:
#   See script at:
#   https://www2.mps.mpg.de/dislin/exa_python.html#section_1

# matplotlib/pyplot:
mpl_script = """
import  matplotlib.pyplot as plt
plt.plot(x, y1, '-', color='r')
plt.plot(x, y2, '-+', color='g')
plt.title('DISLIN Comparison\nsin(x) and cos(x)')
plt.xlabel('x')
plt.ylabel('y')
plt.show()
"""

# wxmplot:
import wxmplot.interactive as wi
wi.plot(x,
        y1,
        color='red',
        xlabel='x',
        ylabel='y',
        title='DISLIN Comparison\nsin(x) and cos(x)')
wi.plot(x, y2, color='green3', marker='+')
Пример #8
0
#!/usr/bin/python
import numpy as np
x = np.linspace(0.0, 15.0, 151)
y = 5*np.sin(4*x)/(x*x+6)
z = 4.8*np.sin(4.3*x)/(x*x+8) + np.random.normal(size=len(x), scale=0.05)

import wxmplot.interactive as wi
wi.plot(x, y, label='reference', marker='+', xlabel='x', ylabel='y',
        title='wxmplot example', show_legend=True)
wi.plot(x, z, label='signal')
Пример #9
0
#!/usr/bin/python
import numpy as np
import wxmplot.interactive as wi

x = np.arange(0.0, 10.0, 0.1)
y = np.sin(2 * x) / (x + 2)

win1 = wi.plot(x, y, title='Window 1', xlabel='X (mm)', win=1)

win2 = wi.plot(x, np.cos(x - 4), title='Window 2', xlabel='X (mm)', win=2)

pos = win2.GetPosition()
siz = win1.GetSize()
win2.SetPosition((pos[0] + int(siz[0] * 0.8), pos[1] + 10))