File: t_Graph_mix.py

package info (click to toggle)
openturns 1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 38,588 kB
  • ctags: 26,495
  • sloc: cpp: 144,032; python: 26,855; ansic: 7,868; sh: 419; makefile: 263; yacc: 123; lex: 44
file content (109 lines) | stat: -rwxr-xr-x 2,522 bytes parent folder | download
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#! /usr/bin/env python

from __future__ import print_function
from openturns import *

TESTPREAMBLE()
RandomGenerator.SetSeed(0)

try:
    # Instanciate one distribution object
    dim = 2
    meanPoint = NumericalPoint(dim, 1.0)
    meanPoint[0] = 12.0
    meanPoint[1] = 5.0
    sigma = NumericalPoint(dim, 1.0)
    sigma[0] = 3.0
    sigma[1] = 1.0
    R = CorrelationMatrix(dim)
    for i in range(1, dim):
        R[i, i - 1] = 0.75

    distribution = Normal(meanPoint, sigma, R)

    # Test for sampling
    size = 200
    sample = distribution.getSample(size)
    tmp = NumericalSample(2, NumericalPoint(2))
    tmp[0, 0] = sample.getMin()[0]
    tmp[0, 1] = meanPoint[1] - sigma[1] / sigma[0] * (meanPoint[0] - tmp[0, 0])
    tmp[1, 0] = sample.getMax()[0]
    tmp[1, 1] = meanPoint[1] - sigma[1] / sigma[0] * (meanPoint[0] - tmp[1, 0])

    # Create the cloud
    myCloud = Cloud(sample, "blue", "fsquare", "Normal Cloud")

    # Create the line
    myLine = Curve(tmp, "red", "solid", 2, "Line")

    data = NumericalPoint(0)

    palette = Description()
    labels = Description()

    data.add(5665855)
    labels.add("Candidate1")
    palette.add("blue")

    data.add(4804713)
    labels.add("Candidate2")
    palette.add("white")

    data.add(4610113)
    labels.add("Candidate3")
    palette.add("pink")

    data.add(1949170)
    labels.add("Candidate4")
    palette.add("yellow")

    data.add(1630045)
    labels.add("Candidate5")
    palette.add("red")

    data.add(1518528)
    labels.add("Candidate6")
    palette.add("ivory")

    data.add(1495724)
    labels.add("Candidate7")
    palette.add("green")

    data.add(1210562)
    labels.add("Candidate8")
    palette.add("orange")

    data.add(1204689)
    labels.add("Candidate9")
    palette.add("maroon")

    data.add(1113484)
    labels.add("Candidate10")
    palette.add("violet")

    data.add(3295588)
    labels.add("cumul candidates < 3.5% ")
    palette.add("purple")

    centre = NumericalPoint(2)
    centre[0] = 7.0
    centre[1] = 10.0

    # Create the piechart
    myPie = Pie(data, labels, centre, 4, palette)

    # Create an empty graph
    myGraph = Graph("Cloud/line/pie", "x1", "x2", True, "topright", 1.0)

    # Then, draw it
    myGraph.add(myCloud)
    myGraph.add(myLine)
    myGraph.add(myPie)
    myGraph.draw("Graph_mix_OT", 640, 480)

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

except:
    import sys
    print("t_Graph_mix.py", sys.exc_info()[0], sys.exc_info()[1])