一直在尝试在jupyter笔记本中使用Ruby。用Python我可以做到这一点
import matplotlib.image as mpimg有没有人知道Ruby的等价物,我还没有在任何iRuby或sciruby文档中找到它呢?
为了澄清一点,在我的宝石档案里我有这个
gem 'iruby'
gem 'cztop'
gem 'matplotlib'但似乎无法访问我习惯于在python中使用的matplotlib的matplotlib部分。
我正在试图找到Ruby版本的什么,在Python中,我会这样写
#importing some useful packages
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
...
%matplotlib inline
#reading in an image
image = mpimg.imread('test_images/solidWhiteRight.jpg')
#printing out some stats and plotting
print('This image is:', type(image), 'with dimesions:', image.shape)
plt.imshow(image) #call as plt.imshow(gray, cmap='gray') to show a grayscaled image非常感谢你的建议
发布于 2018-03-21 05:26:42
这就是我在MacOSX上的jupyter笔记本电脑上工作的距离:
require 'matplotlib/pyplot'
plt = Matplotlib::Pyplot
image = plt.imread 'test.png'
puts "This image's dimensions: #{image.shape}"
plt.imshow(image)
plt.show()我将您的Gemfile与附加的rbczmq一起使用,以避免内核死亡(提示找到了这里):
gem 'iruby'
gem 'cztop'
gem 'matplotlib'
gem 'rbczmq'注意,我使用了一个.png,因为matplotlib只能在没有安装PIL的情况下本地读取PNG。
结果如下所示:

如python版本中所示,显示结果内联:

似乎不可能。
https://stackoverflow.com/questions/49329182
复制相似问题