Jun 2024
This commit is contained in:
29
script/cpy/TestMatplotlib.py
Normal file
29
script/cpy/TestMatplotlib.py
Normal file
@@ -0,0 +1,29 @@
|
||||
print ("Starting...")
|
||||
import matplotlib
|
||||
from ch.psi.pshell.imaging import Utils as ImagingUtils
|
||||
#matplotlib.use('TkAgg')
|
||||
matplotlib.use('Agg')
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
fig, ax = plt.subplots()
|
||||
|
||||
fruits = ['apple', 'blueberry', 'cherry', 'orange']
|
||||
counts = [40, 100, 30, 55]
|
||||
bar_labels = ['red', 'blue', '_red', 'orange']
|
||||
bar_colors = ['tab:red', 'tab:blue', 'tab:red', 'tab:orange']
|
||||
|
||||
ax.bar(fruits, counts, label=bar_labels, color=bar_colors)
|
||||
|
||||
ax.set_ylabel('fruit supply')
|
||||
ax.set_title('Fruit supply by kind and color')
|
||||
ax.legend(title='Fruit color')
|
||||
|
||||
|
||||
f = expand_path("{images}/output.png")
|
||||
plt.savefig(f)
|
||||
img = ImagingUtils.newImage(f)
|
||||
show_panel(img, "tst")
|
||||
|
||||
|
||||
print ("Done")
|
||||
Reference in New Issue
Block a user