Doug's MATLAB Video Tutorials

April 21st, 2010

Copying a figure to the clipboard

Just a little trick that helps you get MATLAB figures easily into other programs by copying them to the clipboard. Could easily be made into a shortcut on the MATLAB toolbar.

12 Responses to “Copying a figure to the clipboard”

  1. Alan Marcel replied on :

    Hello Doug! I’ve followed you at twitter and I’ve found many interesting MatLab tips. Thank you for sharing your knowledge with us! Keep posting!

  2. Roy replied on :

    Is there a way to do something similar on non-Windows platforms?

  3. dhull replied on :

    @Alan,

    Thanks!

    @Roy,

    Nope, sorry!

  4. lzuxz replied on :

    Great jobs.
    But if we have multi figure in one script file,How can we handle the clipboard?

  5. oh replied on :
    >> print -dmeta
    ??? Error using ==> inputcheck>LocalCheckDevice at 250
    Error using ==> inputcheck>LocalCheckDevice at 250
    Illegal device option, '-dmeta', specified.
    
    Error in ==> inputcheck at 45
                    [ pj, devIndex ] = LocalCheckDevice( pj, cur_arg, devices );
    
    Error in ==> print at 172
        [pj, devices, options ] = inputcheck( pj, varargin{:} );
    

    My Mac version 10.4.8 and Matlab 7.5.0(R2007b)
    What’s the problem the above?

  6. matt fig replied on :

    @oh,

    As Doug stated above (comment #2), this works on Windows only. Also, you could read the help for PRINT, which specifies the -dmeta flag under the heading:

    Microsoft Windows system device driver options

  7. dhull replied on :

    @lzuxz,

    The clipboard only supports one item on the stack at a time.

    Doug

  8. frank replied on :

    Good trick!
    It’s a pity that the displaying quality of zoom-out figure is poorer than the one obtained by the operation “copy figure” in the menu of figuret.

  9. Lutfy replied on :

    Is there anyway to read the figure back from the clipboard into matlab?

  10. dhull replied on :

    @Lutfy,

    What would it mean to ‘read the figure back from the clipboard into MATLAB’?

    Doug

  11. Daniel replied on :

    Is there a way to get

     print -dmeta 

    to preserve the figure color?

    For example, the following creates a figure with a black background:

    colordef black
    figure
    membrane
    print -dmeta
    

    but the copied figure has a white background.

    Thanks,
    Dan

  12. dhull replied on :

    @Daniel,

    Check on ‘inverthardcopy’.

    Doug

Leave a Reply

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>

If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).


MathWorks

Doug Hull is a proud MathWorker who is on a mission to help you with MATLAB.

Doug's picture

These postings are the author's and don't necessarily represent the opinions of The MathWorks.