필터 지우기
필터 지우기

Plot in a new figure

조회 수: 1 (최근 30일)
Filippo
Filippo 2012년 3월 12일
Hi, I explain my problem; I have a figure with 8 subplots and i want that, when i click in a subplot of the figure with mouse, this plot should be copied in a new figure with no other plots. For the moment i do something like this:
set(gcf,'WindowButtonDownFcn',{@f_wbfcn})
function [] = f_wbfcn(varargin)
ch = get(gca,'children');
figure
copyobj(ch,axes);
The subplot is copied in a new figure, but i don't know how can i copy all the proprieties of the plot, like title, legend, label, text, etc... How can i fix it? Can anyone help me?

답변 (2개)

Jacob Halbrooks
Jacob Halbrooks 2012년 3월 12일
With COPYOBJ, you should be able to specify the highest level object to copy, and then that object along with its children will be copied:
ax = axes;
plot(ax,1:10);
set(ax,'Color', [1 0 1]);
f=figure;
copyobj(ax, f);
My experience is that COPYOBJ will copy most properties correctly, but it will not copy callback functions, and there may be other follow-up work to do in the new figure, such as re-position a legend.

Filippo
Filippo 2012년 3월 15일
for the moment it's ok, but i have another question:how can i understand in witch subplot the user have clicked?There's an handle, a variable or something like?
  댓글 수: 1
Matt Kindig
Matt Kindig 2012년 3월 15일
When you click on the subplot, the gca output will be the current axes (subplot). So
h=gca; %this is the handle to the current subplot

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Subplots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by