Exemple #1
0
def test(colormap):
    with Plot(colormap) as p:
        p.title = r"%s colormap" % colormap
        p.x.label = "$x$"
        p.y.label = "$y$"
        p.legend.show = False

        p.style.colormap(colormap)
        p.style.thickness = ["ultra thick"] * 8

        for i in range(8):
            p.plot(Function(lambda x: sin(x - i * pi / 8),
                            samples=50,
                            range=(0, pi)),
                   title=r"$\sin(x)$")
Exemple #2
0
import numpy
from math import pi, sqrt, exp
from plotz import Plot, Function, DataFile
numpy.random.seed(42)

mu, sigma = 100, 15
n = 10000
x = mu + sigma * numpy.random.randn(n)
hist, bins = numpy.histogram(x, bins=30)

factor = (bins[1] - bins[0]) * n

with Plot("plot") as p:
    p.title = "example of PlotZ histogram"

    p.x.min = 40
    p.x.max = 160
    p.x.ticks = 20
    p.x.label = r"$x$"

    p.y.min = 0
    p.y.ticks = 200
    p.y.label = r"\# occurrences"
    p.y.label_rotate = True
    p.y.label_shift *= 0.8

    # bins
    p.histogram.bins = bins
    # bins

    # hist
Exemple #3
0
from math import sin, pi
from plotz import Plot, Function
from plotz.utils import Markers

with Plot("plot") as p:
    p.title = "markers"
    p.x.label = "$x$"
    p.y.label = "$y$"

    p.style.colormap("dark")

    N = 6
    fun = [
        lambda x, j=i: sin(2 * pi * x) + (N + 1) - N / (N - 1.) * j
        for i in range(N)
    ]

    # markers
    p.plot(Function(fun[0], samples=20, range=(0, 1)), title=r"line 0").style({
        "markers":
        True,
    })
    # markers

    # oneInN
    p.plot(Function(fun[1], samples=20, range=(0, 1)), title=r"line 1").style({
        "markers":
        True,
        "markers_filter":
        Markers.oneInN(2),
    })
Exemple #4
0
from plotz import Plot, DataFile
from plotz.utils import Markers

with Plot("fourier") as p:
    p.title = "Amplification factor of various acceleration schemes"

    p.x.min = 0
    p.x.max = 20
    p.x.ticks = 2
    p.x.label = r"$\omega$"

    p.y.min, p.y.max = 0, 1
    p.y.tick_format = lambda x: "%.1f"%x
    p.y.label = r"$\displaystyle\frac{\Vert\phi_1\Vert_2}{\Vert\phi_0\Vert_2}$"
    p.y.label_shift *= 0.8

    # thickness
    p.style.thickness = ["ultra thin", "thick", "ultra thick"]

    p.plot(DataFile("fourier.dat"), title="SI").style({
        "thickness": 2, # ultra thick
    })
    # thickness

    p.plot(DataFile("fourier.dat"), title="DSA", col=(0,2)).style({
        "thickness": 2,
    })

    # markers
    p.plot(DataFile("fourier.dat"), title="PDSA(2)", col=(0,3)).style({
        "thickness": 0,
Exemple #5
0
from math import sin, pi
from plotz import Plot, Function, DataFile
from plotz.utils import Markers

with Plot("plot") as p:
    p.title = "Line patterns"
    p.x.label = "$x$"
    p.y.label = "$y$"

    # dashed
    p.style.dashed()
    p.style.colormap("monochrome")
    # dashed

    N = 8
    fun = [
        lambda x, j=i: sin(2 * pi * x) + (N + 1) - N / (N - 1.) * j
        for i in range(N)
    ]

    for i in range(N):
        p.plot(Function(fun[i], samples=40, range=(0, 1)),
               title=r"pattern %d" % i)

    p.legend("east", "west")
    p.legend.margin = 1

with Plot("monochrome") as p:
    p.title = r"Monochrome plot"

    p.x.min = 0