Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline graph images broken #35

Open
kpfoley opened this issue Jul 28, 2018 · 4 comments
Open

Inline graph images broken #35

kpfoley opened this issue Jul 28, 2018 · 4 comments
Labels

Comments

@kpfoley
Copy link

kpfoley commented Jul 28, 2018

I've just started using IPyStata and it's great, but the inline graphs were displaying as blank / gray boxes in the jupyter notebook. My install is a little unusual so I'm not sure if others have run into the same problem, but it looks like it's related to this issue from Jupyter. If I understand correctly there was a security-minded fix to Jupyter that prevents .pdf images from being loaded inline in notebooks. This seems to be the case, since I couldn't load pdf images directly from the Jupyter project folder but was able to load png images. Unfortunately, unix/linux Stata is unable to save graphs to png.

I've implemented a kludgy fix on my installation which uses imagemagick to convert temp_file.pdf to temp_file.png before loading the graph in the notebook with IFrame, but it doesn't seem like a good solution to the problem since it introduces system calls and adds a non-Python dependency.

Has anyone else run into this problem?

My setup:

Jupyter 4.4.0
Jupyter-notebook 5.6.0 (and 5.7.0dev0)
IPython 6.4.0
Python 3.6.4
latest IPyStata
chromebook / ChromeOS 67

@TiesdeKok
Copy link
Owner

Thanks for the heads-up @kpfoley!

I have not encounted this problem before, but I completely acknowledge that the PDF solution is not great.

It seems that @kylebarron figured out a solution by using .svg files for his stata_kernel, I might be able to replicate his solution and implement it into ipystata. If we can circumvent the problem with png files using svg files then I could avoid PDFs all together solving the problem.

For my own reference, this is the relevant code: stata_kernel commit

@TiesdeKok TiesdeKok added the bug label Aug 5, 2018
@ozak
Copy link

ozak commented Jun 12, 2020

Any updates on this? I just tried creating a figure and get no output inline. Also if I run one of your examples

%%stata -gr
use http://stats.idre.ucla.edu/stat/stata/notes/hsb2, clear
graph twoway scatter read math, name(a, replace) title("Graph a")

graph twoway scatter math science, name(b, replace) title("Graph b")

I get

image

@TiesdeKok
Copy link
Owner

Unfortunately not, never got around to it and consequently forgot about it. I've set a reminder to look at this once my schedule clears up in a couple of weeks. Once I looked into it I will update this issue thread.

Thanks for the reminder!

@ozak
Copy link

ozak commented Jun 12, 2020

Thanks! In the meantime a workaround is to save the file and then import it into the notebook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants