Exemplo n.º 1
0
def create_example_graphics_export():
    x = [2 * math.pi * i / 100 for i in range(100)]
    y = [math.sin(c) for c in x]
    gr.begingraphics(GRAPHICS_FILENAME)
    pygr.plot(x, y)
    gr.endgraphics()
    with open(GRAPHICS_FILENAME, "rb") as f:
        graphics_data = f.read()
    base64_encoded_graphics_data = b64encode(graphics_data)
    with open(GRAPHICS_FILENAME, "wb") as f:
        f.write(base64_encoded_graphics_data)
Exemplo n.º 2
0
def plot(variable):
    pygr.plot(variable, ylim=(0.9, 1.7), accelerate=True)
Exemplo n.º 3
0
#!/usr/bin/env python
"""
Plot a function with the use of gr
"""

import time

from gr.pygr import plot

x = [-3.3 + t * 0.1 for t in range(66)]
y = [t**5 - 13 * t**3 + 36 * t for t in x]
plot(x, y)
Exemplo n.º 4
0
#example of plotting with gr library
from gr import pygr
from numpy import *
x = list(i for i in range(10))
y = [sin(i) for i in range(10)]
pygr.plot(x, y)
Exemplo n.º 5
0
from gr import pygr
pygr.plot(list(x**2 for x in range(100)))
Exemplo n.º 6
0
def plot(variable):
    pygr.plot(variable,ylim=(-0.15,0.15),accelerate=True)
Exemplo n.º 7
0
from time import sleep
import os

os.environ["GKS_WSTYPE"] = "gksqt"

num_frames = 200

x = arange(0, 2 * pi, 0.01)

# create an animation using GR

from gr.pygr import plot

tstart = timer()
for i in range(num_frames):
    plot(x, sin(x + i / 10.0))
    sleep(0.0001)

fps_gr = int(num_frames / (timer() - tstart))
print('fps  (GR): %4d' % fps_gr)

# create the same animation using matplotlib

from matplotlib.pyplot import plot, draw, pause

tstart = timer()
line, = plot(x, sin(x))
for i in range(num_frames):
    line.set_ydata(sin(x + i / 10.0))
    draw()
    pause(0.0001)
import gr
from gr.pygr import plot
from math import pi
import numpy as np

L = 5.0
x = np.linspace(0, L, 100)
y1 = np.sin(2 * pi * x / L)
y2 = np.cos(2 * pi * x / L)

gr.beginprint("TEMP_08.pdf")
plt = plot(x, y1, x, y2)
gr.endprint()
Exemplo n.º 9
0
if len(sys.argv) > 1:
    dev = sys.argv[1]
else:
    dev = 'ps'

x = np.arange(0, 2 * np.pi, 0.01)

# create an animation using GR

from gr.pygr import plot

tstart = timer()
os.environ["GKS_WSTYPE"] = dev
for i in range(1, 100):
    plot(x, np.sin(x + i / 10.0))
    if i % 2 == 0:
        print('.', end="")
        sys.stdout.flush()

fps_gr = int(100 / (timer() - tstart))
print('fps  (GR): %4d' % fps_gr)

# create the same animation using matplotlib

import matplotlib
matplotlib.use(dev)

import matplotlib.pyplot as plt

tstart = timer()