From d00a61a32922bb6569c5668177ee9f6075e587e1 Mon Sep 17 00:00:00 2001 From: colganwi Date: Sat, 24 Aug 2024 13:01:40 -0400 Subject: [PATCH] cmaps can be linear segmented --- src/pycea/pl/_utils.py | 2 +- tests/test_plot_tree.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pycea/pl/_utils.py b/src/pycea/pl/_utils.py index 55457b8..eaae64c 100755 --- a/src/pycea/pl/_utils.py +++ b/src/pycea/pl/_utils.py @@ -265,7 +265,7 @@ def _series_to_rgb_array(series, colors, vmin=None, vmax=None, na_color="#808080 color_series = series.map(colors).astype("object") color_series[series.isna()] = na_color rgb_array = np.array([mcolors.to_rgb(color) for color in color_series]) - elif isinstance(colors, mcolors.ListedColormap): + elif isinstance(colors, mcolors.ListedColormap | mcolors.LinearSegmentedColormap): # Normalize and map values if cmap is a ListedColormap if vmin is not None and vmax is not None: norm = mcolors.Normalize(vmin, vmax) diff --git a/tests/test_plot_tree.py b/tests/test_plot_tree.py index 4a328af..941da4d 100755 --- a/tests/test_plot_tree.py +++ b/tests/test_plot_tree.py @@ -25,7 +25,7 @@ def test_angled_numeric_annotations(tdata): ) pycea.pl.nodes(tdata, nodes="all", color="time", style="s", size=20) pycea.pl.nodes(tdata, nodes=["2"], tree="1", color="black", style="*", size=200) - pycea.pl.annotation(tdata, keys=["x", "y"], cmap="magma", width=0.1, gap=0.05, border_width=2) + pycea.pl.annotation(tdata, keys=["x", "y"], cmap="jet", width=0.1, gap=0.05, border_width=2) pycea.pl.annotation(tdata, keys=["0", "1", "2", "3", "4", "5"], label="genes", border_width=2) plt.savefig(plot_path / "angled_numeric.png") plt.close()