From 20cff110981f27807c116a22bc59a0c15703db7b Mon Sep 17 00:00:00 2001 From: Panagiotis Anagnostou Date: Thu, 6 Jun 2024 20:27:40 +0300 Subject: [PATCH] Visualizations fix. Deprecated function. --- src/HiPart/__utility_functions.py | 3 +-- src/HiPart/interactive_visualization.py | 4 ++-- src/HiPart/visualizations.py | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/HiPart/__utility_functions.py b/src/HiPart/__utility_functions.py index 4833aee..d24140f 100644 --- a/src/HiPart/__utility_functions.py +++ b/src/HiPart/__utility_functions.py @@ -639,8 +639,7 @@ def visualization_preparation(hipart_object, color_map): dictionary_of_nodes = hipart_object.tree.nodes # get colormap - color_map = matplotlib.cm.get_cmap( - color_map, + color_map = matplotlib.colormaps[color_map].resampled( max(hipart_object.tree.leaves(), key=lambda x: x.data["color_key"]).data["color_key"] + 1 ) color_list = [color_map(i) for i in range(color_map.N)] diff --git a/src/HiPart/interactive_visualization.py b/src/HiPart/interactive_visualization.py index 376c5b8..f5f6851 100644 --- a/src/HiPart/interactive_visualization.py +++ b/src/HiPart/interactive_visualization.py @@ -497,7 +497,7 @@ def _Splitpoint_Manipulation(object_path): category_order = {"cluster": [str(i) for i in np.unique(data_matrix["cluster"])]} # generate the colors to be used - color_map = matplotlib.cm.get_cmap("tab20", number_of_nodes) + color_map = matplotlib.colormaps["tab20"].resampled(number_of_nodes) colList = {str(i): _convert_to_hex(color_map(i)) for i in range(color_map.N)} with open(object_path, "rb") as obj_file: @@ -904,7 +904,7 @@ def _Cluster_Scatter_Plot(object_path): ) = _data_preparation(object_path, 0) # create scatter plot with the split-point shape - color_map = matplotlib.cm.get_cmap("tab20", number_of_nodes) + color_map = matplotlib.colormaps["tab20"].resampled(number_of_nodes) colList = {str(i): _convert_to_hex(color_map(i)) for i in range(color_map.N)} category_order = { "cluster": [str(i) for i in range(len(np.unique(data_matrix["cluster"])))] diff --git a/src/HiPart/visualizations.py b/src/HiPart/visualizations.py index 2ae5695..f840de2 100644 --- a/src/HiPart/visualizations.py +++ b/src/HiPart/visualizations.py @@ -566,7 +566,7 @@ def dendrogram_visualization(hipart_object, cmap="viridis", default_coloring=Tru default = dendrogram_parameters["above_threshold_color"] # Initialize the color map based on the number of clusters - color_map = matplotlib.cm.get_cmap(cmap, hipart_object.max_clusters_number) + color_map = matplotlib.colormaps[cmap].resampled(hipart_object.max_clusters_number) # Create the linkage and the color keys for the dendrogram Z, link_keys = util.create_linkage(hipart_object.tree, color_keys=True)