【发布时间】:2018-08-26 00:27:16
【问题描述】:
一直在尝试在 jupyter notebook 中使用 Ruby。使用 Python 我可以做到这一点
import matplotlib.image as mpimg
有谁知道 Ruby 的等价物,我在任何 iRuby 或 sciruby 文档中都找不到它?
澄清一下,在我的 gemfile 中有这个
gem 'iruby'
gem 'cztop'
gem 'matplotlib'
但似乎无法访问我习惯在 python 中使用的matplotlib 的image 部分。
我正在尝试在 Python 中找到我会这样写的 Ruby 版本
#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
非常感谢您的任何建议
【问题讨论】:
-
-
当然我知道这些是如何有用的,我的问题是更大的范围,我找不到任何方法来访问我需要的库,因为它甚至不存在于 ruby 环境中,我很好奇我是如何得到的它在 Ruby 中,或者如果它存在于 Ruby 版本中。
-
不,AFAIK 它在 Ruby 版本中不存在。在不确切说明您需要什么的情况下,我可能会建议 mini_magick(iRuby 应该已经支持),或者 chunky_png(您可以使用
IRuby.display png.to_blob, mime: "image/png"将图像从它放入 iRuby)。
标签: ruby matplotlib jupyter-notebook