Issue
I am trying to use Pyqtgraph to plot some image arrays on Jupyter notebook, but I am having some problems. Basically, I'm using the following code:
import pyqtgraph as pg
%gui qt
pg.image(recon_array_a[0])
This is giving me what I need but is opening it in a new window. Is there a way to open inline? Like is possible to do using matplotlib on Jupyter notebook, for exemple?
Solution
I am not aware of a way to make interactive qt applications such as pyqtgraph accessible inline in a jupyter notebook.
If you are only interested in the "raw image" without any interactivity, here's a workaround for you:
- generate an image with pyqtgraph
- export this image to a temporary file
- display the temporary file
Here's a quick demo (%gui qt is not required anymore)
import pyqtgraph as pg
import pyqtgraph.exporters
import numpy as np
from IPython.display import display, Image
def show_image(data):
img = pg.image(data)
file_name = "temp.png"
exporter = pg.exporters.ImageExporter(img.imageItem).export(file_name)
img.close()
display(Image(filename=file_name))
data = np.array([[1,0],[2,3]])
show_image(data)
Answered By - Christian Karcher
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.