1

I have a problem, where I already have a handle to a figure created, and I want to somehow now draw a line, given that handle. For example, I have:

f1 = figure(1);
a1 = gca;

For commands like plot and surf, I can pass the axes and/or figure handles to tell it to plot to that particular figure. However, how do you do this with the line command? There does not seem to be a way as far as I know... thank you.

4

2 回答 2

4

The line function, like patch is a low level function. The plot command are built on top of these. However you can do this:

f1 = figure(1);
a1 = gca;
line([0 1],[0 1],'Parent',a1); % Parent has to be an axis handle

You can find more line options here: line properties or type doc Line_Props in the Matlab command window.

于 2013-05-22T15:02:17.440 回答
2

Have you tried the `Parent' property?

line( x, y, 'Parent', a1 ); 

see line properties for more info.

于 2013-05-22T14:56:12.827 回答