From: Art on
I am having trouble saving a plot generated with imagesc. I am working
on a terminal on a cluster with X graphics disabled.

I create the image with imagesc(X), where X is a large mxn matrix, and
would like to save the image as a png with dpi such that all the
elements of the matrix are guaranteed to be visible. Is there an easy
way to do this?

This is one of my trials:

% f is figure handle, fname is filename.png
set(gcf, 'PaperUnits', 'inches');
set(gcf, 'PaperSize', [11 8.5]);
set(gcf, 'PaperPositionMode', 'manual');
set(gcf, 'PaperPosition', [0 0 11 8.5]);
print(f, '-dpng', '-r300', fname);

There has to be an easier way. In python's matplotlib, the figure size
and dpi are trivial to set.

Thanks for any help,
Art.
From: Oliver Woodford on
Art wrote:
> I am having trouble saving a plot generated with imagesc. I am working
> on a terminal on a cluster with X graphics disabled.
>
> I create the image with imagesc(X), where X is a large mxn matrix, and
> would like to save the image as a png with dpi such that all the
> elements of the matrix are guaranteed to be visible. Is there an easy
> way to do this?
>
> This is one of my trials:
>
> % f is figure handle, fname is filename.png
> set(gcf, 'PaperUnits', 'inches');
> set(gcf, 'PaperSize', [11 8.5]);
> set(gcf, 'PaperPositionMode', 'manual');
> set(gcf, 'PaperPosition', [0 0 11 8.5]);
> print(f, '-dpng', '-r300', fname);
>
> There has to be an easier way. In python's matplotlib, the figure size
> and dpi are trivial to set.
>
> Thanks for any help,
> Art.

A quick question: Why do you need to generate and save a figure, rather than save the matrix X directly as an image, using imwrite along with the colormap you want?
From: Art on
On Mar 29, 3:33 am, "Oliver Woodford" <o.j.woodford...(a)cantab.net>
wrote:
> Art wrote:
> > I am having trouble saving a plot generated with imagesc. I am working
> > on a terminal on a cluster with X graphics disabled.
>
> > I create the image with imagesc(X), where X is a large mxn matrix, and
> > would like to save the image as a png with dpi such that all the
> > elements of the matrix are guaranteed to be visible. Is there an easy
> > way to do this?
>
> > This is one of my trials:
>
> > % f is figure handle, fname is filename.png
> > set(gcf, 'PaperUnits', 'inches');
> > set(gcf, 'PaperSize', [11 8.5]);
> > set(gcf, 'PaperPositionMode', 'manual');
> > set(gcf, 'PaperPosition', [0 0 11 8.5]);
> > print(f, '-dpng', '-r300', fname);
>
> > There has to be an easier way. In python's matplotlib, the figure size
> > and dpi are trivial to set.
>
> > Thanks for any help,
> > Art.
>
> A quick question: Why do you need to generate and save a figure, rather than save the matrix X directly as an image, using imwrite along with the colormap you want?

Thanks Oliver. I didn't look at imwrite carefully. It does what I need
for this particular case. In the general case, I am still not sure how
to correctly size my figures.
From: Oliver Woodford on
Art <grenander(a)gmail.com> wrote in message <69d35b1a-d15b-44db-b94f-7166e36460c4(a)f14g2000pre.googlegroups.com>...
> On Mar 29, 3:33 am, "Oliver Woodford" <o.j.woodford...(a)cantab.net>
> wrote:
> > Art wrote:
> > > I am having trouble saving a plot generated with imagesc. I am working
> > > on a terminal on a cluster with X graphics disabled.
> >
> > > I create the image with imagesc(X), where X is a large mxn matrix, and
> > > would like to save the image as a png with dpi such that all the
> > > elements of the matrix are guaranteed to be visible. Is there an easy
> > > way to do this?
> >
> > > This is one of my trials:
> >
> > > % f is figure handle, fname is filename.png
> > > set(gcf, 'PaperUnits', 'inches');
> > > set(gcf, 'PaperSize', [11 8.5]);
> > > set(gcf, 'PaperPositionMode', 'manual');
> > > set(gcf, 'PaperPosition', [0 0 11 8.5]);
> > > print(f, '-dpng', '-r300', fname);
> >
> > > There has to be an easier way. In python's matplotlib, the figure size
> > > and dpi are trivial to set.
> >
> > > Thanks for any help,
> > > Art.
> >
> > A quick question: Why do you need to generate and save a figure, rather than save the matrix X directly as an image, using imwrite along with the colormap you want?
>
> Thanks Oliver. I didn't look at imwrite carefully. It does what I need
> for this particular case. In the general case, I am still not sure how
> to correctly size my figures.

In the case where you want to save an image, with vector graphics laid over the top, as a bitmap, I suggest you use export_fig with the -native option. Export_fig can be downloaded here:
http://www.mathworks.com/matlabcentral/fileexchange/23629-exportfig