Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Printing a figure to file problem

Subject: Printing a figure to file problem

From: Yoav Rubin

Date: 24 Oct, 2007 10:24:16

Message: 1 of 10

Hi All,
I am trying to print a figure that has in it an image to a
file, I am using the commands:
axes(theFigure);
print('-dtiffn','myTiff.tiff');

but it results in partial image saving, the image itself is
512x512, but the saved file is an image of 473 x 355.

Ive tried either with or without '-noui', but the result
remained the same.
Does anyone has any idea?

thanks

Yoav

Subject: Printing a figure to file problem

From: Richard Quist

Date: 24 Oct, 2007 11:23:43

Message: 2 of 10

Yoav Rubin wrote:
> Hi All,
> I am trying to print a figure that has in it an image to a
> file, I am using the commands:
> axes(theFigure);
> print('-dtiffn','myTiff.tiff');
>
> but it results in partial image saving, the image itself is
> 512x512, but the saved file is an image of 473 x 355.
>
> Ive tried either with or without '-noui', but the result
> remained the same.
> Does anyone has any idea?
>
> thanks
>
> Yoav
Is the issue that the resulting file is just smaller in size or that
some portion of the image is truncated from the file?

Generally, the properties to look at on the figure that affect this are:
* PaperPositionMode - if set to 'auto' the output will use the figure's
width and height; if 'manual' the output will use the PaperPosition
property values
* PaperPosition - used when PaperPositionMode is auto

Also, the print command takes an optional resolution flag (-r) that
specifies the dots per inch. This setting also impacts the width/height
of the output. The documentation describes the defaults if you don't
specify it. Passing a value of 0 (-r0) tells print to use the screen
resolution.

If you're trying to get the output to match the onscreen figure size,
then this should work for you:
   set(gcf, 'PaperPositionMode', 'auto');
   print(gcf, '-dtiffn', '-r0', 'output.tif')


Hope that helps
--

Richard Quist
Software Developer
The MathWorks, Inc.

Subject: Printing a figure to file problem

From: Yoav Rubin

Date: 24 Oct, 2007 13:10:14

Message: 3 of 10

Richard Quist <rquist_nospam@mathworks.com> wrote in message
<ffn9vv$qa3$1@fred.mathworks.com>...
> Yoav Rubin wrote:
> > Hi All,
> > I am trying to print a figure that has in it an image to a
> > file, I am using the commands:
> > axes(theFigure);
> > print('-dtiffn','myTiff.tiff');
> >
> > but it results in partial image saving, the image itself is
> > 512x512, but the saved file is an image of 473 x 355.
> >
> > Ive tried either with or without '-noui', but the result
> > remained the same.
> > Does anyone has any idea?
> >
> > thanks
> >
> > Yoav
> Is the issue that the resulting file is just smaller in
size or that
> some portion of the image is truncated from the file?
>
> Generally, the properties to look at on the figure that
affect this are:
> * PaperPositionMode - if set to 'auto' the output will
use the figure's
> width and height; if 'manual' the output will use the
PaperPosition
> property values
> * PaperPosition - used when PaperPositionMode is auto
>
> Also, the print command takes an optional resolution flag
(-r) that
> specifies the dots per inch. This setting also impacts the
width/height
> of the output. The documentation describes the defaults if
you don't
> specify it. Passing a value of 0 (-r0) tells print to use
the screen
> resolution.
>
> If you're trying to get the output to match the onscreen
figure size,
> then this should work for you:
> set(gcf, 'PaperPositionMode', 'auto');
> print(gcf, '-dtiffn', '-r0', 'output.tif')
>
>
> Hope that helps
> --
>
> Richard Quist
> Software Developer
> The MathWorks, Inc.


Richard,
I didn't explain myself correctly, actually I am trying to
print the contents of an axis control. The created file is
not a scaled down version of the image on the axis, but
partial view of that image. I've tried your suggestion andit
resulted in a file that contains the entire figure that
holds all of my application.
Is there a way to save all the image in the axis? (again,
sorry for the confusion)

thanks
Yoav

Subject: Printing a figure to file problem

From: Richard Quist

Date: 24 Oct, 2007 13:39:12

Message: 4 of 10

Yoav Rubin wrote:
> Richard Quist <rquist_nospam@mathworks.com> wrote in message
> <ffn9vv$qa3$1@fred.mathworks.com>...
>> Yoav Rubin wrote:
>>> Hi All,
>>> I am trying to print a figure that has in it an image to a
>>> file, I am using the commands:
>>> axes(theFigure);
>>> print('-dtiffn','myTiff.tiff');
>>>
>>> but it results in partial image saving, the image itself is
>>> 512x512, but the saved file is an image of 473 x 355.
>>>
>>> Ive tried either with or without '-noui', but the result
>>> remained the same.
>>> Does anyone has any idea?
>>>
>>> thanks
>>>
>>> Yoav
>> Is the issue that the resulting file is just smaller in
> size or that
>> some portion of the image is truncated from the file?
>>
>> Generally, the properties to look at on the figure that
> affect this are:
>> * PaperPositionMode - if set to 'auto' the output will
> use the figure's
>> width and height; if 'manual' the output will use the
> PaperPosition
>> property values
>> * PaperPosition - used when PaperPositionMode is auto
>>
>> Also, the print command takes an optional resolution flag
> (-r) that
>> specifies the dots per inch. This setting also impacts the
> width/height
>> of the output. The documentation describes the defaults if
> you don't
>> specify it. Passing a value of 0 (-r0) tells print to use
> the screen
>> resolution.
>>
>> If you're trying to get the output to match the onscreen
> figure size,
>> then this should work for you:
>> set(gcf, 'PaperPositionMode', 'auto');
>> print(gcf, '-dtiffn', '-r0', 'output.tif')
>>
>>
>> Hope that helps
>> --
>>
>> Richard Quist
>> Software Developer
>> The MathWorks, Inc.
>
>
> Richard,
> I didn't explain myself correctly, actually I am trying to
> print the contents of an axis control. The created file is
> not a scaled down version of the image on the axis, but
> partial view of that image. I've tried your suggestion andit
> resulted in a file that contains the entire figure that
> holds all of my application.
> Is there a way to save all the image in the axis? (again,
> sorry for the confusion)
>
> thanks
> Yoav

Printing currently only works at the figure level. One possible
alternative is to copy just the axis to a second figure using copyobj
   and print that.

--

Richard Quist
Software Developer
The MathWorks, Inc.

Subject: Printing a figure to file problem

From: Michael Wild

Date: 24 Oct, 2007 13:55:58

Message: 5 of 10

Yoav Rubin wrote:
> Richard Quist <rquist_nospam@mathworks.com> wrote in message
> <ffn9vv$qa3$1@fred.mathworks.com>...
>> Yoav Rubin wrote:
>>> Hi All,
>>> I am trying to print a figure that has in it an image to a
>>> file, I am using the commands:
>>> axes(theFigure);
>>> print('-dtiffn','myTiff.tiff');
>>>
>>> but it results in partial image saving, the image itself is
>>> 512x512, but the saved file is an image of 473 x 355.
>>>
>>> Ive tried either with or without '-noui', but the result
>>> remained the same.
>>> Does anyone has any idea?
>>>
>>> thanks
>>>
>>> Yoav
>> Is the issue that the resulting file is just smaller in
> size or that
>> some portion of the image is truncated from the file?
>>
>> Generally, the properties to look at on the figure that
> affect this are:
>> * PaperPositionMode - if set to 'auto' the output will
> use the figure's
>> width and height; if 'manual' the output will use the
> PaperPosition
>> property values
>> * PaperPosition - used when PaperPositionMode is auto
>>
>> Also, the print command takes an optional resolution flag
> (-r) that
>> specifies the dots per inch. This setting also impacts the
> width/height
>> of the output. The documentation describes the defaults if
> you don't
>> specify it. Passing a value of 0 (-r0) tells print to use
> the screen
>> resolution.
>>
>> If you're trying to get the output to match the onscreen
> figure size,
>> then this should work for you:
>> set(gcf, 'PaperPositionMode', 'auto');
>> print(gcf, '-dtiffn', '-r0', 'output.tif')
>>
>>
>> Hope that helps
>> --
>>
>> Richard Quist
>> Software Developer
>> The MathWorks, Inc.
>
>
> Richard,
> I didn't explain myself correctly, actually I am trying to
> print the contents of an axis control. The created file is
> not a scaled down version of the image on the axis, but
> partial view of that image. I've tried your suggestion andit
> resulted in a file that contains the entire figure that
> holds all of my application.
> Is there a way to save all the image in the axis? (again,
> sorry for the confusion)
>
> thanks
> Yoav


have a look at the copyobj function. it might help you. create a figure
with visible='off' and then copy the axes into it using copyobj and then
print it. when finished delete the figure.

perhaps not optimal but it might help.

hth

michael

Subject: Printing a figure to file problem

From: Yoav Rubin

Date: 30 Oct, 2007 11:14:21

Message: 6 of 10

Michael Wild <themiwi@student.ethz.ch> wrote in message
<471f4f04@news1-rz-ap.ethz.ch>...
> Yoav Rubin wrote:
> > Richard Quist <rquist_nospam@mathworks.com> wrote in message
> > <ffn9vv$qa3$1@fred.mathworks.com>...
> >> Yoav Rubin wrote:
> >>> Hi All,
> >>> I am trying to print a figure that has in it an image to a
> >>> file, I am using the commands:
> >>> axes(theFigure);
> >>> print('-dtiffn','myTiff.tiff');
> >>>
> >>> but it results in partial image saving, the image
itself is
> >>> 512x512, but the saved file is an image of 473 x 355.
> >>>
> >>> Ive tried either with or without '-noui', but the result
> >>> remained the same.
> >>> Does anyone has any idea?
> >>>
> >>> thanks
> >>>
> >>> Yoav
> >> Is the issue that the resulting file is just smaller in
> > size or that
> >> some portion of the image is truncated from the file?
> >>
> >> Generally, the properties to look at on the figure that
> > affect this are:
> >> * PaperPositionMode - if set to 'auto' the output will
> > use the figure's
> >> width and height; if 'manual' the output will use the
> > PaperPosition
> >> property values
> >> * PaperPosition - used when PaperPositionMode is auto
> >>
> >> Also, the print command takes an optional resolution flag
> > (-r) that
> >> specifies the dots per inch. This setting also impacts the
> > width/height
> >> of the output. The documentation describes the defaults if
> > you don't
> >> specify it. Passing a value of 0 (-r0) tells print to use
> > the screen
> >> resolution.
> >>
> >> If you're trying to get the output to match the onscreen
> > figure size,
> >> then this should work for you:
> >> set(gcf, 'PaperPositionMode', 'auto');
> >> print(gcf, '-dtiffn', '-r0', 'output.tif')
> >>
> >>
> >> Hope that helps
> >> --
> >>
> >> Richard Quist
> >> Software Developer
> >> The MathWorks, Inc.
> >
> >
> > Richard,
> > I didn't explain myself correctly, actually I am trying to
> > print the contents of an axis control. The created file is
> > not a scaled down version of the image on the axis, but
> > partial view of that image. I've tried your suggestion andit
> > resulted in a file that contains the entire figure that
> > holds all of my application.
> > Is there a way to save all the image in the axis? (again,
> > sorry for the confusion)
> >
> > thanks
> > Yoav
>
>
> have a look at the copyobj function. it might help you.
create a figure
> with visible='off' and then copy the axes into it using
copyobj and then
> print it. when finished delete the figure.
>
> perhaps not optimal but it might help.
>
> hth
>
> michael
Hi,

I've tried to do as suggested - I've created an invisible
figure and used copyobj like this:
copyobj(myAxisHandle,theNewFigureHandle)

and indeed a new figure was created, and it displayed the
axis properly, but after doing the previously described
commands :

set(gcf, 'PaperPositionMode', 'auto');
print( '-dtiffn', '-r0','-noui',tiffFileName);

the created tiff is still only a part of the axis as is
presented on the figure - is there another idea that i can
try so I will print the entire axis?

thanks

Yoav

Subject: Printing a figure to file problem

From: Richard Quist

Date: 30 Oct, 2007 13:03:20

Message: 7 of 10

Yoav Rubin wrote:
> Michael Wild <themiwi@student.ethz.ch> wrote in message
> <471f4f04@news1-rz-ap.ethz.ch>...
>> Yoav Rubin wrote:
>>> Richard Quist <rquist_nospam@mathworks.com> wrote in message
>>> <ffn9vv$qa3$1@fred.mathworks.com>...
>>>> Yoav Rubin wrote:
>>>>> Hi All,
>>>>> I am trying to print a figure that has in it an image to a
>>>>> file, I am using the commands:
>>>>> axes(theFigure);
>>>>> print('-dtiffn','myTiff.tiff');
>>>>>
>>>>> but it results in partial image saving, the image
> itself is
>>>>> 512x512, but the saved file is an image of 473 x 355.
>>>>>
>>>>> Ive tried either with or without '-noui', but the result
>>>>> remained the same.
>>>>> Does anyone has any idea?
>>>>>
>>>>> thanks
>>>>>
>>>>> Yoav
>>>> Is the issue that the resulting file is just smaller in
>>> size or that
>>>> some portion of the image is truncated from the file?
>>>>
>>>> Generally, the properties to look at on the figure that
>>> affect this are:
>>>> * PaperPositionMode - if set to 'auto' the output will
>>> use the figure's
>>>> width and height; if 'manual' the output will use the
>>> PaperPosition
>>>> property values
>>>> * PaperPosition - used when PaperPositionMode is auto
>>>>
>>>> Also, the print command takes an optional resolution flag
>>> (-r) that
>>>> specifies the dots per inch. This setting also impacts the
>>> width/height
>>>> of the output. The documentation describes the defaults if
>>> you don't
>>>> specify it. Passing a value of 0 (-r0) tells print to use
>>> the screen
>>>> resolution.
>>>>
>>>> If you're trying to get the output to match the onscreen
>>> figure size,
>>>> then this should work for you:
>>>> set(gcf, 'PaperPositionMode', 'auto');
>>>> print(gcf, '-dtiffn', '-r0', 'output.tif')
>>>>
>>>>
>>>> Hope that helps
>>>> --
>>>>
>>>> Richard Quist
>>>> Software Developer
>>>> The MathWorks, Inc.
>>>
>>> Richard,
>>> I didn't explain myself correctly, actually I am trying to
>>> print the contents of an axis control. The created file is
>>> not a scaled down version of the image on the axis, but
>>> partial view of that image. I've tried your suggestion andit
>>> resulted in a file that contains the entire figure that
>>> holds all of my application.
>>> Is there a way to save all the image in the axis? (again,
>>> sorry for the confusion)
>>>
>>> thanks
>>> Yoav
>>
>> have a look at the copyobj function. it might help you.
> create a figure
>> with visible='off' and then copy the axes into it using
> copyobj and then
>> print it. when finished delete the figure.
>>
>> perhaps not optimal but it might help.
>>
>> hth
>>
>> michael
> Hi,
>
> I've tried to do as suggested - I've created an invisible
> figure and used copyobj like this:
> copyobj(myAxisHandle,theNewFigureHandle)
>
> and indeed a new figure was created, and it displayed the
> axis properly, but after doing the previously described
> commands :
>
> set(gcf, 'PaperPositionMode', 'auto');
> print( '-dtiffn', '-r0','-noui',tiffFileName);
>
> the created tiff is still only a part of the axis as is
> presented on the figure - is there another idea that i can
> try so I will print the entire axis?
>
> thanks
>
> Yoav

We probably need more specifics to understand what's going on. For
example, the following works just fine for me to read in a 512x512
image, stick it into an axes that fills the figure, add a dummy
uicontrol and create a tiff file that contains the entire image:
   figure('paperpositionmode', 'auto');
   img = imread('512x512.jpg');
   image(img);
   uicontrol;
   % turn off labels & tick marks and
   % make axes fill the figure
   axis off;
   set(gca, 'position', [0 0 1 1]);
   print('-dtiffn', '-noui', '-r0', 'test.tif');

How does this compare to the code you use to construct your figure?

--

Richard Quist
Software Developer
The MathWorks, Inc.

Subject: Printing a figure to file problem

From: Yoav Rubin

Date: 30 Oct, 2007 13:47:51

Message: 8 of 10

Richard Quist <rquist_nospam@mathworks.com> wrote in message
<fg7a2o$h35$1@fred.mathworks.com>...
> Yoav Rubin wrote:
> > Michael Wild <themiwi@student.ethz.ch> wrote in message
> > <471f4f04@news1-rz-ap.ethz.ch>...
> >> Yoav Rubin wrote:
> >>> Richard Quist <rquist_nospam@mathworks.com> wrote in
message
> >>> <ffn9vv$qa3$1@fred.mathworks.com>...
> >>>> Yoav Rubin wrote:
> >>>>> Hi All,
> >>>>> I am trying to print a figure that has in it an
image to a
> >>>>> file, I am using the commands:
> >>>>> axes(theFigure);
> >>>>> print('-dtiffn','myTiff.tiff');
> >>>>>
> >>>>> but it results in partial image saving, the image
> > itself is
> >>>>> 512x512, but the saved file is an image of 473 x 355.
> >>>>>
> >>>>> Ive tried either with or without '-noui', but the result
> >>>>> remained the same.
> >>>>> Does anyone has any idea?
> >>>>>
> >>>>> thanks
> >>>>>
> >>>>> Yoav
> >>>> Is the issue that the resulting file is just smaller in
> >>> size or that
> >>>> some portion of the image is truncated from the file?
> >>>>
> >>>> Generally, the properties to look at on the figure that
> >>> affect this are:
> >>>> * PaperPositionMode - if set to 'auto' the output will
> >>> use the figure's
> >>>> width and height; if 'manual' the output will use the
> >>> PaperPosition
> >>>> property values
> >>>> * PaperPosition - used when PaperPositionMode is auto
> >>>>
> >>>> Also, the print command takes an optional resolution flag
> >>> (-r) that
> >>>> specifies the dots per inch. This setting also
impacts the
> >>> width/height
> >>>> of the output. The documentation describes the
defaults if
> >>> you don't
> >>>> specify it. Passing a value of 0 (-r0) tells print to use
> >>> the screen
> >>>> resolution.
> >>>>
> >>>> If you're trying to get the output to match the onscreen
> >>> figure size,
> >>>> then this should work for you:
> >>>> set(gcf, 'PaperPositionMode', 'auto');
> >>>> print(gcf, '-dtiffn', '-r0', 'output.tif')
> >>>>
> >>>>
> >>>> Hope that helps
> >>>> --
> >>>>
> >>>> Richard Quist
> >>>> Software Developer
> >>>> The MathWorks, Inc.
> >>>
> >>> Richard,
> >>> I didn't explain myself correctly, actually I am trying to
> >>> print the contents of an axis control. The created file is
> >>> not a scaled down version of the image on the axis, but
> >>> partial view of that image. I've tried your suggestion
andit
> >>> resulted in a file that contains the entire figure that
> >>> holds all of my application.
> >>> Is there a way to save all the image in the axis? (again,
> >>> sorry for the confusion)
> >>>
> >>> thanks
> >>> Yoav
> >>
> >> have a look at the copyobj function. it might help you.
> > create a figure
> >> with visible='off' and then copy the axes into it using
> > copyobj and then
> >> print it. when finished delete the figure.
> >>
> >> perhaps not optimal but it might help.
> >>
> >> hth
> >>
> >> michael
> > Hi,
> >
> > I've tried to do as suggested - I've created an invisible
> > figure and used copyobj like this:
> > copyobj(myAxisHandle,theNewFigureHandle)
> >
> > and indeed a new figure was created, and it displayed the
> > axis properly, but after doing the previously described
> > commands :
> >
> > set(gcf, 'PaperPositionMode', 'auto');
> > print( '-dtiffn', '-r0','-noui',tiffFileName);
> >
> > the created tiff is still only a part of the axis as is
> > presented on the figure - is there another idea that i can
> > try so I will print the entire axis?
> >
> > thanks
> >
> > Yoav
>
> We probably need more specifics to understand what's going
on. For
> example, the following works just fine for me to read in a
512x512
> image, stick it into an axes that fills the figure, add a
dummy
> uicontrol and create a tiff file that contains the entire
image:
> figure('paperpositionmode', 'auto');
> img = imread('512x512.jpg');
> image(img);
> uicontrol;
> % turn off labels & tick marks and
> % make axes fill the figure
> axis off;
> set(gca, 'position', [0 0 1 1]);
> print('-dtiffn', '-noui', '-r0', 'test.tif');
>
> How does this compare to the code you use to construct
your figure?
>
> --
>
> Richard Quist
> Software Developer
> The MathWorks, Inc.

Richard,
Thanks for your prompt response, here is the code I use to
construct my figure:

tmpFigure = figure('Visible','off');
copyobj(the_axis_I_want_to_print_handle,tmpFigure);
set(gcf, 'PaperPositionMode', 'auto');
print( '-dtiffn', '-r0','-noui','myTiff.tif');

the 'the_axis_I_want_to_print_handle' is a handle to an axis
that holds within in an image and some other things I draw
on it - lines and rectangles mostly, therefore I am using
copyobj and not re-open the image in the new figure.

I hope my response helped to clarify my question

Thanks

Yoav

Subject: Printing a figure to file problem

From: Richard Quist

Date: 30 Oct, 2007 13:53:19

Message: 9 of 10

Yoav Rubin wrote:
> Richard Quist <rquist_nospam@mathworks.com> wrote in message
> <fg7a2o$h35$1@fred.mathworks.com>...
>> Yoav Rubin wrote:
>>> Michael Wild <themiwi@student.ethz.ch> wrote in message
>>> <471f4f04@news1-rz-ap.ethz.ch>...
>>>> Yoav Rubin wrote:
>>>>> Richard Quist <rquist_nospam@mathworks.com> wrote in
> message
>>>>> <ffn9vv$qa3$1@fred.mathworks.com>...
>>>>>> Yoav Rubin wrote:
>>>>>>> Hi All,
>>>>>>> I am trying to print a figure that has in it an
> image to a
>>>>>>> file, I am using the commands:
>>>>>>> axes(theFigure);
>>>>>>> print('-dtiffn','myTiff.tiff');
>>>>>>>
>>>>>>> but it results in partial image saving, the image
>>> itself is
>>>>>>> 512x512, but the saved file is an image of 473 x 355.
>>>>>>>
>>>>>>> Ive tried either with or without '-noui', but the result
>>>>>>> remained the same.
>>>>>>> Does anyone has any idea?
>>>>>>>
>>>>>>> thanks
>>>>>>>
>>>>>>> Yoav
>>>>>> Is the issue that the resulting file is just smaller in
>>>>> size or that
>>>>>> some portion of the image is truncated from the file?
>>>>>>
>>>>>> Generally, the properties to look at on the figure that
>>>>> affect this are:
>>>>>> * PaperPositionMode - if set to 'auto' the output will
>>>>> use the figure's
>>>>>> width and height; if 'manual' the output will use the
>>>>> PaperPosition
>>>>>> property values
>>>>>> * PaperPosition - used when PaperPositionMode is auto
>>>>>>
>>>>>> Also, the print command takes an optional resolution flag
>>>>> (-r) that
>>>>>> specifies the dots per inch. This setting also
> impacts the
>>>>> width/height
>>>>>> of the output. The documentation describes the
> defaults if
>>>>> you don't
>>>>>> specify it. Passing a value of 0 (-r0) tells print to use
>>>>> the screen
>>>>>> resolution.
>>>>>>
>>>>>> If you're trying to get the output to match the onscreen
>>>>> figure size,
>>>>>> then this should work for you:
>>>>>> set(gcf, 'PaperPositionMode', 'auto');
>>>>>> print(gcf, '-dtiffn', '-r0', 'output.tif')
>>>>>>
>>>>>>
>>>>>> Hope that helps
>>>>>> --
>>>>>>
>>>>>> Richard Quist
>>>>>> Software Developer
>>>>>> The MathWorks, Inc.
>>>>> Richard,
>>>>> I didn't explain myself correctly, actually I am trying to
>>>>> print the contents of an axis control. The created file is
>>>>> not a scaled down version of the image on the axis, but
>>>>> partial view of that image. I've tried your suggestion
> andit
>>>>> resulted in a file that contains the entire figure that
>>>>> holds all of my application.
>>>>> Is there a way to save all the image in the axis? (again,
>>>>> sorry for the confusion)
>>>>>
>>>>> thanks
>>>>> Yoav
>>>> have a look at the copyobj function. it might help you.
>>> create a figure
>>>> with visible='off' and then copy the axes into it using
>>> copyobj and then
>>>> print it. when finished delete the figure.
>>>>
>>>> perhaps not optimal but it might help.
>>>>
>>>> hth
>>>>
>>>> michael
>>> Hi,
>>>
>>> I've tried to do as suggested - I've created an invisible
>>> figure and used copyobj like this:
>>> copyobj(myAxisHandle,theNewFigureHandle)
>>>
>>> and indeed a new figure was created, and it displayed the
>>> axis properly, but after doing the previously described
>>> commands :
>>>
>>> set(gcf, 'PaperPositionMode', 'auto');
>>> print( '-dtiffn', '-r0','-noui',tiffFileName);
>>>
>>> the created tiff is still only a part of the axis as is
>>> presented on the figure - is there another idea that i can
>>> try so I will print the entire axis?
>>>
>>> thanks
>>>
>>> Yoav
>> We probably need more specifics to understand what's going
> on. For
>> example, the following works just fine for me to read in a
> 512x512
>> image, stick it into an axes that fills the figure, add a
> dummy
>> uicontrol and create a tiff file that contains the entire
> image:
>> figure('paperpositionmode', 'auto');
>> img = imread('512x512.jpg');
>> image(img);
>> uicontrol;
>> % turn off labels & tick marks and
>> % make axes fill the figure
>> axis off;
>> set(gca, 'position', [0 0 1 1]);
>> print('-dtiffn', '-noui', '-r0', 'test.tif');
>>
>> How does this compare to the code you use to construct
> your figure?
>> --
>>
>> Richard Quist
>> Software Developer
>> The MathWorks, Inc.
>
> Richard,
> Thanks for your prompt response, here is the code I use to
> construct my figure:
>
> tmpFigure = figure('Visible','off');
> copyobj(the_axis_I_want_to_print_handle,tmpFigure);
> set(gcf, 'PaperPositionMode', 'auto');
> print( '-dtiffn', '-r0','-noui','myTiff.tif');
>
> the 'the_axis_I_want_to_print_handle' is a handle to an axis
> that holds within in an image and some other things I draw
> on it - lines and rectangles mostly, therefore I am using
> copyobj and not re-open the image in the new figure.
>
> I hope my response helped to clarify my question
>
> Thanks
>
> Yoav

It will probably be best at this point to contact support to figure out
why you're getting this behavior.
--

Richard Quist
Software Developer
The MathWorks, Inc.

Subject: Printing a figure to file problem

From: Yoav Rubin

Date: 31 Oct, 2007 11:28:40

Message: 10 of 10

Richard Quist <rquist_nospam@mathworks.com> wrote in message
<fg7d0f$s4o$1@fred.mathworks.com>...
> Yoav Rubin wrote:
> > Richard Quist <rquist_nospam@mathworks.com> wrote in message
> > <fg7a2o$h35$1@fred.mathworks.com>...
> >> Yoav Rubin wrote:
> >>> Michael Wild <themiwi@student.ethz.ch> wrote in message
> >>> <471f4f04@news1-rz-ap.ethz.ch>...
> >>>> Yoav Rubin wrote:
> >>>>> Richard Quist <rquist_nospam@mathworks.com> wrote in
> > message
> >>>>> <ffn9vv$qa3$1@fred.mathworks.com>...
> >>>>>> Yoav Rubin wrote:
> >>>>>>> Hi All,
> >>>>>>> I am trying to print a figure that has in it an
> > image to a
> >>>>>>> file, I am using the commands:
> >>>>>>> axes(theFigure);
> >>>>>>> print('-dtiffn','myTiff.tiff');
> >>>>>>>
> >>>>>>> but it results in partial image saving, the image
> >>> itself is
> >>>>>>> 512x512, but the saved file is an image of 473 x 355.
> >>>>>>>
> >>>>>>> Ive tried either with or without '-noui', but the
result
> >>>>>>> remained the same.
> >>>>>>> Does anyone has any idea?
> >>>>>>>
> >>>>>>> thanks
> >>>>>>>
> >>>>>>> Yoav
> >>>>>> Is the issue that the resulting file is just smaller in
> >>>>> size or that
> >>>>>> some portion of the image is truncated from the file?
> >>>>>>
> >>>>>> Generally, the properties to look at on the figure that
> >>>>> affect this are:
> >>>>>> * PaperPositionMode - if set to 'auto' the output will
> >>>>> use the figure's
> >>>>>> width and height; if 'manual' the output will use the
> >>>>> PaperPosition
> >>>>>> property values
> >>>>>> * PaperPosition - used when PaperPositionMode is auto
> >>>>>>
> >>>>>> Also, the print command takes an optional
resolution flag
> >>>>> (-r) that
> >>>>>> specifies the dots per inch. This setting also
> > impacts the
> >>>>> width/height
> >>>>>> of the output. The documentation describes the
> > defaults if
> >>>>> you don't
> >>>>>> specify it. Passing a value of 0 (-r0) tells print
to use
> >>>>> the screen
> >>>>>> resolution.
> >>>>>>
> >>>>>> If you're trying to get the output to match the
onscreen
> >>>>> figure size,
> >>>>>> then this should work for you:
> >>>>>> set(gcf, 'PaperPositionMode', 'auto');
> >>>>>> print(gcf, '-dtiffn', '-r0', 'output.tif')
> >>>>>>
> >>>>>>
> >>>>>> Hope that helps
> >>>>>> --
> >>>>>>
> >>>>>> Richard Quist
> >>>>>> Software Developer
> >>>>>> The MathWorks, Inc.
> >>>>> Richard,
> >>>>> I didn't explain myself correctly, actually I am
trying to
> >>>>> print the contents of an axis control. The created
file is
> >>>>> not a scaled down version of the image on the axis, but
> >>>>> partial view of that image. I've tried your suggestion
> > andit
> >>>>> resulted in a file that contains the entire figure that
> >>>>> holds all of my application.
> >>>>> Is there a way to save all the image in the axis?
(again,
> >>>>> sorry for the confusion)
> >>>>>
> >>>>> thanks
> >>>>> Yoav
> >>>> have a look at the copyobj function. it might help you.
> >>> create a figure
> >>>> with visible='off' and then copy the axes into it using
> >>> copyobj and then
> >>>> print it. when finished delete the figure.
> >>>>
> >>>> perhaps not optimal but it might help.
> >>>>
> >>>> hth
> >>>>
> >>>> michael
> >>> Hi,
> >>>
> >>> I've tried to do as suggested - I've created an invisible
> >>> figure and used copyobj like this:
> >>> copyobj(myAxisHandle,theNewFigureHandle)
> >>>
> >>> and indeed a new figure was created, and it displayed the
> >>> axis properly, but after doing the previously described
> >>> commands :
> >>>
> >>> set(gcf, 'PaperPositionMode', 'auto');
> >>> print( '-dtiffn', '-r0','-noui',tiffFileName);
> >>>
> >>> the created tiff is still only a part of the axis as is
> >>> presented on the figure - is there another idea that i can
> >>> try so I will print the entire axis?
> >>>
> >>> thanks
> >>>
> >>> Yoav
> >> We probably need more specifics to understand what's going
> > on. For
> >> example, the following works just fine for me to read in a
> > 512x512
> >> image, stick it into an axes that fills the figure, add a
> > dummy
> >> uicontrol and create a tiff file that contains the entire
> > image:
> >> figure('paperpositionmode', 'auto');
> >> img = imread('512x512.jpg');
> >> image(img);
> >> uicontrol;
> >> % turn off labels & tick marks and
> >> % make axes fill the figure
> >> axis off;
> >> set(gca, 'position', [0 0 1 1]);
> >> print('-dtiffn', '-noui', '-r0', 'test.tif');
> >>
> >> How does this compare to the code you use to construct
> > your figure?
> >> --
> >>
> >> Richard Quist
> >> Software Developer
> >> The MathWorks, Inc.
> >
> > Richard,
> > Thanks for your prompt response, here is the code I use to
> > construct my figure:
> >
> > tmpFigure = figure('Visible','off');
> > copyobj(the_axis_I_want_to_print_handle,tmpFigure);
> > set(gcf, 'PaperPositionMode', 'auto');
> > print( '-dtiffn', '-r0','-noui','myTiff.tif');
> >
> > the 'the_axis_I_want_to_print_handle' is a handle to an axis
> > that holds within in an image and some other things I draw
> > on it - lines and rectangles mostly, therefore I am using
> > copyobj and not re-open the image in the new figure.
> >
> > I hope my response helped to clarify my question
> >
> > Thanks
> >
> > Yoav
>
> It will probably be best at this point to contact support
to figure out
> why you're getting this behavior.
> --
>
> Richard Quist
> Software Developer
> The MathWorks, Inc.

Hi, I have found the problem - I didn't pass the figure
handle as a parameter in the call to the print function. It
seems that setting the figure as the current one wasn't enough.

thanks for all the help

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us