On 11/9/11 11:13 AM, Joe Kington wrote:
On Wed, Nov 9, 2011 at 10:07 AM, Howard <how...@renci.org
<mailto:how...@renci.org>> wrote:
Hi all
I'm a new user to matplotlib, and I'm having a little difficulty
with something I feel must be basic. When I plot our data, I'm
using a canvas that is 4"x4" at 128 DPI and saving the canvas as a
png. Here's the basics of the code:
imageWidth = 4
imageHeight = 4
DPI = 128
figure1 = plt.figure(figsize=(imageWidth,imageHeight))
plt.axis("off")
plt.tricontourf(theTriangulation,
modelData,
theLookupTable.N,
cmap=theLookupTable)
canvas = FigureCanvasAgg(figure1)
canvas.print_figure(prefix + ".png", dpi=DPI)
The png is 512x512 as I would expect, but the contoured image
doesn't fill the whole image. How do I tell the library to map
the plotted are to the entire canvas and not leave a border around
the rendered image?
You need to make an axis that fills up the entire figure.
By default, axes don't fill up the entire figure to leave room for
tick labels, axis lables, titles, etc.
Try something like:
import matplotlib as plt
dpi = 128
fig = plt.figure(figsize=(4,4))
# Specifies an axis at 0, 0 with a width and height of 1 (the full
width of the figure)
ax = fig.add_axes([0,0,1,1])
ax.tricontourf(...)
fig.savefig('output.png', dpi=dpi)
Hope that helps,
-Joe
Hi Joe
That did it! Thanks much. Can I also turn off the tick marks on the new
axis?
Howard
--
Howard Lander <mailto:how...@renci.org>
Senior Research Software Developer
Renaissance Computing Institute (RENCI) <http://www.renci.org>
The University of North Carolina at Chapel Hill
Duke University
North Carolina State University
100 Europa Drive
Suite 540
Chapel Hill, NC 27517
919-445-9651
------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users