Hi,

A while ago, I sent an email around asking about the EPS output from  
matplotlib. The following example summarizes the problem well:

import matplotlib
matplotlib.use('Agg')
from matplotlib.pyplot import *

import numpy as np

nx,ny = 10,10

image = np.random.random((nx,ny))

fig = figure(figsize=(4,4))
ax = fig.add_subplot(111)
ax.pcolorfast(image)
fig.savefig('plot.eps')
fig.savefig('plot.pdf')
fig.savefig('plot.svg')

This produces files with the following sizes:

600K    plot.eps
8.0K    plot.pdf
20K     plot.svg

The EPS file is much larger because the bitmap is being rasterized to  
a much higher resolution than a 10x10 grid. However, I eventually  
figured out that the best way to solve this, assuming that the pixels  
are square, and that the pixels line up with the axes is:

fig = figure(figsize=(4,4))
ax = fig.add_subplot(111,aspect='equal')
ax.imshow(image)
width = ax.get_position().width * 4
dpi = nx / width
fig.savefig('plot2.eps',dpi=dpi)

which produces

12K     plot2.eps

As a temporary solution this works well - essentially matching the DPI  
to the resolution of the input array.

However, I have one remaining problem. In plot2.eps, the frame border  
has disappeared. Is this a bug? Does anyone know why this might be  
happening?

Thanks for any advice,

Thomas

------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to