home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_1814 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  3.9 KB  |  69 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. __all__ = [
  5.     'Gnuplot',
  6.     'gp',
  7.     'gp_new',
  8.     'plot',
  9.     'plot2',
  10.     'splot',
  11.     'replot',
  12.     'hardcopy',
  13.     'gpdata',
  14.     'gpfile',
  15.     'gpstring',
  16.     'gpfunc',
  17.     'gpgrid',
  18.     'gphelp']
  19. import IPython.GnuplotRuntime as GRun
  20. from IPython.genutils import page, warn
  21. Gnuplot = GRun.Gnuplot
  22. gp_new = GRun.gp_new
  23. gp = GRun.gp
  24. plot = gp.plot
  25. plot2 = gp.plot2
  26. splot = gp.splot
  27. replot = gp.replot
  28. hardcopy = gp.hardcopy
  29. gpdata = Gnuplot.Data
  30. gpfile = Gnuplot.File
  31. gpstring = Gnuplot.String
  32. gpfunc = Gnuplot.Func
  33. gpgrid = Gnuplot.GridData
  34.  
  35. def gphelp():
  36.     page("\nIPython provides an interface to access the Gnuplot scientific plotting\nsystem, in an environment similar to that of Mathematica or Matlab.\n\nNew top-level global objects\n----------------------------\n\nPlease see their respective docstrings for further details.\n\n- gp: a running Gnuplot instance. You can access its methods as\ngp.<method>. gp(`a string`) will execute the given string as if it had been\ntyped in an interactive gnuplot window.\n\n- plot, splot, replot and hardcopy: aliases to the methods of the same name in\nthe global running Gnuplot instance gp. These allow you to simply type:\n\nIn [1]: plot(x,sin(x),title='Sin(x)')  # assuming x is a Numeric array\n\nand obtain a plot of sin(x) vs x with the title 'Sin(x)'.\n\n- gp_new: a function which returns a new Gnuplot instance. This can be used to\nhave multiple Gnuplot instances running in your session to compare different\nplots, each in a separate window.\n\n- Gnuplot: alias to the Gnuplot2 module, an improved drop-in replacement for\nthe original Gnuplot.py. Gnuplot2 needs Gnuplot but redefines several of its\nfunctions with improved versions (Gnuplot2 comes with IPython).\n\n- gpdata, gpfile, gpstring, gpfunc, gpgrid: aliases to Gnuplot.Data,\nGnuplot.File, Gnuplot.String, Gnuplot.Func and Gnuplot.GridData\nrespectively. These functions create objects which can then be passed to the\nplotting commands. See the Gnuplot.py documentation for details.\n\nKeep in mind that all commands passed to a Gnuplot instance are executed in\nthe Gnuplot namespace, where no Python variables exist. For example, for\nplotting sin(x) vs x as above, typing\n\nIn [2]: gp('plot x,sin(x)')\n\nwould not work. Instead, you would get the plot of BOTH the functions 'x' and\n'sin(x)', since Gnuplot doesn't know about the 'x' Python array. The plot()\nmethod lives in python and does know about these variables.\n\n\nNew magic functions\n-------------------\n\n%gpc: pass one command to Gnuplot and execute it or open a Gnuplot shell where\neach line of input is executed.\n\n%gp_set_default: reset the value of IPython's global Gnuplot instance.")
  37.  
  38.  
  39. def magic_gpc(self, parameter_s = ''):
  40.     if parameter_s.strip():
  41.         self.shell.gnuplot(parameter_s)
  42.     else:
  43.         self.shell.gnuplot.interact()
  44.  
  45.  
  46. def magic_gp_set_default(self, parameter_s = ''):
  47.     gname = parameter_s.strip()
  48.     G = eval(gname, self.shell.user_ns)
  49.     self.shell.gnuplot = G
  50.     self.shell.user_ns.update({
  51.         'plot': G.plot,
  52.         'splot': G.splot,
  53.         'plot2': G.plot2,
  54.         'replot': G.replot,
  55.         'hardcopy': G.hardcopy })
  56.  
  57.  
  58. try:
  59.     __IPYTHON__
  60. except NameError:
  61.     pass
  62.  
  63. __IPYTHON__.gnuplot = GRun.gp
  64. __IPYTHON__.gnuplot.shell_first_time = 1
  65. print '*** Type `gphelp` for help on the Gnuplot integration features.'
  66. from IPython.iplib import InteractiveShell
  67. InteractiveShell.magic_gpc = magic_gpc
  68. InteractiveShell.magic_gp_set_default = magic_gp_set_default
  69.