mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-06 09:22:26 +00:00
Fix hashrate chart legend position (#1406)
Co-authored-by: didierlopes.eth <dro.lopes@campus.fct.unl.pt>
This commit is contained in:
committed by
GitHub
parent
f82a7e00d5
commit
a18977486e
@@ -8,6 +8,7 @@ import numpy as np
|
||||
from matplotlib import dates as mdates
|
||||
from matplotlib import pyplot as plt
|
||||
from matplotlib import ticker
|
||||
from matplotlib.lines import Line2D
|
||||
|
||||
from gamestonk_terminal.config_terminal import theme
|
||||
from gamestonk_terminal import config_plot as cfgPlot
|
||||
@@ -494,7 +495,6 @@ def display_hashrate(
|
||||
ax1.yaxis.set_major_formatter(ticker.StrMethodFormatter("{x:.0f}T"))
|
||||
ax1.set_ylabel(f"{asset} hashrate (Terahashes/second)")
|
||||
ax1.set_title(f"{asset}: Mean hashrate")
|
||||
ax1.legend(["Hash Rate"], loc="best")
|
||||
ax1.tick_params(axis="x", labelrotation=10)
|
||||
|
||||
ax2.set_xlim(left=df.index[0])
|
||||
@@ -502,7 +502,14 @@ def display_hashrate(
|
||||
ax2.plot(df.index, df["price"] / 1_000, color=theme.up_color, lw=0.8)
|
||||
ax2.yaxis.set_major_formatter(ticker.StrMethodFormatter("${x:.1f}k"))
|
||||
ax2.set_ylabel(f"{asset} price [$]")
|
||||
ax2.legend(["Price"], loc="best")
|
||||
|
||||
# Manually construct the chart legend
|
||||
lines = [
|
||||
Line2D([0], [0], color=color)
|
||||
for color in [theme.up_color, theme.down_color]
|
||||
]
|
||||
labels = ["Hash Rate", "Price"]
|
||||
ax2.legend(lines, labels)
|
||||
|
||||
if not external_axes:
|
||||
theme.visualize_output()
|
||||
|
||||
Reference in New Issue
Block a user