Switch to horizontal bar plot
This commit is contained in:
parent
b1b3a5afa2
commit
0437814725
1 changed files with 5 additions and 4 deletions
|
@ -188,8 +188,8 @@ def snapshot_graph(request, uuid):
|
|||
|
||||
print(_categories_p)
|
||||
print(_categories_m)
|
||||
fig, ax = plt.subplots()
|
||||
ax.bar(
|
||||
fig, ax = plt.subplots(constrained_layout=True)
|
||||
ax.barh(
|
||||
[
|
||||
"*" if (c := _cat["category"]) is None else Category.objects.get(id=c).name
|
||||
for _cat in _categories_p
|
||||
|
@ -197,7 +197,7 @@ def snapshot_graph(request, uuid):
|
|||
[_cat["sum"] for _cat in _categories_p],
|
||||
color="#007339",
|
||||
)
|
||||
ax.bar(
|
||||
ax.barh(
|
||||
[
|
||||
"*" if (c := _cat["category"]) is None else Category.objects.get(id=c).name
|
||||
for _cat in _categories_m
|
||||
|
@ -206,7 +206,8 @@ def snapshot_graph(request, uuid):
|
|||
color="#bf1500",
|
||||
)
|
||||
ax.grid(color="k", alpha=0.2)
|
||||
ax.set(ylabel="Value (€)")
|
||||
ax.set(xlabel="Value (€)")
|
||||
#fig.tight_layout()
|
||||
with tempfile.NamedTemporaryFile(suffix=".svg") as f:
|
||||
fig.savefig(f.name)
|
||||
f.seek(0)
|
||||
|
|
Loading…
Reference in a new issue