python colorbar箭头设置
左侧箭头import matplotlib.pyplot as pltimport matplotlib as mplfig = plt.figure(figsize=(4,3))ax = fig.add_axes([0.05,0.5,0.8,0.1])cmap = mpl.colors.ListedColormap(['r','g','b','c'])cmap.set_over('...
·
左侧箭头
import matplotlib.pyplot as plt
import matplotlib as mpl
fig = plt.figure(figsize=(4,3))
ax = fig.add_axes([0.05,0.5,0.8,0.1])
cmap = mpl.colors.ListedColormap(['r','g','b','c'])
cmap.set_over('0.25')
cmap.set_under('0.75')
bounds = [1,2,3,4,5]
norm = mpl.colors.BoundaryNorm(bounds,cmap.N)
cb = mpl.colorbar.ColorbarBase(ax,
cmap = cmap,
norm = norm,
boundaries = [0]+bounds,
orientation = 'horizontal',
extend = 'min')
效果图:
右侧箭头
import matplotlib.pyplot as plt
import matplotlib as mpl
fig = plt.figure(figsize=(4,3))
ax = fig.add_axes([0.05,0.5,0.8,0.1])
cmap = mpl.colors.ListedColormap(['r','g','b','c'])
cmap.set_over('0.25')
cmap.set_under('0.75')
bounds = [1,2,3,4,5]
norm = mpl.colors.BoundaryNorm(bounds,cmap.N)
cb = mpl.colorbar.ColorbarBase(ax,
cmap = cmap,
norm = norm,
boundaries = bounds+[6],
orientation = 'horizontal',
extend = 'max')
效果图:
两端箭头
import matplotlib.pyplot as plt
import matplotlib as mpl
fig = plt.figure(figsize=(4,3))
ax = fig.add_axes([0.05,0.5,0.8,0.1])
cmap = mpl.colors.ListedColormap(['r','g','b','c'])
cmap.set_over('0.25')
cmap.set_under('0.75')
bounds = [1,2,3,4,5]
norm = mpl.colors.BoundaryNorm(bounds,cmap.N)
cb = mpl.colorbar.ColorbarBase(ax,
cmap = cmap,
norm = norm,
boundaries = bounds+[6],
orientation = 'horizontal',
extend = 'both')
效果图:
开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!
更多推荐
已为社区贡献5条内容
所有评论(0)