1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
#! /usr/bin/env python
from __future__ import print_function
from openturns import *
from math import *
import os
TESTPREAMBLE()
try:
maxPoint = 101
xMin = -2.0 * pi
xMax = 2.0 * pi
data = NumericalSample(maxPoint, 2)
for i in range(maxPoint):
x = xMin + (xMax - xMin) * i / (maxPoint - 1.0)
data[i, 0] = x
data[i, 1] = sin(x)
sinGraph = Graph('Sin function', 'x', 'y', True, 'topright')
sinGraph.add(Curve(data, 'red', 'solid', 2, 'sin'))
# Test export to all formats
sinGraph.draw('sinGraph_ALL', 640, 480, GraphImplementation.ALL)
list(map(lambda ext: os.remove('sinGraph_ALL' + ext),
['.eps', '.png', '.fig', '.pdf']))
# Test export to PNG format
sinGraph.draw('sinGraph.png', 640, 480, GraphImplementation.PNG)
os.remove('sinGraph.png')
# Test export to EPS format
sinGraph.draw('sinGraph_EPS_PDF', 640, 480,
GraphImplementation.EPS | GraphImplementation.PDF)
os.remove('sinGraph_EPS_PDF.eps')
os.remove('sinGraph_EPS_PDF.pdf')
# Test export to FIG format
sinGraph.draw('sinGraph', 640, 480, GraphImplementation.FIG)
os.remove('sinGraph.fig')
except:
import sys
print('t_Graph_export.py', sys.exc_info()[0], sys.exc_info()[1])
|