MCPcopy Create free account
hub / github.com/cselab/aphros / AddColorBar

Function AddColorBar

deploy/scripts/aphros/plot.py:180–190  ·  view source on GitHub ↗
(fig, vmin, vmax, cmap)

Source from the content-addressed store, hash-verified

178 return fig, ax
179
180def AddColorBar(fig, vmin, vmax, cmap):
181 cbar_ax = fig.add_axes([0.15, 0.07, 0.7, 0.05])
182 norm = matplotlib.colors.Normalize(vmin=vmin, vmax=vmax)
183 sm = plt.cm.ScalarMappable(cmap=cmap, norm=norm)
184 sm.set_array([])
185 vv = [vmin, (vmin + vmax) * 0.5, vmax]
186 if abs(vv[1]) < 1e-14:
187 vv[1] = 0
188 cbar = fig.colorbar(sm, cax=cbar_ax, orientation='horizontal', ticks=vv)
189 cbar.ax.set_xticklabels(["{:.4g}".format(v) for v in vv])
190 return cbar
191
192
193def PlotFieldCoolwarm(ax, u, vmin=None, vmax=None):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected