フィルターのクリア

How to: Copy/Print (sub)plots to clipboard and pdf

7 ビュー (過去 30 日間)
Hello kity
Hello kity 2013 年 2 月 5 日
コメント済み: AJ 2018 年 12 月 4 日
Hi
I would like to copy a (sub)plot to the clipboard and a pdf file
with and w/o the gui interface.
How can I do that?
thank you
  1 件のコメント
Jan
Jan 2013 年 3 月 21 日
What exactly is "the GUI interface"? Does it inlcude the window borders?

サインインしてコメントする。

回答 (3 件)

Walter Roberson
Walter Roberson 2013 年 2 月 5 日

Hello kity
Hello kity 2013 年 2 月 5 日
編集済み: Hello kity 2013 年 2 月 5 日
I allready found that one. But that is not really what I want. I have 3 subbplots and some edit/statit fields around it. Now it copys all of them at once then it is pretty much minimized when you copy paste it.
I d rather have the option to select the specific subpplot and edit/static fields on the figure.

Ram
Ram 2013 年 3 月 20 日
Try this. While you are generating the subplot, create a uicontextmenu for each axes that allows a right mouse click and choose to copy. Then, write the callback to copy using "print -dmeta" command.
% Commands to create uicontextmenus
for i = 1:length(justAxes)
hcmenu = uicontextmenu;
item = uimenu(hcmenu,'Label','Copy','Callback', @copy_call});
set(justAxes(i),'uicontextmenu',hcmenu);
end
% Now the copy_call function has to create a figure with that plot copied on it. Then upe "print -dmeta" command.
function copy_call(varargin)
currAxes = get(get(get(varargin{1},'parent'),'parent'),'currentAxes');
newFig = figure('visible','off');
newHandle = copyobj(currAxes,newFig);
print(newFig,'-dmeta');
delete(newFig);
% Right mouse click on individual plots and choose the "copy" option. The "print -dmeta" command puts the plot in the clipboard. Use the paste command on to MS Word or other files.
  1 件のコメント
AJ
AJ 2018 年 12 月 4 日
I had mixed luck with this solution. I had to do a few mods to get it to work well.
This is intended to copy an axis from a GUI figure, so this is a callback function for a pushbutton to copy the axis data to the clipboard.
% --- Executes on button press in PB_Copy_to_clipboard.
function PB_Copy_to_clipboard_Callback(hObject, eventdata, handles)
% hObject handle to PB_Copy_to_clipboard (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
hObject.String = 'Copying...'; % Let user know copy is proceding
hObject.BackgroundColor = 'y';
drawnow
newFig = figure('visible','off'); % Create new figure
%newFig.Position(3:4) = [1100 720]; % Make figure bigger
ax1 = subplot(1,1,1); % Create new axis (temporary, for sizing)
ax_new = copyobj(handles.axes1,newFig);
set(ax_new,'units','normalized','position',get(ax1,'position'));
delete(ax1);
print(newFig,'-dmeta'); % Copy to clipboard
delete(newFig);
hObject.String = 'Copy to Clipboard'; % Restore original pushbutton text
hObject.BackgroundColor = 0.94*[1 1 1];

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by