cloudbian-helper 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cloudbian_helper-0.1.0/PKG-INFO +13 -0
- cloudbian_helper-0.1.0/README.md +1 -0
- cloudbian_helper-0.1.0/pyproject.toml +19 -0
- cloudbian_helper-0.1.0/src/cloudbian_helper/__init__.py +0 -0
- cloudbian_helper-0.1.0/src/cloudbian_helper/graphics.adoc +337 -0
- cloudbian_helper-0.1.0/src/cloudbian_helper/graphics.py +602 -0
- cloudbian_helper-0.1.0/src/cloudbian_helper/password.py +14 -0
- cloudbian_helper-0.1.0/src/cloudbian_helper/test.py +10 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cloudbian-helper
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary:
|
|
5
|
+
Author: CloudberryPiTechnologies
|
|
6
|
+
Author-email: cloudberrypi1@outlook.com
|
|
7
|
+
Requires-Python: >=3.14
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
10
|
+
Requires-Dist: matplotlib (>=3.10.9,<4.0.0)
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
|
|
13
|
+
# Oops! Project under development
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Oops! Project under development
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "cloudbian-helper"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = ""
|
|
5
|
+
authors = [
|
|
6
|
+
{name = "CloudberryPiTechnologies",email = "cloudberrypi1@outlook.com"}
|
|
7
|
+
]
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
requires-python = ">=3.14"
|
|
10
|
+
dependencies = [
|
|
11
|
+
"matplotlib (>=3.10.9,<4.0.0)"
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
[tool.poetry]
|
|
15
|
+
packages = [{include = "cloudbian_helper", from = "src"}]
|
|
16
|
+
|
|
17
|
+
[build-system]
|
|
18
|
+
requires = ["poetry-core>=2.0.0,<3.0.0"]
|
|
19
|
+
build-backend = "poetry.core.masonry.api"
|
|
File without changes
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
= Graphics Module
|
|
2
|
+
:toc:
|
|
3
|
+
:authors: Cloudberry Pi Foundations
|
|
4
|
+
|
|
5
|
+
A simple Python library that makes data visualization easier using Matplotlib with a clean API and built-in 2D + 3D graphs.
|
|
6
|
+
|
|
7
|
+
== Example Usage
|
|
8
|
+
|
|
9
|
+
[source,python]
|
|
10
|
+
----
|
|
11
|
+
from graphs import Graphs
|
|
12
|
+
|
|
13
|
+
g = Graphs(
|
|
14
|
+
title="Animal Balance",
|
|
15
|
+
theme="ggplot"
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
g.pie_chart(
|
|
19
|
+
labels=["Humans", "Animals", "Insects"],
|
|
20
|
+
values=[80, 50, 40]
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
g.bar_graph(
|
|
24
|
+
labels=["Humans", "Animals", "Insects"],
|
|
25
|
+
values=[80, 50, 40]
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
g.horizontal_bar_graph(
|
|
29
|
+
labels=["Humans", "Animals", "Insects"],
|
|
30
|
+
values=[80, 50, 40]
|
|
31
|
+
)
|
|
32
|
+
----
|
|
33
|
+
|
|
34
|
+
== Installation
|
|
35
|
+
|
|
36
|
+
[source,bash]
|
|
37
|
+
----
|
|
38
|
+
pip install matplotlib numpy
|
|
39
|
+
----
|
|
40
|
+
|
|
41
|
+
== Creating a Graph Object
|
|
42
|
+
|
|
43
|
+
[source,python]
|
|
44
|
+
----
|
|
45
|
+
from graphs import Graphs
|
|
46
|
+
|
|
47
|
+
g = Graphs(
|
|
48
|
+
title="My Graph",
|
|
49
|
+
figsize=(8, 5),
|
|
50
|
+
theme="default",
|
|
51
|
+
grid=True
|
|
52
|
+
)
|
|
53
|
+
----
|
|
54
|
+
|
|
55
|
+
=== Parameters
|
|
56
|
+
|
|
57
|
+
* title → Graph title
|
|
58
|
+
* figsize → Figure size
|
|
59
|
+
* theme → Matplotlib style (e.g. ggplot, default)
|
|
60
|
+
* grid → Enable grid (True/False)
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
== 2D GRAPHS
|
|
65
|
+
|
|
66
|
+
=== Line Graph
|
|
67
|
+
|
|
68
|
+
[source,python]
|
|
69
|
+
----
|
|
70
|
+
g.line_graph(
|
|
71
|
+
x=[1,2,3,4],
|
|
72
|
+
y=[10,20,30,40]
|
|
73
|
+
)
|
|
74
|
+
----
|
|
75
|
+
|
|
76
|
+
=== Bar Graph
|
|
77
|
+
|
|
78
|
+
[source,python]
|
|
79
|
+
----
|
|
80
|
+
g.bar_graph(
|
|
81
|
+
labels=["A","B","C"],
|
|
82
|
+
values=[10,20,30]
|
|
83
|
+
)
|
|
84
|
+
----
|
|
85
|
+
|
|
86
|
+
=== Horizontal Bar Graph
|
|
87
|
+
|
|
88
|
+
[source,python]
|
|
89
|
+
----
|
|
90
|
+
g.horizontal_bar_graph(
|
|
91
|
+
labels=["A","B","C"],
|
|
92
|
+
values=[10,20,30]
|
|
93
|
+
)
|
|
94
|
+
----
|
|
95
|
+
|
|
96
|
+
=== Scatter Graph
|
|
97
|
+
|
|
98
|
+
[source,python]
|
|
99
|
+
----
|
|
100
|
+
g.scatter_graph(
|
|
101
|
+
x=[1,2,3],
|
|
102
|
+
y=[4,5,6]
|
|
103
|
+
)
|
|
104
|
+
----
|
|
105
|
+
|
|
106
|
+
=== Pie Chart
|
|
107
|
+
|
|
108
|
+
[source,python]
|
|
109
|
+
----
|
|
110
|
+
g.pie_chart(
|
|
111
|
+
labels=["A","B","C"],
|
|
112
|
+
values=[50,30,20]
|
|
113
|
+
)
|
|
114
|
+
----
|
|
115
|
+
|
|
116
|
+
=== Histogram
|
|
117
|
+
|
|
118
|
+
[source,python]
|
|
119
|
+
----
|
|
120
|
+
g.histogram(
|
|
121
|
+
data=[1,2,2,3,4,5]
|
|
122
|
+
)
|
|
123
|
+
----
|
|
124
|
+
|
|
125
|
+
=== Area Graph
|
|
126
|
+
|
|
127
|
+
[source,python]
|
|
128
|
+
----
|
|
129
|
+
g.area_graph(
|
|
130
|
+
x=[1,2,3,4],
|
|
131
|
+
y=[10,20,30,40]
|
|
132
|
+
)
|
|
133
|
+
----
|
|
134
|
+
|
|
135
|
+
=== Step Graph
|
|
136
|
+
|
|
137
|
+
[source,python]
|
|
138
|
+
----
|
|
139
|
+
g.step_graph(
|
|
140
|
+
x=[1,2,3],
|
|
141
|
+
y=[10,20,30]
|
|
142
|
+
)
|
|
143
|
+
----
|
|
144
|
+
|
|
145
|
+
=== Stem Graph
|
|
146
|
+
|
|
147
|
+
[source,python]
|
|
148
|
+
----
|
|
149
|
+
g.stem_graph(
|
|
150
|
+
x=[1,2,3],
|
|
151
|
+
y=[10,20,30]
|
|
152
|
+
)
|
|
153
|
+
----
|
|
154
|
+
|
|
155
|
+
=== Box Plot
|
|
156
|
+
|
|
157
|
+
[source,python]
|
|
158
|
+
----
|
|
159
|
+
g.box_plot([1,2,3,4,5,6])
|
|
160
|
+
----
|
|
161
|
+
|
|
162
|
+
=== Violin Plot
|
|
163
|
+
|
|
164
|
+
[source,python]
|
|
165
|
+
----
|
|
166
|
+
g.violin_plot([1,2,3,4,5,6])
|
|
167
|
+
----
|
|
168
|
+
|
|
169
|
+
=== Heatmap
|
|
170
|
+
|
|
171
|
+
[source,python]
|
|
172
|
+
----
|
|
173
|
+
g.heatmap([
|
|
174
|
+
[1,2,3],
|
|
175
|
+
[4,5,6],
|
|
176
|
+
[7,8,9]
|
|
177
|
+
])
|
|
178
|
+
----
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
== REALTIME GRAPH
|
|
183
|
+
|
|
184
|
+
[source,python]
|
|
185
|
+
----
|
|
186
|
+
import random
|
|
187
|
+
|
|
188
|
+
def data():
|
|
189
|
+
return random.randint(1,100)
|
|
190
|
+
|
|
191
|
+
g.realtime_graph(data)
|
|
192
|
+
----
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
== SAVE GRAPH
|
|
197
|
+
|
|
198
|
+
[source,python]
|
|
199
|
+
----
|
|
200
|
+
g.save("graph.png")
|
|
201
|
+
----
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
== 3D GRAPHS (VALUE-ONLY API)
|
|
206
|
+
|
|
207
|
+
All 3D graphs use ONLY values (no x/y/z required). The library generates structure automatically.
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
=== 3D Bar Graph
|
|
212
|
+
|
|
213
|
+
[source,python]
|
|
214
|
+
----
|
|
215
|
+
g.bar_3d_graph(
|
|
216
|
+
labels=["A","B","C"],
|
|
217
|
+
values=[10,20,30]
|
|
218
|
+
)
|
|
219
|
+
----
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
=== 3D Line Graph (True 3D)
|
|
224
|
+
|
|
225
|
+
[source,python]
|
|
226
|
+
----
|
|
227
|
+
g.line_3d_graph(
|
|
228
|
+
values=[5,10,15,20],
|
|
229
|
+
style="linear"
|
|
230
|
+
)
|
|
231
|
+
----
|
|
232
|
+
|
|
233
|
+
==== Styles
|
|
234
|
+
|
|
235
|
+
* linear
|
|
236
|
+
* wave
|
|
237
|
+
* spiral
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
=== 3D Scatter Graph
|
|
242
|
+
|
|
243
|
+
[source,python]
|
|
244
|
+
----
|
|
245
|
+
g.scatter_3d_graph(
|
|
246
|
+
values=[1,2,3,4,5]
|
|
247
|
+
)
|
|
248
|
+
----
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
=== 3D Surface Graph
|
|
253
|
+
|
|
254
|
+
[source,python]
|
|
255
|
+
----
|
|
256
|
+
g.surface_3d_graph(
|
|
257
|
+
values=[3,6,2,8,5]
|
|
258
|
+
)
|
|
259
|
+
----
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
=== 3D Wireframe Graph
|
|
264
|
+
|
|
265
|
+
[source,python]
|
|
266
|
+
----
|
|
267
|
+
g.wireframe_3d_graph(
|
|
268
|
+
values=[3,6,2,8,5]
|
|
269
|
+
)
|
|
270
|
+
----
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
=== 3D Contour Graph
|
|
275
|
+
|
|
276
|
+
[source,python]
|
|
277
|
+
----
|
|
278
|
+
g.contour_3d_graph(
|
|
279
|
+
values=[3,6,2,8,5]
|
|
280
|
+
)
|
|
281
|
+
----
|
|
282
|
+
|
|
283
|
+
---
|
|
284
|
+
|
|
285
|
+
=== 🌄 Mountain Graph (Terrain Style)
|
|
286
|
+
|
|
287
|
+
A smooth 3D landscape-style graph.
|
|
288
|
+
|
|
289
|
+
[source,python]
|
|
290
|
+
----
|
|
291
|
+
g.mountain_3d_graph(
|
|
292
|
+
values=[3,8,2,10,6,12]
|
|
293
|
+
)
|
|
294
|
+
----
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
== Themes
|
|
299
|
+
|
|
300
|
+
Available Matplotlib themes:
|
|
301
|
+
|
|
302
|
+
* default
|
|
303
|
+
* ggplot
|
|
304
|
+
* dark_background
|
|
305
|
+
* seaborn-v0_8
|
|
306
|
+
* classic
|
|
307
|
+
* bmh
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
== Full Example
|
|
312
|
+
|
|
313
|
+
[source,python]
|
|
314
|
+
----
|
|
315
|
+
from graphs import Graphs
|
|
316
|
+
|
|
317
|
+
g = Graphs(
|
|
318
|
+
title="Sales Data",
|
|
319
|
+
theme="ggplot"
|
|
320
|
+
)
|
|
321
|
+
|
|
322
|
+
g.bar_graph(
|
|
323
|
+
labels=["India","USA","China"],
|
|
324
|
+
values=[100,200,300]
|
|
325
|
+
)
|
|
326
|
+
|
|
327
|
+
g.bar_3d_graph(
|
|
328
|
+
labels=["India","USA","China"],
|
|
329
|
+
values=[100,200,300]
|
|
330
|
+
)
|
|
331
|
+
|
|
332
|
+
g.mountain_3d_graph(
|
|
333
|
+
values=[5,10,3,12,7]
|
|
334
|
+
)
|
|
335
|
+
|
|
336
|
+
g.save("output.png")
|
|
337
|
+
----
|
|
@@ -0,0 +1,602 @@
|
|
|
1
|
+
"""Generate graphs using matplotlib only by entering simple commands
|
|
2
|
+
Example usage:
|
|
3
|
+
|
|
4
|
+
```python
|
|
5
|
+
|
|
6
|
+
from graphs import Graphs
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
g = Graphs(
|
|
10
|
+
title="Animal Balance",
|
|
11
|
+
|
|
12
|
+
theme="ggplot"
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
g.pie_chart(
|
|
16
|
+
labels=["Humans", "Animals", "Insects"],
|
|
17
|
+
|
|
18
|
+
values=[80, 50, 40]
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
g.bar_graph(
|
|
22
|
+
labels=["Humans", "Animals", "Insects"],
|
|
23
|
+
|
|
24
|
+
values=[80, 50, 40]
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
g.horizontal_bar_graph(
|
|
28
|
+
labels=["Humans", "Animals", "Insects"],
|
|
29
|
+
|
|
30
|
+
values=[80, 50, 40]
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
import matplotlib.pyplot as plt
|
|
38
|
+
from matplotlib.animation import FuncAnimation
|
|
39
|
+
from mpl_toolkits.mplot3d import Axes3D
|
|
40
|
+
from matplotlib.colors import LinearSegmentedColormap
|
|
41
|
+
from matplotlib.colors import LinearSegmentedColormap
|
|
42
|
+
import numpy as np
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class Graphs:
|
|
46
|
+
def __init__(
|
|
47
|
+
self,
|
|
48
|
+
title="Graph",
|
|
49
|
+
figsize=(8, 5),
|
|
50
|
+
theme="default",
|
|
51
|
+
grid=True
|
|
52
|
+
):
|
|
53
|
+
plt.style.use(theme)
|
|
54
|
+
self.figsize = figsize
|
|
55
|
+
self.title = title
|
|
56
|
+
self.grid = grid
|
|
57
|
+
|
|
58
|
+
# -------------------------
|
|
59
|
+
# LINE GRAPH
|
|
60
|
+
# -------------------------
|
|
61
|
+
def line_graph(
|
|
62
|
+
self,
|
|
63
|
+
x,
|
|
64
|
+
y,
|
|
65
|
+
color="blue",
|
|
66
|
+
marker="o",
|
|
67
|
+
linewidth=2,
|
|
68
|
+
xlabel="X",
|
|
69
|
+
ylabel="Y",
|
|
70
|
+
show=True
|
|
71
|
+
):
|
|
72
|
+
"""Draw a line graph."""
|
|
73
|
+
plt.figure(figsize=self.figsize)
|
|
74
|
+
plt.plot(
|
|
75
|
+
x,
|
|
76
|
+
y,
|
|
77
|
+
color=color,
|
|
78
|
+
marker=marker,
|
|
79
|
+
linewidth=linewidth
|
|
80
|
+
)
|
|
81
|
+
plt.title(self.title)
|
|
82
|
+
plt.xlabel(xlabel)
|
|
83
|
+
plt.ylabel(ylabel)
|
|
84
|
+
plt.grid(self.grid)
|
|
85
|
+
|
|
86
|
+
if show:
|
|
87
|
+
plt.show()
|
|
88
|
+
|
|
89
|
+
# -------------------------
|
|
90
|
+
# BAR GRAPH
|
|
91
|
+
# -------------------------
|
|
92
|
+
def bar_graph(
|
|
93
|
+
self,
|
|
94
|
+
labels,
|
|
95
|
+
values,
|
|
96
|
+
color="skyblue",
|
|
97
|
+
xlabel="Category",
|
|
98
|
+
ylabel="Value",
|
|
99
|
+
show=True
|
|
100
|
+
):
|
|
101
|
+
"""Draw a simple and basic bar graph."""
|
|
102
|
+
plt.figure(figsize=self.figsize)
|
|
103
|
+
plt.bar(labels, values, color=color)
|
|
104
|
+
|
|
105
|
+
plt.title(self.title)
|
|
106
|
+
plt.xlabel(xlabel)
|
|
107
|
+
plt.ylabel(ylabel)
|
|
108
|
+
|
|
109
|
+
if show:
|
|
110
|
+
plt.show()
|
|
111
|
+
|
|
112
|
+
# -------------------------
|
|
113
|
+
# HORIZONTAL BAR
|
|
114
|
+
# -------------------------
|
|
115
|
+
def horizontal_bar_graph(
|
|
116
|
+
self,
|
|
117
|
+
labels,
|
|
118
|
+
values,
|
|
119
|
+
color="green",
|
|
120
|
+
show=True
|
|
121
|
+
):
|
|
122
|
+
"""Draw a simple and basic horizontal bar graph."""
|
|
123
|
+
plt.figure(figsize=self.figsize)
|
|
124
|
+
plt.barh(labels, values, color=color)
|
|
125
|
+
plt.title(self.title)
|
|
126
|
+
|
|
127
|
+
if show:
|
|
128
|
+
plt.show()
|
|
129
|
+
|
|
130
|
+
# -------------------------
|
|
131
|
+
# SCATTER PLOT
|
|
132
|
+
# -------------------------
|
|
133
|
+
def scatter_graph(
|
|
134
|
+
self,
|
|
135
|
+
x,
|
|
136
|
+
y,
|
|
137
|
+
color="red",
|
|
138
|
+
size=50,
|
|
139
|
+
show=True
|
|
140
|
+
):
|
|
141
|
+
"""Draw a standard scatter graph using the x and y coordinates"""
|
|
142
|
+
plt.figure(figsize=self.figsize)
|
|
143
|
+
|
|
144
|
+
plt.scatter(
|
|
145
|
+
x,
|
|
146
|
+
y,
|
|
147
|
+
c=color,
|
|
148
|
+
s=size
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
plt.title(self.title)
|
|
152
|
+
plt.grid(self.grid)
|
|
153
|
+
|
|
154
|
+
if show:
|
|
155
|
+
plt.show()
|
|
156
|
+
|
|
157
|
+
# -------------------------
|
|
158
|
+
# PIE CHART
|
|
159
|
+
# -------------------------
|
|
160
|
+
def pie_chart(
|
|
161
|
+
self,
|
|
162
|
+
labels,
|
|
163
|
+
values,
|
|
164
|
+
autopct="%1.1f%%",
|
|
165
|
+
startangle=90,
|
|
166
|
+
show=True
|
|
167
|
+
):
|
|
168
|
+
"""Draw a color coded pie chart"""
|
|
169
|
+
plt.figure(figsize=self.figsize)
|
|
170
|
+
|
|
171
|
+
plt.pie(
|
|
172
|
+
values,
|
|
173
|
+
labels=labels,
|
|
174
|
+
autopct=autopct,
|
|
175
|
+
startangle=startangle
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
plt.title(self.title)
|
|
179
|
+
|
|
180
|
+
if show:
|
|
181
|
+
plt.show()
|
|
182
|
+
|
|
183
|
+
# -------------------------
|
|
184
|
+
# HISTOGRAM
|
|
185
|
+
# -------------------------
|
|
186
|
+
def histogram(
|
|
187
|
+
self,
|
|
188
|
+
data,
|
|
189
|
+
bins=10,
|
|
190
|
+
color="purple",
|
|
191
|
+
show=True
|
|
192
|
+
):
|
|
193
|
+
"""By using this command you can simly draw a histograph"""
|
|
194
|
+
plt.figure(figsize=self.figsize)
|
|
195
|
+
|
|
196
|
+
plt.hist(
|
|
197
|
+
data,
|
|
198
|
+
bins=bins,
|
|
199
|
+
color=color
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
plt.title(self.title)
|
|
203
|
+
|
|
204
|
+
if show:
|
|
205
|
+
plt.show()
|
|
206
|
+
|
|
207
|
+
# -------------------------
|
|
208
|
+
# AREA GRAPH
|
|
209
|
+
# -------------------------
|
|
210
|
+
def area_graph(
|
|
211
|
+
self,
|
|
212
|
+
x,
|
|
213
|
+
y,
|
|
214
|
+
color="cyan",
|
|
215
|
+
alpha=0.5,
|
|
216
|
+
show=True
|
|
217
|
+
):
|
|
218
|
+
"""Draw an area graph using this command. An example for usage is ```graph.area_graph(x=(12, 2), y=(1,12))```."""
|
|
219
|
+
plt.figure(figsize=self.figsize)
|
|
220
|
+
|
|
221
|
+
plt.fill_between(
|
|
222
|
+
x,
|
|
223
|
+
y,
|
|
224
|
+
color=color,
|
|
225
|
+
alpha=alpha
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
plt.title(self.title)
|
|
229
|
+
|
|
230
|
+
if show:
|
|
231
|
+
plt.show()
|
|
232
|
+
|
|
233
|
+
# -------------------------
|
|
234
|
+
# STEP GRAPH
|
|
235
|
+
# -------------------------
|
|
236
|
+
def step_graph(
|
|
237
|
+
self,
|
|
238
|
+
x,
|
|
239
|
+
y,
|
|
240
|
+
color="orange",
|
|
241
|
+
show=True
|
|
242
|
+
):
|
|
243
|
+
"""Draw a simple step graph"""
|
|
244
|
+
plt.figure(figsize=self.figsize)
|
|
245
|
+
|
|
246
|
+
plt.step(
|
|
247
|
+
x,
|
|
248
|
+
y,
|
|
249
|
+
color=color
|
|
250
|
+
)
|
|
251
|
+
|
|
252
|
+
plt.title(self.title)
|
|
253
|
+
|
|
254
|
+
if show:
|
|
255
|
+
plt.show()
|
|
256
|
+
|
|
257
|
+
# -------------------------
|
|
258
|
+
# STEM GRAPH
|
|
259
|
+
# -------------------------
|
|
260
|
+
def stem_graph(
|
|
261
|
+
self,
|
|
262
|
+
x,
|
|
263
|
+
y,
|
|
264
|
+
show=True
|
|
265
|
+
):
|
|
266
|
+
"""Draw a simple stem graph."""
|
|
267
|
+
plt.figure(figsize=self.figsize)
|
|
268
|
+
|
|
269
|
+
plt.stem(x, y)
|
|
270
|
+
|
|
271
|
+
plt.title(self.title)
|
|
272
|
+
|
|
273
|
+
if show:
|
|
274
|
+
plt.show()
|
|
275
|
+
|
|
276
|
+
# -------------------------
|
|
277
|
+
# BOX PLOT
|
|
278
|
+
# -------------------------
|
|
279
|
+
def box_plot(
|
|
280
|
+
self,
|
|
281
|
+
data,
|
|
282
|
+
show=True
|
|
283
|
+
):
|
|
284
|
+
"""Draw a simple box plot graph"""
|
|
285
|
+
plt.figure(figsize=self.figsize)
|
|
286
|
+
|
|
287
|
+
plt.boxplot(data)
|
|
288
|
+
|
|
289
|
+
plt.title(self.title)
|
|
290
|
+
|
|
291
|
+
if show:
|
|
292
|
+
plt.show()
|
|
293
|
+
|
|
294
|
+
# -------------------------
|
|
295
|
+
# VIOLIN PLOT
|
|
296
|
+
# -------------------------
|
|
297
|
+
def violin_plot(
|
|
298
|
+
self,
|
|
299
|
+
data,
|
|
300
|
+
show=True
|
|
301
|
+
):
|
|
302
|
+
"""Draw a violin graph"""
|
|
303
|
+
plt.figure(figsize=self.figsize)
|
|
304
|
+
|
|
305
|
+
plt.violinplot(data)
|
|
306
|
+
|
|
307
|
+
plt.title(self.title)
|
|
308
|
+
|
|
309
|
+
if show:
|
|
310
|
+
plt.show()
|
|
311
|
+
|
|
312
|
+
# -------------------------
|
|
313
|
+
# HEATMAP
|
|
314
|
+
# -------------------------
|
|
315
|
+
def heatmap(
|
|
316
|
+
self,
|
|
317
|
+
matrix,
|
|
318
|
+
cmap="viridis",
|
|
319
|
+
color=None,
|
|
320
|
+
show=True
|
|
321
|
+
):
|
|
322
|
+
plt.figure(figsize=self.figsize)
|
|
323
|
+
|
|
324
|
+
heatmap_cmap = cmap
|
|
325
|
+
|
|
326
|
+
if color is not None:
|
|
327
|
+
heatmap_cmap = LinearSegmentedColormap.from_list(
|
|
328
|
+
f"{color}_heatmap",
|
|
329
|
+
["white", color]
|
|
330
|
+
)
|
|
331
|
+
|
|
332
|
+
plt.imshow(matrix, cmap=heatmap_cmap)
|
|
333
|
+
|
|
334
|
+
plt.colorbar()
|
|
335
|
+
plt.title(self.title)
|
|
336
|
+
|
|
337
|
+
if show:
|
|
338
|
+
plt.show()
|
|
339
|
+
# -------------------------
|
|
340
|
+
# REALTIME LINE GRAPH
|
|
341
|
+
# -------------------------
|
|
342
|
+
def realtime_graph(
|
|
343
|
+
self,
|
|
344
|
+
data_function,
|
|
345
|
+
interval=100
|
|
346
|
+
):
|
|
347
|
+
"""Draw a realtime graph"""
|
|
348
|
+
fig, ax = plt.subplots()
|
|
349
|
+
|
|
350
|
+
x_data = []
|
|
351
|
+
y_data = []
|
|
352
|
+
|
|
353
|
+
line, = ax.plot([], [])
|
|
354
|
+
|
|
355
|
+
def animate(frame):
|
|
356
|
+
value = data_function()
|
|
357
|
+
|
|
358
|
+
x_data.append(len(x_data))
|
|
359
|
+
y_data.append(value)
|
|
360
|
+
|
|
361
|
+
line.set_data(x_data, y_data)
|
|
362
|
+
|
|
363
|
+
ax.relim()
|
|
364
|
+
ax.autoscale_view()
|
|
365
|
+
|
|
366
|
+
return line,
|
|
367
|
+
|
|
368
|
+
FuncAnimation(
|
|
369
|
+
fig,
|
|
370
|
+
animate,
|
|
371
|
+
interval=interval,
|
|
372
|
+
cache_frame_data=False
|
|
373
|
+
)
|
|
374
|
+
|
|
375
|
+
plt.show()
|
|
376
|
+
|
|
377
|
+
# -------------------------
|
|
378
|
+
# SAVE FIGURE
|
|
379
|
+
# -------------------------
|
|
380
|
+
def save(
|
|
381
|
+
self,
|
|
382
|
+
filename="graph.png",
|
|
383
|
+
dpi=300
|
|
384
|
+
):
|
|
385
|
+
"""Save the graph to a file"""
|
|
386
|
+
plt.savefig(
|
|
387
|
+
filename,
|
|
388
|
+
dpi=dpi,
|
|
389
|
+
bbox_inches="tight"
|
|
390
|
+
)
|
|
391
|
+
|
|
392
|
+
# -------------------------
|
|
393
|
+
# 3D BAR GRAPH
|
|
394
|
+
# -------------------------
|
|
395
|
+
def bar_3d_graph(
|
|
396
|
+
self,
|
|
397
|
+
labels,
|
|
398
|
+
values,
|
|
399
|
+
color="skyblue",
|
|
400
|
+
show=True
|
|
401
|
+
):
|
|
402
|
+
"""Draw a 3D bar graph using only values."""
|
|
403
|
+
|
|
404
|
+
fig = plt.figure(figsize=self.figsize)
|
|
405
|
+
ax = fig.add_subplot(111, projection="3d")
|
|
406
|
+
|
|
407
|
+
x = np.arange(len(values))
|
|
408
|
+
y = np.zeros(len(values))
|
|
409
|
+
z = np.zeros(len(values))
|
|
410
|
+
|
|
411
|
+
dx = np.ones(len(values)) * 0.6
|
|
412
|
+
dy = np.ones(len(values)) * 0.6
|
|
413
|
+
dz = values
|
|
414
|
+
|
|
415
|
+
ax.bar3d(x, y, z, dx, dy, dz, color=color, shade=True)
|
|
416
|
+
|
|
417
|
+
ax.set_title(self.title)
|
|
418
|
+
ax.set_xlabel("Index")
|
|
419
|
+
ax.set_ylabel("")
|
|
420
|
+
ax.set_zlabel("Value")
|
|
421
|
+
|
|
422
|
+
if show:
|
|
423
|
+
plt.show()
|
|
424
|
+
|
|
425
|
+
# -------------------------
|
|
426
|
+
# 3D LINE GRAPH
|
|
427
|
+
# -------------------------
|
|
428
|
+
def line_3d_graph(
|
|
429
|
+
self,
|
|
430
|
+
values,
|
|
431
|
+
color="blue",
|
|
432
|
+
linewidth=2,
|
|
433
|
+
style="linear",
|
|
434
|
+
show=True
|
|
435
|
+
):
|
|
436
|
+
"""True 3D line graph using only values."""
|
|
437
|
+
|
|
438
|
+
fig = plt.figure(figsize=self.figsize)
|
|
439
|
+
ax = fig.add_subplot(111, projection="3d")
|
|
440
|
+
|
|
441
|
+
x = np.arange(len(values))
|
|
442
|
+
|
|
443
|
+
if style == "linear":
|
|
444
|
+
y = np.arange(len(values)) # depth axis
|
|
445
|
+
elif style == "wave":
|
|
446
|
+
y = np.sin(x / 2) # wave motion depth
|
|
447
|
+
elif style == "spiral":
|
|
448
|
+
y = np.cos(x / 2) # spiral-like variation
|
|
449
|
+
else:
|
|
450
|
+
y = np.arange(len(values))
|
|
451
|
+
|
|
452
|
+
z = np.array(values)
|
|
453
|
+
|
|
454
|
+
ax.plot(x, y, z, color=color, linewidth=linewidth)
|
|
455
|
+
|
|
456
|
+
ax.set_title(self.title)
|
|
457
|
+
ax.set_xlabel("Index (X)")
|
|
458
|
+
ax.set_ylabel("Depth (Y)")
|
|
459
|
+
ax.set_zlabel("Value (Z)")
|
|
460
|
+
|
|
461
|
+
if show:
|
|
462
|
+
plt.show()
|
|
463
|
+
# -------------------------
|
|
464
|
+
# 3D SCATTER GRAPH
|
|
465
|
+
# -------------------------
|
|
466
|
+
def scatter_3d_graph(
|
|
467
|
+
self,
|
|
468
|
+
values,
|
|
469
|
+
color="red",
|
|
470
|
+
size=50,
|
|
471
|
+
show=True
|
|
472
|
+
):
|
|
473
|
+
"""Draw a 3D scatter graph using only values."""
|
|
474
|
+
|
|
475
|
+
fig = plt.figure(figsize=self.figsize)
|
|
476
|
+
ax = fig.add_subplot(111, projection="3d")
|
|
477
|
+
|
|
478
|
+
x = np.arange(len(values))
|
|
479
|
+
y = np.random.rand(len(values))
|
|
480
|
+
z = np.array(values)
|
|
481
|
+
|
|
482
|
+
ax.scatter(x, y, z, c=color, s=size)
|
|
483
|
+
|
|
484
|
+
ax.set_title(self.title)
|
|
485
|
+
ax.set_xlabel("Index")
|
|
486
|
+
ax.set_ylabel("Spread")
|
|
487
|
+
ax.set_zlabel("Value")
|
|
488
|
+
|
|
489
|
+
if show:
|
|
490
|
+
plt.show()
|
|
491
|
+
|
|
492
|
+
# -------------------------
|
|
493
|
+
# 3D SURFACE GRAPH
|
|
494
|
+
# -------------------------
|
|
495
|
+
def surface_3d_graph(
|
|
496
|
+
self,
|
|
497
|
+
values,
|
|
498
|
+
cmap="viridis",
|
|
499
|
+
show=True
|
|
500
|
+
):
|
|
501
|
+
"""Draw a 3D surface graph from values."""
|
|
502
|
+
|
|
503
|
+
fig = plt.figure(figsize=self.figsize)
|
|
504
|
+
ax = fig.add_subplot(111, projection="3d")
|
|
505
|
+
|
|
506
|
+
x = np.arange(len(values))
|
|
507
|
+
y = np.arange(len(values))
|
|
508
|
+
|
|
509
|
+
X, Y = np.meshgrid(x, y)
|
|
510
|
+
Z = np.outer(values, np.ones(len(values)))
|
|
511
|
+
|
|
512
|
+
ax.plot_surface(X, Y, Z, cmap=cmap)
|
|
513
|
+
|
|
514
|
+
ax.set_title(self.title)
|
|
515
|
+
|
|
516
|
+
if show:
|
|
517
|
+
plt.show()
|
|
518
|
+
|
|
519
|
+
# -------------------------
|
|
520
|
+
# 3D WIREFRAME GRAPH
|
|
521
|
+
# -------------------------
|
|
522
|
+
def wireframe_3d_graph(
|
|
523
|
+
self,
|
|
524
|
+
values,
|
|
525
|
+
color="black",
|
|
526
|
+
show=True
|
|
527
|
+
):
|
|
528
|
+
"""Draw a 3D wireframe graph."""
|
|
529
|
+
|
|
530
|
+
fig = plt.figure(figsize=self.figsize)
|
|
531
|
+
ax = fig.add_subplot(111, projection="3d")
|
|
532
|
+
|
|
533
|
+
x = np.arange(len(values))
|
|
534
|
+
y = np.arange(len(values))
|
|
535
|
+
|
|
536
|
+
X, Y = np.meshgrid(x, y)
|
|
537
|
+
Z = np.outer(values, np.ones(len(values)))
|
|
538
|
+
|
|
539
|
+
ax.plot_wireframe(X, Y, Z, color=color)
|
|
540
|
+
|
|
541
|
+
ax.set_title(self.title)
|
|
542
|
+
|
|
543
|
+
if show:
|
|
544
|
+
plt.show()
|
|
545
|
+
|
|
546
|
+
# -------------------------
|
|
547
|
+
# 3D CONTOUR GRAPH
|
|
548
|
+
# -------------------------
|
|
549
|
+
def contour_3d_graph(
|
|
550
|
+
self,
|
|
551
|
+
values,
|
|
552
|
+
cmap="terrain",
|
|
553
|
+
show=True
|
|
554
|
+
):
|
|
555
|
+
"""Draw a 3D contour graph."""
|
|
556
|
+
|
|
557
|
+
fig = plt.figure(figsize=self.figsize)
|
|
558
|
+
ax = fig.add_subplot(111, projection="3d")
|
|
559
|
+
|
|
560
|
+
x = np.arange(len(values))
|
|
561
|
+
y = np.arange(len(values))
|
|
562
|
+
|
|
563
|
+
X, Y = np.meshgrid(x, y)
|
|
564
|
+
Z = np.outer(values, np.ones(len(values)))
|
|
565
|
+
|
|
566
|
+
ax.contour3D(X, Y, Z, 50, cmap=cmap)
|
|
567
|
+
|
|
568
|
+
ax.set_title(self.title)
|
|
569
|
+
|
|
570
|
+
if show:
|
|
571
|
+
plt.show()
|
|
572
|
+
|
|
573
|
+
# -------------------------
|
|
574
|
+
# 3D MOUNTAIN GRAPH
|
|
575
|
+
# -------------------------
|
|
576
|
+
def mountain_3d_graph(
|
|
577
|
+
self,
|
|
578
|
+
values,
|
|
579
|
+
cmap="terrain",
|
|
580
|
+
show=True
|
|
581
|
+
):
|
|
582
|
+
"""Draw a mountain-style 3D terrain graph."""
|
|
583
|
+
|
|
584
|
+
fig = plt.figure(figsize=self.figsize)
|
|
585
|
+
ax = fig.add_subplot(111, projection="3d")
|
|
586
|
+
|
|
587
|
+
x = np.arange(len(values))
|
|
588
|
+
y = np.linspace(0, 1, len(values))
|
|
589
|
+
|
|
590
|
+
X, Y = np.meshgrid(x, y)
|
|
591
|
+
|
|
592
|
+
Z = np.tile(values, (len(values), 1)).astype(float)
|
|
593
|
+
|
|
594
|
+
# add terrain-like variation
|
|
595
|
+
Z += np.sin(X / 2) * 0.5
|
|
596
|
+
|
|
597
|
+
ax.plot_surface(X, Y, Z, cmap=cmap, edgecolor="none")
|
|
598
|
+
|
|
599
|
+
ax.set_title(self.title)
|
|
600
|
+
|
|
601
|
+
if show:
|
|
602
|
+
plt.show()
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from tkinter import *
|
|
2
|
+
def start_password_entry(required="abcd1234"):
|
|
3
|
+
root = Tk()
|
|
4
|
+
root.title("Enter your password")
|
|
5
|
+
password = Entry(root, show="*")
|
|
6
|
+
password.pack()
|
|
7
|
+
def submit():
|
|
8
|
+
passw = password.get()
|
|
9
|
+
if passw == required:
|
|
10
|
+
return True
|
|
11
|
+
else:
|
|
12
|
+
return False
|
|
13
|
+
Button(root, text="Submit", command=submit).pack()
|
|
14
|
+
root.mainloop()
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
from graphics import Graphs
|
|
2
|
+
from tkinter import colorchooser
|
|
3
|
+
clr = colorchooser.askcolor()
|
|
4
|
+
g = Graphs(title="Alpha", theme="ggplot")
|
|
5
|
+
temperatures = [[0, 12, 45, 23],
|
|
6
|
+
[1, 12, 15, 20],
|
|
7
|
+
[20, 15, 12, 1]]
|
|
8
|
+
g.heatmap(temperatures
|
|
9
|
+
,color=str(clr[1]))
|
|
10
|
+
g.histogram(temperatures)
|