Created
April 19, 2023 09:31
-
-
Save JohannesBuchner/fad4ece9816f0123fbd61b8d9cc7746f to your computer and use it in GitHub Desktop.
Revisions
-
JohannesBuchner created this gist
Apr 19, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ import matplotlib as mpl import matplotlib.pyplot as plt # make a colormap that can be used to look up colors norm = mpl.colors.Normalize(vmin=0, vmax=3) zcmap = plt.cm.ScalarMappable(norm=norm, cmap=plt.cm.viridis) # use it to plot stuff plt.errorbar( x=1, xerr=0.1, y=2, yerr=0.2, color=zcmap.to_rgba(redshifts[i]), ) # show the color bar in the panel cax = plt.axes([0.85, 0.5, 0.02, 0.2]) # left, bottom, width, height cbar = plt.colorbar(zcmap, orientation="vertical", cax=cax) cbar.set_label('redshift')