From 6406fea7edc6fea2fc56c76cdc84878615dec4c2 Mon Sep 17 00:00:00 2001 From: Alexander Steppke Date: Fri, 14 Nov 2025 22:23:59 +0100 Subject: [PATCH] added custom value-to-color mapper --- src/cristallina/plot.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/cristallina/plot.py b/src/cristallina/plot.py index 6802d55..e691724 100644 --- a/src/cristallina/plot.py +++ b/src/cristallina/plot.py @@ -2,6 +2,7 @@ import re from collections import defaultdict import matplotlib +import matplotlib as mpl from matplotlib import pyplot as plt import warnings @@ -13,7 +14,7 @@ import numpy as np from tqdm import tqdm from matplotlib import patches from pathlib import Path -import matplotlib as mpl + from sfdata import SFDataFiles, sfdatafile, SFScanInfo import jungfrau_utils as ju @@ -298,4 +299,9 @@ def line_plot_with_colorbar(xs,ys,colors, cmap=plt.cm.viridis, ax.set_ylabel(ylabel) # add colorbar - fig.colorbar(s_m,ax=ax,ticks=colors,label=cbar_label,alpha=alpha) \ No newline at end of file + fig.colorbar(s_m,ax=ax,ticks=colors,label=cbar_label,alpha=alpha) + + +def get_normalized_colormap(vmin, vmax, cmap=mpl.cm.viridis): + norm = mpl.colors.Normalize(vmin=vmin, vmax=vmax) + return lambda x: cmap(norm(x))