File: t_Curve_std.py

package info (click to toggle)
openturns 1.24-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 66,204 kB
  • sloc: cpp: 256,662; python: 63,381; ansic: 4,414; javascript: 406; sh: 180; xml: 164; yacc: 123; makefile: 98; lex: 55
file content (45 lines) | stat: -rwxr-xr-x 1,016 bytes parent folder | download | duplicates (2)
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
39
40
41
42
43
44
45
#! /usr/bin/env python

import openturns as ot

ot.TESTPREAMBLE()

# Generate the data for the curves to be drawn
size = 50
cursor = ot.Point(2)

# curve y = 2x for x in [-25]
data1 = ot.Sample(size, 2)
# curve y = x*x for x in [-11]
data2 = ot.Sample(size, 2)

for i in range(size):
    tmp = 7.0 * i / size + 2
    cursor[0] = tmp
    cursor[1] = 2 * tmp
    data1[i] = cursor

    tmp = 9.0 * i / size + 1
    cursor[0] = tmp
    cursor[1] = tmp * tmp - (tmp - 5) * tmp * tmp / 60
    data2[i] = cursor

# Create an empty graph
myGraph = ot.Graph("Some curves", "x1", "x2", True, "topright")

# Create the first curve
myCurve1 = ot.Curve(data1, "blue", "dashed", 2, "linear function")

# Then, draw it
myGraph.add(myCurve1)

# Check that the correct files have been generated by computing their
# checksum

# Create the second curve
myCurve2 = ot.Curve(data2, "red", "solid", 2, "polynomial function")

# Add it to the graph and draw everything
myGraph.add(myCurve2)
for i in range(4):
    myGraph.setLogScale(i)