|
From: Joe K. <jof...@gm...> - 2013-10-21 14:21:08
|
I just realized that I replied to this off-list. Sending back out to the
entire list. (Sorry for the duplicate e-mail Christoph!)
On Oct 18, 2013 6:11 AM, "Christoph Groth" <chr...@gr...> wrote:
> Joe, thank you very much for your reply. So the "figsize" of a
> matplotlib plot is the physical size of the region between the axes
> where the data is shown?
No, your first assumption was correct. "figsize" refers to the size of the
whole figure.
What I meant to do in that example was abuse the fact that matplotlib will
happily add things beyond the figure boundaries. You can then abuse the
"bbox_inches" kwarg to savefig to show everything, while keeping the size
of the "data area" between the axes boundaries the same as the figsize.
My example there is actually completely wrong. I meant to do this:
import numpy as np
import matplotlib.pyplot as plt
dpi = 80
data = np.random.random((100, 100))
height, width = np.array(data.shape, dtype=float) / dpi
fig = plt.figure(figsize=(width, height), dpi=dpi)
ax = fig.add_axes([0, 0, 1, 1])
ax.imshow(data, interpolation='none')
fig.savefig('test.png', bbox_inches='tight')
At any rate, I'm not quite sure if that's actually what you wanted, but
it's a useful trick in cases like this.
|