项目作者: thuxuxs

项目描述 :
Manipulate for Python
高级语言: Python
项目地址: git://github.com/thuxuxs/mplot.git
创建时间: 2017-05-02T04:44:34Z
项目社区:https://github.com/thuxuxs/mplot

开源协议:

下载


Hello mplot

mplot is designed to give you a interactive manipulation
of the parameters of the function you want.

install

  1. python setup.py install

Define a function we want to show

  1. def generate(x, a, phi):
  2. out = np.array([x, a * np.sin(x + phi), a * np.cos(x + phi)]).T
  3. return pd.DataFrame(out, columns=['x', 'sin', 'cos'])

This function will generate sin and cos waves, and the parameters are
the amplitude and the phase, now we change these two parameters to show
the corresponding changes of the waves.

usage 1

We plot two waves in one picture

  1. fig = mplot(generate, np.linspace(0, 10, 100), a=(1, 2), phi=(0, 2 * np.pi))
  2. fig.add_subplot()
  3. fig.add_all()
  4. fig.show()

one subplot

usage 2

We plot there two waves in different subplots

  1. fig = mplot(generate, np.linspace(0, 10, 100), a=(1, 2), phi=(0, 2 * np.pi))
  2. sub1 = fig.add_subplot(121)
  3. fig.add_line(sub1, 'x', 'sin', 'r', linewidth=2, label='sin')
  4. fig.add_line(sub1, 'x', 'cos', 'k-.', lw=4, label='cos')
  5. sub2 = fig.add_subplot(122)
  6. fig.add_line(sub2, 'sin', 'cos')
  7. fig.show()

two subplots