Open quantshah opened 4 years ago
Yes, this is an issue with the PGF backend in general. Actually, rsmf
is based on a notebook I made to achieve the same functionality for Quantum alone. You find it here. In certain versions of Jupyter notebook it seems to work to have both PDF output with PGF and a display of the figure, but this involves some serious hackery as you can see in the notebook (i.e. using magic commands and switching between backends). And it's not even reproducible.
I guess the most reasonable way to do it would be to load the PDF file that is created into the notebook again, as proposed here. One could make an api for that like
rsmf.save_and_show("output.pdf")
What do you think @quantshah ?
I think the best would be to dynamically detect if one can import IPython
and then use the approach detailed here.
If I use your code in the way I proposed in #4 things work out of the box in Jupyter notebooks.
Yes, this is an issue with the PGF backend in general. Actually,
rsmf
is based on a notebook I made to achieve the same functionality for Quantum alone. You find it here. In certain versions of Jupyter notebook it seems to work to have both PDF output with PGF and a display of the figure, but this involves some serious hackery as you can see in the notebook (i.e. using magic commands and switching between backends). And it's not even reproducible.I guess the most reasonable way to do it would be to load the PDF file that is created into the notebook again, as proposed here. One could make an api for that like
rsmf.save_and_show("output.pdf")
What do you think @quantshah ?
This looks interesting but I feel like the more we keep the rsmf code in the background and use matplotlib defaults, the better. So I could make the plots show on notebooks directly and save them like regular matplotlib figures using just the initialisation at the top.
Now I think the best way forward is to just wrap the IPython IFrame explained here as rsmf.show("xyz.pdf")
.
Okay, this doesn't work as expected, see PR #14
I suppose this was not the original intention of the package - to support plotting inside a notebook. But if I do this in a Jupyter notebook, I cannot see any plots:
However there are no issues if I save the plot, even in a notebook.