mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-04 16:32:10 +00:00
Scale text size with size of box in crypto/ov/hm (#2278)
* Updated text size so it scales with size of box * fix linting Co-authored-by: minhhoang1023 <40023817+minhhoang1023@users.noreply.github.com> Co-authored-by: Chavithra <chavithra@gmail.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com>
This commit is contained in:
@@ -90,11 +90,26 @@ def display_crypto_heatmap(
|
||||
|
||||
squarify.plot(
|
||||
df["market_cap"],
|
||||
label=df_copy["symbol"],
|
||||
alpha=0.8,
|
||||
color=colors,
|
||||
text_kwargs={"color": "black", "size": 8},
|
||||
)
|
||||
text_sizes = squarify.normalize_sizes(df["market_cap"], 100, 100)
|
||||
rects = squarify.squarify(text_sizes, 0, 0, 100, 100)
|
||||
for la, r in zip(df_copy["symbol"], rects):
|
||||
x, y, dx, dy = r["x"], r["y"], r["dx"], r["dy"]
|
||||
ax.text(
|
||||
x + dx / 2,
|
||||
y + dy / 2,
|
||||
la,
|
||||
va="center",
|
||||
ha="center",
|
||||
color="black",
|
||||
size=(
|
||||
text_sizes[df_copy.index[df_copy["symbol"] == la].tolist()[0]]
|
||||
** 0.5
|
||||
* 0.8
|
||||
),
|
||||
)
|
||||
ax.set_title(f"Top {top} Cryptocurrencies {category_str}")
|
||||
ax.set_axis_off()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user