-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnew file template.py
More file actions
45 lines (33 loc) · 1.09 KB
/
new file template.py
File metadata and controls
45 lines (33 loc) · 1.09 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
40
41
42
43
44
45
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created Date:
Author: Leonardo Del Bino
Description of the script
Copyright (c) 2023 Akhetonics GmbH
'''
import numpy as np
import matplotlib.pyplot as plt
class MyClass:
def __init__(self, attribute):
self.attribute = attribute
def my_method(self):
print(f"The attribute of the class is: {self.attribute}")
if __name__ == "__main__":
# Prepare the figure and axis for plotting
fig, ax = plt.subplots()
# Create an instance of the class and call the method
my_instance = MyClass("example_attribute")
my_instance.my_method()
# For loop using enumerate example
my_list = ["item1", "item2", "item3"]
for i, item in enumerate(my_list):
print(f"Index: {i}, Item: {item}")
# Plot example
x = np.linspace(0, 2*np.pi, 100)
y = np.sin(x)
ln = ax.plot(x, y) #also save it as a line, just in case
plt.tight_layout()
fig.savefig('plot.png', dpi=600, bbox_inches='tight', pad_inches=0)
#fig.savefig('plot.pdf', dpi=600, bbox_inches='tight', pad_inches=0)
plt.show()