Why are images generated by IJulia in low resolution?

843 views
Skip to first unread message

Staro Pickle

unread,
Sep 7, 2014, 12:19:19 AM9/7/14
to julia...@googlegroups.com

The image below was found on http://nbviewer.ipython.org/url/jdj.mit.edu/~stevenj/IJulia%20Preview.ipynb




I tried the code on my own computer but I got an unclear image compared to that. You can see my picture:

I originally tought it was mac's(OX 10.9) problem. Then I tried windows 8.1, the resolution was still low.

Can any tell me why and how to fix it?

Thank you.

gael....@gmail.com

unread,
Sep 7, 2014, 6:58:14 AM9/7/14
to julia...@googlegroups.com
Hi, this is matplotlib-related (the python lib behind PyPlot). You have to change the figsize or the dpi either this way:

http://stackoverflow.com/questions/17230797/how-to-set-the-matplotlib-figure-default-size-in-ipython-notebook

Or that way:

http://stackoverflow.com/questions/332289/how-do-you-change-the-size-of-figures-drawn-with-matplotlib

I don't know if this is wrapped directly in PyPlot though. Some persons may give more accurate answer.

Just as a reminder though, if you want to reuse those figure, you might want a more suitable format such as svg (vector graphics).

BTW, you can switch to vector graphics following the indications in this thread (you just have to change Julia's Jupyter profile instead of creating a new one):

http://stackoverflow.com/questions/17582137/ipython-notebook-svg-figures-by-default

Steven G. Johnson

unread,
Sep 7, 2014, 10:53:09 AM9/7/14
to julia...@googlegroups.com
You can change the figure size easily by just

    figure(figsize=(xx, yy))

etcetera, exactly as in Python.


On Sunday, September 7, 2014 6:58:14 AM UTC-4, gael....@gmail.com wrote:
 

BTW, you can switch to vector graphics following the indications in this thread (you just have to change Julia's Jupyter profile instead of creating a new one):

http://stackoverflow.com/questions/17582137/ipython-notebook-svg-figures-by-default

As explained in

  https://github.com/stevengj/PyPlot.jl#svg-output-in-ijulia

you can get SVG output by default in PyPlot by running PyPlot.svg(true) .... this isn't the default because browsers are much slower at rendering complex SVG plots than they are at rendering PNG.

Of course, you can also save to a vector format at any time by savefig("foo.svg") or savefig("foo.eps").
 

Staro Pickle

unread,
Sep 8, 2014, 12:21:08 AM9/8/14
to julia...@googlegroups.com
Thank you for your reply.

I have followed the steps under http://stackoverflow.com/questions/17582137/ipython-notebook-svg-figures-by-default. I found ~.ipython/profile_julia/ipython_notebook_config.py and uncommented and changed several lines:

c.InlineBackend.figure_format = 'svg'
c.InlineBackend.figure_formats = set(['svg'])
c.IPKernelApp.matplotlib = 'inline'

I also added "PyPlot.svg(true)" to my code. But still, my image was not switched to svg. I don't know why.

Besides, I tried Winston as well. The same problem.
Reply all
Reply to author
Forward
0 new messages