2014-10-18 36 views
0

我想一个jpg图像与-1之间连续线的一个简单的插曲结合1 ,但我还没有尚未对其进行管理。问题在于jpg图像被加载了3个维度(RGB),而一个图形只能接受具有两个维度的数组。结合JPEG图像与数字

任何想法??

Thanx提前

到现在为止我已经在网上搜索这个管理:

fig, axes = plt.subplots(nrows=2) 
print fig,axes 
for ax in axes: 
    ax.plot(np.random.random(100)) 

image=im.imread('image.jpg') 
plot = plt.imshow(image) 

plt.text(image.shape[1]/2, 10, "Does this refer to a ?", horizontalalignment = "center") 

axes[1].autoscale(False)) 



plt.show() 
+0

“*这个数字只能接受与二维数组*” - 你能更准确?什么API调用只能接受二维数组? – 2014-10-18 23:31:59

回答

1

我无法理解你的问题。

这是否你想要做什么?

import numpy as np 
import matplotlib.pyplot as plt 
import matplotlib.image as im 

fig, (chart, picture) = plt.subplots(nrows=2) 

# First, the chart 
chart.plot(np.random.random(100)) 

# Second, an image 
image=im.imread('image.jpg') 
picture.imshow(image) 
picture.axis('off') 

plt.show() 

enter image description here