1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| import matplotlib.pyplot as plt import numpy as np import fastdataing as fd
def colorbar(orientation="vertical"): if orientation=="vertical": fig = fd.add_fig(figsize=(1.5, 6)) ax = fig.add_axes([0.45, 0.2, 0.10, 0.6]) else: fig = fd.add_fig(figsize=(6, 1.5)) ax = fig.add_axes([0.2, 0.45, 0.6, 0.20]) cmap = plt.get_cmap('jet') norm = plt.Normalize(vmin=0, vmax=1) cb = plt.colorbar(plt.cm.ScalarMappable(norm=norm, cmap=cmap), cax=ax, orientation=orientation) cb.set_ticks([0, 0.2, 0.4, 0.6, 0.8, 1.0]) plt.savefig("./colorbar.png",dpi=600,transparent=True) plt.show()
def colorbar_T(orientation="vertical"): if orientation=="vertical": fig = fd.add_fig(figsize=(1.5, 6)) ax = fig.add_axes([0.45, 0.2, 0.10, 0.6]) else: fig = fd.add_fig(figsize=(6, 1.5)) ax = fig.add_axes([0.2, 0.45, 0.6, 0.20]) cmap = plt.get_cmap('jet') norm = plt.Normalize(vmin=257, vmax=317) cb = plt.colorbar(plt.cm.ScalarMappable(norm=norm, cmap=cmap), cax=ax, orientation=orientation) cb.set_ticks([257, 272 , 287, 302, 317]) plt.savefig("./colorbar_temp.png",dpi=600,transparent=True) plt.show()
if __name__ == "__main__": orientation = "horizontal" colorbar_T(orientation=orientation)
|