EasyMachineLearningDemo / visualization /draw_histogram_line_subgraph.py
LLH
2024/03/07/16:46
8d94a86
raw
history blame
1.28 kB
import numpy as np
from matplotlib import pyplot as plt
from classes.static_custom_class import *
def draw_histogram_line_subgraph(total_data_for_plot):
# Manually adjust based on the data
layout = """
ABC
DDE
FGH
IJK
"""
fig, ax = plt.subplot_mosaic(layout, figsize=(16, 16))
for i, data in enumerate(total_data_for_plot):
if data[0] == "line_graph":
ax[str(chr(i+65))].grid()
ax[str(chr(i+65))].plot(
data[1],
data[2],
"-o",
color=StaticValue.COLORS[0],
markersize=4
)
ax[str(chr(i+65))].set_title(data[3])
elif data[0] == "histogram":
ax[str(chr(i+65))].grid()
ax[str(chr(i+65))].bar(
np.arange(0, len(data[1])),
data[1],
align="center",
alpha=1,
color=StaticValue.COLORS,
tick_label=data[2]
)
if data[3]:
ax[str(chr(i+65))].tick_params(axis='x', labelrotation=-90)
ax[str(chr(i+65))].set_title(data[5])
plt.tight_layout()
plt.savefig("./diagram/{}.png".format("total"), dpi=300)
plt.show()