-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraph_test.py
More file actions
39 lines (28 loc) · 1.33 KB
/
Copy pathgraph_test.py
File metadata and controls
39 lines (28 loc) · 1.33 KB
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
# An example of Graph2D instantiation. It draws one or several datasets on
# one canvas and is useful for displaying numerical functions
import plot_data
from plot_data.colors import *
import numpy as np
k = 0
T1 = np.linspace(1, 20, 20)
I1 = [t ** 2 for t in T1]
elements1 = []
for k in range(len(T1)):
elements1.append({'time': T1[k], 'electric current': I1[k]})
dataset1 = plot_data.Dataset(elements=elements1, name='I1 = f(t)')
# The previous line instantiates a dataset with limited arguments but
# several customizations are available
point_style = plot_data.PointStyle(color_fill=RED, color_stroke=BLACK)
edge_style = plot_data.EdgeStyle(color_stroke=BLUE, dashline=[10, 5])
custom_dataset = plot_data.Dataset(elements=elements1, name='I = f(t)',
point_style=point_style,
edge_style=edge_style)
# Now let's create another dataset for the purpose of this exercice
T2 = np.linspace(1, 20, 100)
I2 = [100*(2+np.cos(t)) for t in T2]
elements2 = []
for k in range(1, len(T2)):
elements2.append({'time': T2[k], 'electric current': I2[k]})
dataset2 = plot_data.Dataset(elements=elements2, name='I2 = f(t)')
graph2d = plot_data.Graph2D(graphs=[dataset2], log_scale_x=True, log_scale_y=True,
x_variable='time', y_variable='electric current')