You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just wanted to share some code here in case it may help anyone else: I've added a legend to the PVDs which shows the Z_val associated with each colour. It assumes that the Z_vals are the same for all biomarkers when creating the legend labels. I'm aware that there's an open issue on PVD colourbars and am not offering a solution to that problem, but simply a fix in the meantime to show clearly which value maps to which colour (I myself found this quite confusing to parse out when using more than 3 Z_vals as there was no documentation showing the mappings). It would be well paired with explanations I've seen used in papers about what the intensity, etc. of each colour indicates.
This requires an extra import from Matplotlib in ZscoreSustain: import matplotlib.patches as mpatches.
To implement it, add the following to plot_positional_var in ZscoreSustain between lines 660 (ax.set_title(title_i, fontsize=title_font_size)) and 661 (# Tighten up the figure). Further customization (i.e. legend size, location, etc) is possible through use of the ax.legend arguments.
ax.set_xlabel(stage_label, fontsize=stage_font_size+2)
ax.set_title(title_i, fontsize=title_font_size)
# Add a legend
# adding an extra dim to colour mat for RGB reasons
legend_colour_mat = np.array([[[1, 0, 0], [1, 0, 1], [0, 0, 1], [0.5, 0, 1], [0, 1, 1], [0, 1, 0.5]]])[:N_z]
patches = [ mpatches.Patch(color=legend_colour_mat[0][i], label=f"Z_val = {zvalues[i]}") for i in range(len(zvalues)) ]
# put those patches as legend-handles into the legend
ax.legend(handles=patches, loc = "best" )
# Tighten up the figure
#plt.tight_layout()
fig.tight_layout()
this is an example of the result using the Sustain Workshop data:
I also found it helpful to visualize the general mapping of Z_vals to colours, especially if legends aren't used:
Hi all,
I just wanted to share some code here in case it may help anyone else: I've added a legend to the PVDs which shows the Z_val associated with each colour. It assumes that the Z_vals are the same for all biomarkers when creating the legend labels. I'm aware that there's an open issue on PVD colourbars and am not offering a solution to that problem, but simply a fix in the meantime to show clearly which value maps to which colour (I myself found this quite confusing to parse out when using more than 3 Z_vals as there was no documentation showing the mappings). It would be well paired with explanations I've seen used in papers about what the intensity, etc. of each colour indicates.
This requires an extra import from Matplotlib in ZscoreSustain:
import matplotlib.patches as mpatches
.To implement it, add the following to
plot_positional_var
in ZscoreSustain between lines 660 (ax.set_title(title_i, fontsize=title_font_size)
) and 661 (# Tighten up the figure
). Further customization (i.e. legend size, location, etc) is possible through use of theax.legend
arguments.this is an example of the result using the Sustain Workshop data:
I also found it helpful to visualize the general mapping of Z_vals to colours, especially if legends aren't used:
which I generated using:
I hope this will be helpful to some! Thanks 😊
The text was updated successfully, but these errors were encountered: