Copy Figure Elements to System Clipboard
Mostra commenti meno recenti
Hi,
I frequently use matlab on multiple adjacent computers running their own instances of matlab, and sometimes I want to share a trace or a title or an axis across figures in different computers.
I have third party software (search sharemouse or inputdirector for example) that enables clipboard sharing across multiple computers, so if there is any way that I can copy a figure element to the system clipboard and not just within the plot editing mode's internal version of the clipboard, i'll be good to go.
Perhaps a simpler problem that would be equally useful is if there is some way to copy an entire figure to the clipboard in a way that it can be pasted back into another instance of matlab, rather than as a bitmap for opening in word like the 'copy figure' option enables.
Thanks!
Risposta accettata
Più risposte (1)
Björn
il 18 Set 2013
For the last part you could consider saving the figure as .fig and then copy the file to the other computer. Here you can open de figure with full compatibility and all data preserved.
To display certain parameters of the figure you can use the get function. For example for getting the title you use:
get(get(gca,'title'),'string')
The inner 'get' retrieves the title of the current axes ('gca'). The outer 'get' converts it to a string.
In case you have more figures open then you have to have the axes-handle of figure-handle for the right figure but this is a bit more complicated. If you need that too, just let me know.
3 Commenti
David
il 18 Set 2013
Björn
il 19 Set 2013
Hi David,
If the main problem now is to get it automatically to the clipboard, you can make script that does the following:
function str = clipboard_plot_data(parameters,axes_handle)
[par_nr,~]=size(parameters);
str='';
for i=1:par_nr
if nargin < 2
str_test=get(get(gca,parameters{i}),'string');
str_t=['\' parss '=' str_test ' \' parss '\'];
else
str_test=get(get(axes_handle,parameters{i}),'string');
str_t=['\' parss '=' str_test ' \' parss '\'];
end
str=[str str_t];
end
clipboard('copy',str)
This will copy a string with all the data to the clipboard. You can use
clipboard('paste')
to paste is to the clipboard again. The input parameters of the function are of the form:
parameters={'title';'xlabel';'ylabel'}
If you don't input the axes-handle it will use the current axes.
The actual parameters are located between '\title=' and '\title\' Hence, finding those parts in the string will get you the title.
David
il 24 Set 2013
Categorie
Scopri di più su Creating, Deleting, and Querying Graphics Objects in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!