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

  • Home
  • SEARCH
  • 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 4240706
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T03:12:06+00:00 2026-05-21T03:12:06+00:00

I am wondering if you have good ways to show plots inside a loop

  • 0

I am wondering if you have good ways to show plots inside a loop in mma. Usually, the output of Plot function is not shown, for example in the following code:

For[i = 1, i <= 10, i++, Plot[Sin[i*x], {x, -Pi, Pi}]]

Thanks for your help.

Edit

In connection to my previous question, I already have the For loop, for example, like this For[i = 1, i <= 10, i++, Plot[Sin[i*x], {x, -Pi, Pi}]]. Given this fact, I want to have something like “press any key to continue…” inside the For loop, then refresh the plot every time I press any random key. Could anybody give a complete working code?

  • 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-21T03:12:07+00:00Added an answer on May 21, 2026 at 3:12 am

    Just use Print:

    For[i = 1, i <= 10, i++, Plot[Sin[i*x], {x, -Pi, Pi}] // Print]
    

    or Monitor:

    Monitor[For[i = 1, i <= 10, i++, p = Plot[Sin[i*x], {x, -Pi, Pi}]; 
      Pause[0.5]], p]
    

    (Pause is used here to give some time to view the plot; the loop is pretty fast here. Remove if necessary)

    EDIT
    On request a version that is controlled by mouse clicks on the graph (key presses need the graph to have focus so you need to click anyway)

    Monitor[For[i = 1, i <= 10, , p = Plot[Sin[i*x], {x, -Pi, Pi}]], 
    EventHandler[p, {"MouseDown" :> i++}]]
    

    This is a pretty stupid way to do this. The loop redraws the plot continuously. So, a slightly (but still ugly) version might be:

    s = True;
    Monitor[
     For[i = 1, i <= 10, ,
      If[s,
       (* Put main loop body here*) 
       p = Plot[Sin[i*x], {x, -Pi, Pi}] 
       (* end of main body *) ;
       s = False (* prevents continuous re-evaluating main body *)
       ]
      ]
     , EventHandler[p, {"MouseDown" :> (i++; s = True)}]
     ]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I like jQuery and I was wondering if anyone have used a good plugin
I have a fairly good feel for what MySQL replication can do. I'm wondering
I'm wondering if this is a good design. I have a number of tables
I'm wondering what good ways there would be make assertions about synchronization or something
I have been wondering how to put all the stored procedures on a SQL
I have been wondering what the best practices or ramifications are in setting up
After much googling I have been wondering what the benefits/differences are between mysql and
There is a question I have been wondering about for ages and I was
I have long been wondering why lazy evaluation is useful. I have yet to
Just wondering what little scripts/programs people here have written that helps one with his

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.