visualize_5_36.py 1.1 KB

123456789101112131415161718192021222324
  1. def normal_bar(df='dataframe', x_col_name=None, y_col_name=None, dim=(6, 4), bw=0.4, colorbar="#f2aa4cff", r=300,
  2. ar=(0, 0), valphabar=1, show=False, ylm=None, axtickfontsize=9, axtickfontname='Arial',
  3. ax_x_ticklabel=None, axlabelfontsize=9, axlabelfontname='Arial', axxlabel=None, axylabel=None,
  4. figtype='png', figname='normal_bar', theme=None):
  5. # set axis labels to None
  6. _x = None
  7. _y = None
  8. xbar = np.arange(len(df[x_col_name]))
  9. if theme == 'dark':
  10. general.dark_bg()
  11. plt.subplots(figsize=dim)
  12. plt.bar(x=xbar, height=df[y_col_name], width=bw, color=colorbar, alpha=valphabar)
  13. if ax_x_ticklabel:
  14. x_ticklabel = ax_x_ticklabel
  15. else:
  16. x_ticklabel = df[x_col_name].to_numpy()
  17. plt.xticks(ticks=xbar, labels=x_ticklabel, fontsize=axtickfontsize, rotation=ar[0], fontname=axtickfontname)
  18. if axxlabel:
  19. _x = axxlabel
  20. if axylabel:
  21. _y = axylabel
  22. general.axis_labels(_x, _y, axlabelfontsize, axlabelfontname)
  23. general.get_figure(show, r, figtype, figname, theme)