How can I select lines in a subplot and delete them?

6 次查看(过去 30 天)
Hello World,
I'm currently struggeling with my figures.
I have a figure saved as FIG-file. After I opened it I want to select a specific subplot in it and delete a specific line object in the subplot.
What I know so far is that I can find all subplots/axes (?):
>> h1 = findobj(gcf,'Type','axes')
and that I can find all line objects in the subplot/axis:
>> h2 = findobj(gca,'Type','line')
But how do I link these two informations? Which one of the output of the first command (h1) is the subplot I want to choose? And which one of the output of the second command (h2) ist the line I want to choose?
As the size of h1 and h2 differs from the number of subplots / number of line objects I can see I'm confused with the output.
Any idea? Sebastian

回答(3 个)

Honglei Chen
Honglei Chen 2012-3-14
If you don't need to automate the process, it's actually easier to do from the figure window. Just click the arrow on the toolbar, and then choose any line from any subplot.

Jan
Jan 2012-3-14
We cannot know which of the handles in h1 is the wanted subplot. It is your turn to define this detail.
So start from scratch: How do you define, which line you want to delete?
  1 个评论
Sebastian Gatzka
Sebastian Gatzka 2012-3-14
There is always a data plot and two line objects.
I want to detete both of the last ones and keep the data plot.
Each time I call the above command for h2 I get round about 18 elements inside h2... So they can't be the two lines?!

请先登录,再进行评论。


Stephen
Stephen 2012-3-14
when you use gca for h2 it will only look in the last axes that was called. you can try recalling the subplot you want, then doing the gca. i.e. subplot(2,3,2) for the 2nd axes in the figure. Then your line should be in h2. Depending on how you plotted the data, it will be in that order in h2 for you to call it and delete it. good luck
  1 个评论
Sebastian Gatzka
Sebastian Gatzka 2012-3-14
The Figure is saved as a FIG-file. If I call any subplot subplot(2,3,2) to it will delete my current subplot.

请先登录,再进行评论。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by