123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- def bars_plot(bar_labels=None, bar_heights=None, bar_colors="blue", bar_width=0.25, xlabel="xlabel", ylabel="ylabel", fig_title="title", figsize=(12.8, 9.6), output="./bars.png", show=False):
- import matplotlib.pyplot as plt
- plt.figure(figsize=figsize)
- plt.bar(x=list(map(str,bar_labels)), height=bar_heights, width=bar_width, color=bar_colors)
- plt.xlabel(xlabel)
- plt.ylabel(ylabel)
- plt.title(fig_title)
- plt.savefig(output, dpi="figure")
- if show:
- plt.show()
- plt.close()
-
- def clustering_plot(abcissas=None, ordinates=None, predictions=None, marker="o", xlabel="xlabel", ylabel="ylabel", fig_title="title", figsize=(12.8, 9.6), output="./bars.png", show=False):
- import matplotlib.pyplot as plt
- plt.figure(figsize=figsize)
- plt.scatter(x=abcissas, y=ordinates, c=predictions, marker=marker)
- plt.xlabel(xlabel)
- plt.ylabel(ylabel)
- plt.title(fig_title)
- plt.savefig(output, dpi="figure")
- if show:
- plt.show()
- plt.close()
-
- def bars_plot2(bar_labels=None, bar_heights=None, bar_colors="blue", bar_width=0.25, xlabel="xlabel", ylabel="ylabel", fig_title="title", figsize=(12.8, 9.6), output="./bars.png", show=False, show_heights=True, percent_mark=False):
- import matplotlib.pyplot as plt
- plt.figure(figsize=figsize)
- bar = plt.bar(x=list(map(str,bar_labels)), height=bar_heights, width=bar_width, color=bar_colors)
- plt.xlabel(xlabel)
- plt.ylabel(ylabel)
- plt.title(fig_title)
- if show_heights:
- for rect in bar:
- height = rect.get_height()
- if percent_mark:
- plt.text(rect.get_x() + rect.get_width() / 2.0, height, '%.2f%%' % height, ha='center', va='bottom')
- else:
- plt.text(rect.get_x() + rect.get_width() / 2.0, height, '%.2f' % height, ha='center', va='bottom')
- plt.savefig(output, dpi="figure")
- if show:
- plt.show()
- plt.close()
-
- def curve_plot(abcissas=None, ordinates=None, xlabel="xlabel", ylabel="ylabel", fig_title="title", figsize=(12.8, 9.6), output="./bars.png", show=False):
- import matplotlib.pyplot as plt
- plt.figure(figsize=figsize)
- plt.plot(abcissas,ordinates)
- plt.xlabel(xlabel)
- plt.ylabel(ylabel)
- plt.title(fig_title)
- plt.savefig(output, dpi="figure")
- if show:
- plt.show()
- plt.close()
|