python - IPython and Inline Matplotlib Figure Sizes -
in current ipython, matplotlib plots being displayed inline. wanted way display images specific pixel sizes, work pixels , don't print out.
my screen ppi 208, ran these 2 pieces of code:
plt.figure(figsize=(2000/float(208), 1000/float(208)), dpi=208) # other code here... plt.savefig('my_fig.png', dpi=208)
what i'm confused this: when examine my_fig.png
, in fact 2000 pixels 1000 pixels, want. according https://stackoverflow.com/a/7912007/582917 dpi settings rendering display device , rendering file have different defaults. that's why have add in dpi=208
plt.savefig
function.
however image rendered on ipython notebook, in browser, smaller. using browser ruler, it's 600 300 pixels.
using same dpi both functions, why inline rendered image in ipython notebook small, while saved image @ correct resolution want?
note i'm running ipython in virtualbox (that headless), i'm not sure if can cause differences.
after few trial , errors, in order close correct size inline rendering, figure dpi needed 58. images generated inline not match specified pixel count. it's +- 10 20 pixels.
this might due fact %matplotlib inline
default pass bbox_inches='tight'
plt.figure(...)
. try following,
after calling%matplotlib inline
, %config inlinebackend.print_figure_kwargs = {'bbox_inches':none}
create plot. here's did me:
Comments
Post a Comment