From 0359bcedea56c8f731d789083d74b46775f04fb0 Mon Sep 17 00:00:00 2001
From: George Katsikas <giorgakis.katsikas@gmail.com>
Date: Wed, 27 Nov 2024 16:39:31 +0100
Subject: [PATCH] use powers for large values in map plot colorbar

---
 scipost_django/graphs/graphs/plotkind.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/scipost_django/graphs/graphs/plotkind.py b/scipost_django/graphs/graphs/plotkind.py
index e22c039e8..50fe5b64b 100644
--- a/scipost_django/graphs/graphs/plotkind.py
+++ b/scipost_django/graphs/graphs/plotkind.py
@@ -233,7 +233,15 @@ class MapPlot(PlotKind):
         ax.xaxis.set_visible(False)
         ax.yaxis.set_visible(False)
 
-        cax.xaxis.set_ticklabels(f"{int(x)}" for x in cax.xaxis.get_ticklocs())
+        # Set the colorbar ticks to integers if < 1000, else leave intact
+        labels = []
+        for label, loc in zip(cax.get_xticklabels(), cax.get_xticks()):
+            if loc < 1000:
+                labels.append(int(loc))
+            else:
+                labels.append(label)
+
+        cax.set_xticklabels(labels)
 
         return fig
 
-- 
GitLab