Exemple #1
0
Mohammad Rahmani <mohammad [dot] rahmani [at] gmail [dot] com>
Amirkabir Uni of Tech, Teh, Ir
@License
This file is licensed under the GNU Lesser General Public License (LGPL)
@Version
alpha, Aug 27, 2010
'''

import gplot

#...............................................................................
# Example 1: A very basic example
#...............................................................................

#Create a new instance of Gnuplot class
gp = gplot.Gnuplot()

# Input data
x = [-8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8]
y = [66, 51, 38, 27, 18, 11, 6, 3, 2, 3, 6, 11, 18, 27, 38, 51, 66]

#Annotation, set title, xlabel, ylabel
gp.title("Example 1: plot of x-y data")
gp.xlabel("x,...")
gp.ylabel("y,...")

#Call plot method
gp.plot(x, y)
gp.script("pause 1 'press any key to continue...'")

#...............................................................................
Exemple #2
0
from matpy import *

import gplot, gplot.funcutils
_g = gplot.Gnuplot()
gnuplot_has_pm3d = True


class _seti:
    def __getitem__(self, x):
        if type(x) is slice:
            s, e, t = (x.start is not None and x.start
                       or 1) - 1, x.step - 1, x.stop is None and 1 or x.stop
            if round(t) != t:
                raise Exception('The step must be integer value!')
            e += 1e-6 * t
            return arange(s, e, t)
        return array(x) - 1


mri_ = _seti()


class _setitem:
    def __init__(self, ibase=0):
        self.__ibase = ibase

    def __getitem__(self, x):
        if type(x) is slice:
            step = x.stop or 1.
            if x.start is None:
                return arange(1, x.step + 0.1 * step, x.stop)