ItGo.me Focus on IT Recommend

Home > matplotlib basemap colorbar text position

matplotlib basemap colorbar text position

2020腾讯云双十一活动,全年最低!!!(领取3500元代金券),
地址https://cloud.tencent.com/act/cps/redirect?redirect=1074

【阿里云】双十一活动,全年抄底价,限时3天!(老用户也有),
入口地址https://www.aliyun.com/1111/home

up vote 4 down vote favorite 1 I have a problem about the text position of the colorbar. I'm using matplotlib Basemap to make some plots, and I the use colorbar() function. Now I need to put my colorbar on the left side of my figure. So I use location='left', but the text of ticks and label are given on the right side of the colorbar, which overlay part of the picture. Is there any way to change the text on the left side of the bar? matplotlib colorbar matplotlib-basemap
  |
  this question edited Oct 31 '12 at 9:43 bmu 14.6k 3 58 87 asked Oct 30 '12 at 23:21 innu 21 1 3



 |  1 Answers

up vote 6 down vote Sadly not in an entirely integrated way, but most things are possible when you are dealing with an OO plotting library such as mpl. I worked on a change that implemented this functionality in a more accessible form about 3 months ago (https://github.com/matplotlib/matplotlib/pull/956), but we decided not to merge it as there were some fundamental changes going on that made this change less applicable to may types of p

Recommend:Python matplotlib: position colorbar in data coordinates

a coordinates. Here is an example of how it works when specifying figure coordinates: import numpy as npimport matplotlib.pyplot as plt

#Generate some random data:a = -2b = 2x = (b - a) * np.random.random(50) + ay = (b - a) * np.r

lot. To produce the colorbar with ticks on the left hand side, you could do something like: <your_colorbar_instance>.ax.yaxis.set_ticks_position('left')

A real working example: import matplotlib

# create a dummy scalar mappable to create a colour bar with:

sm = plt.cm.ScalarMappable(cmap=plt.get_cmap('Reds'))

sm.set_array(range(10))

# create the colorbar and put the ticks on the left hand side

cb = plt.colorbar(sm)

cb.ax.yaxis.set_ticks_position('left')

plt.show()

HTH,
  |
  this answer answered Oct 31 '12 at 9:26 pelson 10.1k 2 40 61      @innu: Did this help at all? –  pelson Jan 4 '13 at 8:51



 | 

Recommend:python - Adjusting number precision in matplotlib basemap colorbar

3 places after the decimal. Here is what I am doing right now: kwargs = {'fmt': '%.1f'}cb = m.colorbar(cs, "bottom", size="3%", pad='2%', extend='neither', drawedges=False, norm=mpl.colors.Normalize(vmin=xaxis_min, vmax=xa

up vote 4 down vote favorite 1 I have a problem about the text position of the colorbar. I'm using matplotlib Basemap to make some plots, and I the use colorbar() function. Now I n

------splitte line----------------------------