mirror of
https://github.com/Crocmagnon/checkout.git
synced 2024-11-22 08:08:04 +01:00
Improve graphs readability
This commit is contained in:
parent
84d003e2e0
commit
24a46d398d
1 changed files with 4 additions and 4 deletions
|
@ -135,14 +135,14 @@ def get_products_plots(products: ProductQuerySet):
|
||||||
|
|
||||||
x = np.arange(len(labels))
|
x = np.arange(len(labels))
|
||||||
width = 0.4
|
width = 0.4
|
||||||
fig: Figure = plt.figure()
|
fig: Figure = plt.figure(figsize=(10, 6))
|
||||||
fig.suptitle(_("Sales by product"))
|
fig.suptitle(_("Sales by product"))
|
||||||
|
|
||||||
color = "tab:orange"
|
color = "tab:orange"
|
||||||
ax1: Axes = fig.add_subplot()
|
ax1: Axes = fig.add_subplot()
|
||||||
bar: BarContainer = ax1.bar(x - width / 2, sold, width=width, color=color)
|
bar: BarContainer = ax1.bar(x - width / 2, sold, width=width, color=color)
|
||||||
ax1.bar_label(bar)
|
ax1.bar_label(bar)
|
||||||
ax1.tick_params(axis="x", rotation=15)
|
ax1.tick_params(axis="x", rotation=90)
|
||||||
ax1.tick_params(axis="y", labelcolor=color)
|
ax1.tick_params(axis="y", labelcolor=color)
|
||||||
ax1.set_xticks(x, labels)
|
ax1.set_xticks(x, labels)
|
||||||
ax1.set_ylabel(_("# sold"), color=color)
|
ax1.set_ylabel(_("# sold"), color=color)
|
||||||
|
@ -161,14 +161,14 @@ def get_products_plots(products: ProductQuerySet):
|
||||||
fig = plt.figure()
|
fig = plt.figure()
|
||||||
fig.suptitle(_("# sold"))
|
fig.suptitle(_("# sold"))
|
||||||
ax1 = fig.add_subplot()
|
ax1 = fig.add_subplot()
|
||||||
ax1.pie(sold, labels=labels, autopct="%d%%")
|
ax1.pie(sold, labels=labels, autopct="%d%%", pctdistance=0.85)
|
||||||
fig.tight_layout()
|
fig.tight_layout()
|
||||||
img2 = get_image_from_fig(fig)
|
img2 = get_image_from_fig(fig)
|
||||||
|
|
||||||
fig = plt.figure()
|
fig = plt.figure()
|
||||||
fig.suptitle(_("Turnover by product"))
|
fig.suptitle(_("Turnover by product"))
|
||||||
ax1 = fig.add_subplot()
|
ax1 = fig.add_subplot()
|
||||||
ax1.pie(turnover, labels=labels, autopct="%d%%")
|
ax1.pie(turnover, labels=labels, autopct="%d%%", pctdistance=0.85)
|
||||||
fig.tight_layout()
|
fig.tight_layout()
|
||||||
img3 = get_image_from_fig(fig)
|
img3 = get_image_from_fig(fig)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue