不管我改变什么样的价值观,它总是扭曲它,或者它太偏左了。你知道吗
举个例子:
barchart = pd.read_csv('barchart.csv')
df = pd.DataFrame(barchart)
var1 = df['col1'].head(7).tolist()
var2 = df['col2'].head(7).tolist()
sometitle = df['sometitle'][0]
var2 = [ float(x) for x in var2 ]
y_pos = np.arange(len(var1))
datafile = cbook.get_sample_data('/path/to/watch.jpg', asfileobj=False)
im = image.imread(datafile)
plt.imshow(im, zorder=0, extent=[0.5, 8.0, 1.0, 7.0])
barlist = plt.barh(y_pos, var2, align='center', alpha=0.5)
colors = ["red", "green", "blue", "orange", "pink", "cyan", "yellow"]
for a, b in zip(range(6), colors):
barlist[a].set_color(b)
plt.yticks(y_pos, var1)
plt.xlabel('a label', color="green", fontsize=9)
plt.title(sometitle + " " + str(now))
plt.show()
从文件来看
所以如果你想把图像放在一个给定的
x
,y
和size
都在数据坐标中,得到im.shape
的比率,并用它来缩放。例如看起来像是
注意,还有一个问题是图像周围的空白会导致它看起来远离范围。你知道吗
您也可以执行类似于set
aspect="equal"
的操作,但必须删除extents
。你知道吗相关问题 更多 >
编程相关推荐