Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 800831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:20:58+00:00 2026-05-14T23:20:58+00:00

I have a strange problem that the plot overlaps in the graph, but not

  • 0

I have a strange problem that the plot overlaps in the graph, but not in the image in the same axis.

I am sure I didn’t leave hold on somewhere or else it will overlap in the image itself as well.

EDIT : I want to get rid of the blue overlapped lines, I only want one blue line to be present in that pic.

Here is a sample :

(NOTE : The black image is a RGB image but I didn’t plot that atm, so it IS meant to be a transition from black to white on the graph. )

alt text http://img541.imageshack.us/img541/3212/parabolaaaaa.png

Some part of the code :

   for K=1:23

    hold on
    I = fig.img.(['p' num2str(K)]);
    bw=(I);
    imshow(bw)

    ss = bwlabel(bw);
    s = regionprops(ss,'centroid');


    centroids{K} = cat(1,s.Centroid);
    hold(imgca,'on')
    plot(imgca,centroids{K}(:,1), centroids{K}(:,2), 'r*'); hold on;
    x=centroids{K}(:,1);
    y=centroids{K}(:,2);
    points=plot(x,y,'go',x,y,'rx');

    hold on
    axis on
    axis fill
    ccentroids = cat(1,centroids{:});
    C1=ccentroids(:,1);
    C2=ccentroids(:,2);
    set(points,'XData',C1,'YData',C2);

    .
    .  
    .

    p= polyfit(x2,y2,2)
    parabola_x = linspace(-250,640,500);
    parabola_polyval = polyval(p,parabola_x);
    plot(parabola_x,parabola_polyval,'b-');
    .
    .  
    .
    end

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T23:20:58+00:00Added an answer on May 14, 2026 at 11:20 pm

    The reason you have multiple blue lines is because you plot one for every pass through your loop with the line:

    plot(parabola_x,parabola_polyval,'b-');
    

    In fact, you are plotting everything (the images, points, and lines) over and over again in your loop without clearing the old ones.

    You should instead initialize plot objects outside of your for loop and use the SET command to update them within the loop, instead of just replotting them. I gave one example of this in this answer to a question you previously asked where I discuss using the handles to plot objects to modify them. For the sample code you give here, you could do something like this:

    hImage = imshow(bw(fig.img.p1));  %# Initialize the image
    hold on;                          %# Add to the existing plot
    hStar = plot(nan,nan,'r*');       %# Initialize the red star
    hPoints = plot(nan,nan,'go',...   %# Initialize the other points
                   nan,nan,'rx');
    hLine = plot(nan,nan,'b-');       %# Initialize the blue line
    
    for K = 1:23
    
      I = fig.img.(['p' num2str(K)]);
      bw = (I);
      set(hImage,'CData',bw);  %# Update the image
    
      ss = bwlabel(bw);
      s = regionprops(ss,'centroid');
      centroids{K} = cat(1,s.Centroid);
      set(hStar,'XData',centroids{K}(:,1),...  %# Update the red star
                'YData',centroids{K}(:,2));
      ccentroids = cat(1,centroids{:});
      C1 = ccentroids(:,1);
      C2 = ccentroids(:,2);
      set(hPoints,'XData',C1,'YData',C2);  %# Update the other points
    
      ...
    
      p = polyfit(x2,y2,2);
      parabola_x = linspace(-250,640,500);
      parabola_polyval = polyval(p,parabola_x);
      set(hLine,'XData',parabola_x,...      %# Update the blue line
                'YData',parabola_polyval);
    
      ...
    
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 388k
  • Answers 388k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I ended up installing the French language pack to my… May 15, 2026 at 12:35 am
  • Editorial Team
    Editorial Team added an answer PostgreSQL allows you to associate configuration settings with databases and… May 15, 2026 at 12:35 am
  • Editorial Team
    Editorial Team added an answer If it can be done in FORTRAN 77, it will… May 15, 2026 at 12:35 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.