-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgen_plot.py
64 lines (54 loc) · 1.72 KB
/
gen_plot.py
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
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 42., 1_000_000)
y = np.random.random(size=x.shape[0])
fig,ax = plt.subplots(
nrows=1,
ncols=1,
figsize=(10,5)
)
ax.plot(
x,
y,
"--k"
)
plt.tight_layout()
fig.savefig("test_plot.png", dpi=200)
fig.savefig("test_plot.jpg", dpi=200)
fig.savefig("test_plot.pdf", dpi=200)
plt.show()
import matplotlib
gui_env = [i for i in matplotlib.rcsetup.interactive_bk]
non_gui_backends = matplotlib.rcsetup.non_interactive_bk
print ("Gui backends I will test for", gui_env)
for gui in gui_env:
print ("testing", gui)
try:
matplotlib.use(gui, force=True)
from matplotlib import pyplot as plt
print (" ",gui, "Is Available")
plt.plot(np.random.random(1_000_000))
fig = plt.gcf()
fig.suptitle(gui)
fig.savefig(f"test_plot_{gui=}.png", dpi=200)
fig.savefig(f"test_plot_{gui=}.jpg", dpi=200)
fig.savefig(f"test_plot_{gui=}.pdf", dpi=200)
print ("Using ..... ",matplotlib.get_backend())
except:
print (" ",gui, "Not found")
print ("Non Gui backends are:", non_gui_backends)
for non_gui in non_gui_backends:
print ("testing", non_gui)
try:
matplotlib.use(non_gui, force=True)
from matplotlib import pyplot as plt
print (" ",non_gui, "Is Available")
plt.plot(np.random.random(1_000_000))
fig = plt.gcf()
fig.suptitle(non_gui)
fig.savefig(f"test_plot_{non_gui=}.png", dpi=200)
fig.savefig(f"test_plot_{non_gui=}.jpg", dpi=200)
fig.savefig(f"test_plot_{non_gui=}.pdf", dpi=200)
print ("Using ..... ",matplotlib.get_backend())
except:
print (" ", non_gui, "Not found")