From: <mh...@us...> - 2008-10-03 18:53:30
|
Revision: 310 http://gnuplot-py.svn.sourceforge.net/gnuplot-py/?rev=310&view=rev Author: mhagger Date: 2008-10-03 18:53:20 +0000 (Fri, 03 Oct 2008) Log Message: ----------- Make __init__.py, funcutils.py, and utils.py non-executable. Modified Paths: -------------- trunk/__init__.py trunk/funcutils.py trunk/utils.py Property Changed: ---------------- trunk/__init__.py Modified: trunk/__init__.py =================================================================== --- trunk/__init__.py 2008-05-08 14:38:57 UTC (rev 309) +++ trunk/__init__.py 2008-10-03 18:53:20 UTC (rev 310) @@ -1,4 +1,3 @@ -#! /usr/bin/env python # $Id$ # Copyright (C) 1998-2003 Michael Haggerty <mh...@al...> @@ -167,8 +166,3 @@ from _Gnuplot import Gnuplot -if __name__ == '__main__': - import demo - demo.demo() - - Property changes on: trunk/__init__.py ___________________________________________________________________ Deleted: svn:executable - * Modified: trunk/funcutils.py =================================================================== --- trunk/funcutils.py 2008-05-08 14:38:57 UTC (rev 309) +++ trunk/funcutils.py 2008-10-03 18:53:20 UTC (rev 310) @@ -1,5 +1,3 @@ -#! /usr/bin/env python - # $Id$ # Copyright (C) 1998-2003 Michael Haggerty <mh...@al...> Modified: trunk/utils.py =================================================================== --- trunk/utils.py 2008-05-08 14:38:57 UTC (rev 309) +++ trunk/utils.py 2008-10-03 18:53:20 UTC (rev 310) @@ -1,5 +1,3 @@ -#! /usr/bin/env python - # $Id$ # Copyright (C) 1998-2003 Michael Haggerty <mh...@al...> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mh...@us...> - 2011-11-19 14:01:51
|
Revision: 318 http://gnuplot-py.svn.sourceforge.net/gnuplot-py/?rev=318&view=rev Author: mhagger Date: 2011-11-19 14:01:45 +0000 (Sat, 19 Nov 2011) Log Message: ----------- Add method Gnuplot.set_tics(). Allow axis tic marks and labels to be set a la "set xtics" etc. Suggested by: Lorenzo Mentaschi <lor...@ya...> Modified Paths: -------------- trunk/_Gnuplot.py trunk/__init__.py trunk/test.py Modified: trunk/_Gnuplot.py =================================================================== --- trunk/_Gnuplot.py 2011-11-19 07:59:32 UTC (rev 317) +++ trunk/_Gnuplot.py 2011-11-19 14:01:45 UTC (rev 318) @@ -57,6 +57,35 @@ self.flush() +class Tic: + """An explicit ticmark definition. + + An instance of this class defines a tic mark explicitly, a la + gnuplot's 'set xtics (...)' command.""" + + def __init__(self, position, label=None, level=None): + self.position = position + if label is None: + if level is not None: + label = str(position) + elif not isinstance(label, basestring): + raise TypeError('label must be a string') + self.label = label + if level is None: + self.level = None + else: + self.level = int(level) + + def __str__(self): + retval = [] + if self.label is not None: + retval.append('"%s"' % (self.label,)) + retval.append(str(self.position)) + if self.level is not None: + retval.append(str(self.level)) + return ' '.join(retval) + + class Gnuplot: """Interface to a gnuplot program. @@ -472,6 +501,39 @@ self.set_label('title', s, offset=offset, font=font) + def set_tics(self, axis, value): + """Configure the tics for the given axis. + + axis may be 'x', 'y', 'z', 'x2', or 'y2'. + + value can be a string, in which case it is passed to gnuplot's + 'set xtics', 'set ytics', etc. command. Or it can be a list + of Tic objects or tuples specifying where each individual + tic/label should be placed. Any list entries that are tuples + are passed to the Tic constructor and therefore must be in one + of the following forms: + + (pos,) + (pos, label) + (pos, label, level) + + where pos is the position of the tic mark (as a number), label + is a string that will be used to label the tic, and level is 0 + (for major tics) or 1 (for minor tics). + + """ + + if type(value) is types.StringType: + tics_string = value + else: + tics_strings = [] + for tic in value: + if not isinstance(tic, Tic): + tic = Tic(*tic) + tics_strings.append(str(tic)) + tics_string = '(%s)' % (', '.join(tics_strings),) + self('set %stics %s' % (axis, tics_string,)) + def hardcopy(self, filename=None, terminal='postscript', **keyw): """Create a hardcopy of the current plot. Modified: trunk/__init__.py =================================================================== --- trunk/__init__.py 2011-11-19 07:59:32 UTC (rev 317) +++ trunk/__init__.py 2011-11-19 14:01:45 UTC (rev 318) @@ -163,6 +163,6 @@ from gp import GnuplotOpts, GnuplotProcess, test_persist from Errors import Error, OptionError, DataError from PlotItems import PlotItem, Func, File, Data, GridData -from _Gnuplot import Gnuplot +from _Gnuplot import Gnuplot, Tic Modified: trunk/test.py =================================================================== --- trunk/test.py 2011-11-19 07:59:32 UTC (rev 317) +++ trunk/test.py 2011-11-19 14:01:45 UTC (rev 318) @@ -80,6 +80,21 @@ g.plot(Gnuplot.Func('sin(x)', title='Sine of x')) wait('axes=x2y2') g.plot(Gnuplot.Func('sin(x)', axes='x2y2', title='Sine of x')) + wait('Custom tics') + g.set_tics( + 'x', + [ + (-2 * math.pi, '-2pi'), + (-math.pi, '', 2), + (0,), + Gnuplot.Tic(math.pi, level=2), + Gnuplot.Tic(2 * math.pi, '2pi'), + ], + ) + g.plot(Gnuplot.Func('sin(x)', title='Sine of x')) + wait('Reset to default tics') + g.set_tics('x', 'auto') + g.plot(Gnuplot.Func('sin(x)', title='Sine of x')) print 'Change Func attributes after construction:' f = Gnuplot.Func('sin(x)') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mh...@us...> - 2012-12-06 09:23:43
|
Revision: 323 http://gnuplot-py.svn.sourceforge.net/gnuplot-py/?rev=323&view=rev Author: mhagger Date: 2012-12-06 09:23:32 +0000 (Thu, 06 Dec 2012) Log Message: ----------- Use "print" in a way that is compatible with Python 3.x. Suggested by: Csaba Szepesvari <sze...@ua...> Modified Paths: -------------- trunk/demo.py trunk/test.py Modified: trunk/demo.py =================================================================== --- trunk/demo.py 2011-11-19 14:51:51 UTC (rev 322) +++ trunk/demo.py 2012-12-06 09:23:32 UTC (rev 323) @@ -60,7 +60,7 @@ # support enhanced mode, set `enhanced=0' below. g.ylabel('x^2') # take advantage of enhanced postscript mode g.hardcopy('gp_test.ps', enhanced=1, color=1) - print ('\n******** Saved plot to postscript file "gp_test.ps" ********\n') + print('\n******** Saved plot to postscript file "gp_test.ps" ********\n') raw_input('Please press return to continue...\n') g.reset() Modified: trunk/test.py =================================================================== --- trunk/test.py 2011-11-19 14:51:51 UTC (rev 322) +++ trunk/test.py 2012-12-06 09:23:32 UTC (rev 323) @@ -31,14 +31,14 @@ def wait(str=None, prompt='Press return to show results...\n'): if str is not None: - print str + print(str) raw_input(prompt) def main(): """Exercise the Gnuplot module.""" - print ( + print( 'This program exercises many of the features of Gnuplot.py. The\n' 'commands that are actually sent to gnuplot are printed for your\n' 'enjoyment.' @@ -62,7 +62,7 @@ f.write('%s %s %s\n' % (x, math.cos(x), math.sin(x))) f.close() - print '############### test Func ###################################' + print('############### test Func ###################################') wait('Plot a gnuplot-generated function') g.plot(Gnuplot.Func('sin(x)')) @@ -96,7 +96,7 @@ g.set_tics('x', 'auto') g.plot(Gnuplot.Func('sin(x)', title='Sine of x')) - print 'Change Func attributes after construction:' + print('Change Func attributes after construction:') f = Gnuplot.Func('sin(x)') wait('Original') g.plot(f) @@ -113,7 +113,7 @@ f.set_option(axes='x2y2') g.plot(f) - print '############### test File ###################################' + print('############### test File ###################################') wait('Generate a File from a filename') g.plot(Gnuplot.File(filename1)) @@ -140,7 +140,7 @@ wait('title="title"') g.plot(Gnuplot.File(filename1, title='title')) - print 'Change File attributes after construction:' + print('Change File attributes after construction:') f = Gnuplot.File(filename1) wait('Original') g.plot(f) @@ -154,7 +154,7 @@ f.set_option(title=None) g.plot(f) - print '############### test Data ###################################' + print('############### test Data ###################################') x = numpy.arange(100)/5. - 10. y1 = numpy.cos(x) y2 = numpy.sin(x) @@ -200,7 +200,7 @@ wait('title="Cosine of x"') g.plot(Gnuplot.Data(d, title='Cosine of x')) - print '############### test compute_Data ###########################' + print('############### test compute_Data ###########################') x = numpy.arange(100)/5. - 10. wait('Plot Data, computed by Gnuplot.py') @@ -217,8 +217,8 @@ wait('with_="lp 4 4"') g.plot(Gnuplot.funcutils.compute_Data(x, math.cos, with_='lp 4 4')) - print '############### test hardcopy ###############################' - print '******** Generating postscript file "gp_test.ps" ********' + print('############### test hardcopy ###############################') + print('******** Generating postscript file "gp_test.ps" ********') wait() g.plot(Gnuplot.Func('cos(0.5*x*x)', with_='linespoints 2 2', title='cos(0.5*x^2)')) @@ -258,7 +258,7 @@ wait('Testing hardcopy options: fontsize=20') g.hardcopy('gp_test.ps', fontsize=20) - print '******** Generating svg file "gp_test.svg" ********' + print('******** Generating svg file "gp_test.svg" ********') wait() g.plot(Gnuplot.Func('cos(0.5*x*x)', with_='linespoints 2 2', title='cos(0.5*x^2)')) @@ -268,11 +268,11 @@ g.hardcopy('gp_test.ps', terminal='svg', enhanced='1') - print '############### test shortcuts ##############################' + print('############### test shortcuts ##############################') wait('plot Func and Data using shortcuts') g.plot('sin(x)', d) - print '############### test splot ##################################' + print('############### test splot ##################################') wait('a 3-d curve') g.splot(Gnuplot.Data(d, with_='linesp', inline=0)) wait('Same thing, saved to a file') @@ -281,7 +281,7 @@ wait('Same thing, inline data') g.splot(Gnuplot.Data(d, with_='linesp', inline=1)) - print '############### test GridData and compute_GridData ##########' + print('############### test GridData and compute_GridData ##########') # set up x and y values at which the function will be tabulated: x = numpy.arange(35)/2.0 y = numpy.arange(30)/10.0 - 1.5 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mh...@us...> - 2012-12-06 09:23:58
|
Revision: 324 http://gnuplot-py.svn.sourceforge.net/gnuplot-py/?rev=324&view=rev Author: mhagger Date: 2012-12-06 09:23:50 +0000 (Thu, 06 Dec 2012) Log Message: ----------- Update for modern gnuplot. Change to use modern gnuplot usage "set style data lines" rather than "set data style lines". Suggested by: Csaba Szepesvari <sze...@ua...> Modified Paths: -------------- trunk/__init__.py trunk/demo.py trunk/test.py Modified: trunk/__init__.py =================================================================== --- trunk/__init__.py 2012-12-06 09:23:32 UTC (rev 323) +++ trunk/__init__.py 2012-12-06 09:23:50 UTC (rev 324) @@ -136,7 +136,7 @@ commands to gnuplot manually:: g = Gnuplot.Gnuplot() - g('set data style linespoints') + g('set style data linespoints') g('set pointsize 5') - There is no provision for missing data points in array data (which Modified: trunk/demo.py =================================================================== --- trunk/demo.py 2012-12-06 09:23:32 UTC (rev 323) +++ trunk/demo.py 2012-12-06 09:23:50 UTC (rev 324) @@ -27,7 +27,7 @@ # are also output on stderr. g = Gnuplot.Gnuplot(debug=1) g.title('A simple example') # (optional) - g('set data style linespoints') # give gnuplot an arbitrary command + g('set style data linespoints') # give gnuplot an arbitrary command # Plot a list of (x, y) pairs (tuples or a numpy array would # also be OK): g.plot([[0,1.1], [1,5.8], [2,3.3], [3,4.2]]) @@ -75,7 +75,7 @@ ym = y[newaxis,:] m = (sin(xm) + 0.1*xm) - ym**2 g('set parametric') - g('set data style lines') + g('set style data lines') g('set hidden') g('set contour base') g.title('An example of a surface plot') Modified: trunk/test.py =================================================================== --- trunk/test.py 2012-12-06 09:23:32 UTC (rev 323) +++ trunk/test.py 2012-12-06 09:23:50 UTC (rev 324) @@ -293,7 +293,7 @@ m = (numpy.sin(xm) + 0.1*xm) - ym**2 wait('a function of two variables from a GridData file') g('set parametric') - g('set data style lines') + g('set style data lines') g('set hidden') g('set contour base') g.xlabel('x') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mh...@us...> - 2012-12-06 09:24:17
|
Revision: 325 http://gnuplot-py.svn.sourceforge.net/gnuplot-py/?rev=325&view=rev Author: mhagger Date: 2012-12-06 09:24:06 +0000 (Thu, 06 Dec 2012) Log Message: ----------- Add Python 2.x/3.x compatibility hack for raw_input. Modified Paths: -------------- trunk/_Gnuplot.py trunk/demo.py trunk/test.py Modified: trunk/_Gnuplot.py =================================================================== --- trunk/_Gnuplot.py 2012-12-06 09:23:50 UTC (rev 324) +++ trunk/_Gnuplot.py 2012-12-06 09:24:06 UTC (rev 325) @@ -14,6 +14,14 @@ import sys, string, types + +try: + # For Python 2.x/3.x compatibility: + input = raw_input +except NameError: + pass + + import gp, PlotItems, termdefs, Errors @@ -377,7 +385,7 @@ sys.stderr.write('Press C-d to end interactive input\n') while 1: try: - line = raw_input('gnuplot>>> ') + line = input('gnuplot>>> ') except EOFError: break self(line) Modified: trunk/demo.py =================================================================== --- trunk/demo.py 2012-12-06 09:23:50 UTC (rev 324) +++ trunk/demo.py 2012-12-06 09:24:06 UTC (rev 325) @@ -15,6 +15,14 @@ from numpy import * + +try: + # For Python 2.x/3.x compatibility: + input = raw_input +except NameError: + pass + + # If the package has been installed correctly, this should work: import Gnuplot, Gnuplot.funcutils @@ -31,7 +39,7 @@ # Plot a list of (x, y) pairs (tuples or a numpy array would # also be OK): g.plot([[0,1.1], [1,5.8], [2,3.3], [3,4.2]]) - raw_input('Please press return to continue...\n') + input('Please press return to continue...\n') g.reset() # Plot one dataset from an array and one via a gnuplot function; @@ -50,7 +58,7 @@ g.ylabel('x squared') # Plot a function alongside the Data PlotItem defined above: g.plot(Gnuplot.Func('x**2', title='calculated by gnuplot'), d) - raw_input('Please press return to continue...\n') + input('Please press return to continue...\n') # Save what we just plotted as a color postscript file. @@ -61,7 +69,7 @@ g.ylabel('x^2') # take advantage of enhanced postscript mode g.hardcopy('gp_test.ps', enhanced=1, color=1) print('\n******** Saved plot to postscript file "gp_test.ps" ********\n') - raw_input('Please press return to continue...\n') + input('Please press return to continue...\n') g.reset() # Demonstrate a 3-d plot: @@ -89,7 +97,7 @@ # binary data. Change this to `binary=1' (or omit the binary # option) to get the advantage of binary format. g.splot(Gnuplot.GridData(m,x,y, binary=0)) - raw_input('Please press return to continue...\n') + input('Please press return to continue...\n') # plot another function, but letting GridFunc tabulate its values # automatically. f could also be a lambda or a global function: @@ -97,7 +105,7 @@ return 1.0 / (1 + 0.01 * x**2 + 0.5 * y**2) g.splot(Gnuplot.funcutils.compute_GridData(x,y, f, binary=0)) - raw_input('Please press return to continue...\n') + input('Please press return to continue...\n') # Explicit delete shouldn't be necessary, but if you are having # trouble with temporary files being left behind, try uncommenting Modified: trunk/test.py =================================================================== --- trunk/test.py 2012-12-06 09:23:50 UTC (rev 324) +++ trunk/test.py 2012-12-06 09:24:06 UTC (rev 325) @@ -18,6 +18,13 @@ import numpy try: + # For Python 2.x/3.x compatibility: + input = raw_input +except NameError: + pass + + +try: import Gnuplot, Gnuplot.PlotItems, Gnuplot.funcutils except ImportError: # kludge in case Gnuplot hasn't been installed as a module yet: @@ -32,7 +39,7 @@ def wait(str=None, prompt='Press return to show results...\n'): if str is not None: print(str) - raw_input(prompt) + input(prompt) def main(): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |