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.")
def magic_gpc(self, parameter_s = ''):
if parameter_s.strip():
self.shell.gnuplot(parameter_s)
else:
self.shell.gnuplot.interact()
def magic_gp_set_default(self, parameter_s = ''):
gname = parameter_s.strip()
G = eval(gname, self.shell.user_ns)
self.shell.gnuplot = G
self.shell.user_ns.update({
'plot': G.plot,
'splot': G.splot,
'plot2': G.plot2,
'replot': G.replot,
'hardcopy': G.hardcopy })
try:
__IPYTHON__
except NameError:
pass
__IPYTHON__.gnuplot = GRun.gp
__IPYTHON__.gnuplot.shell_first_time = 1
print '*** Type `gphelp` for help on the Gnuplot integration features.'