Group Abstract Group Abstract

Message Boards Message Boards

0
|
14.4K Views
|
5 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Displaying Graphics Objects in Loops - How?

Posted 12 years ago

this is a very simple question ... hopefully someone has a quick answer.

suppose I define a simple graphics object and display it ... for example ...

obj = Line[ { {-3, -1}, {3, -1} } ] ;      Graphics[obj]

these 2 lines of code work fine - and I get a Line in Mathematica.

Now ... I want to do the same thing inside a loop, such as a For Loop. But Mathematica gives no output. WHY?? Even if I add a Show command outside the Graphics statement, this still does not work.

For [ j = 1,  j < 3,  j++,   Graphics[obj]
 ]

thanks, Pete

POSTED BY: pete p
5 Replies
Posted 12 years ago

awesome ... that reply is really helpful!! big thanks!!!

POSTED BY: pete p

Rather than use Print, put the Graphics into a TextCell and use CellPrint as in this example:

For[i = 0, i < 5, i++, 
  CellPrint[
   TextCell[Graphics[{Line[{{-3, -1}, {3, -1 + i}}]}], "Text"]]] ;
POSTED BY: David Reiss

Hi David,

I'm struggling with issues similar to those Pete had. I'm trying to use Tooltip[ListLinePlot [.... constructs within various M10 loop constructs without success yet the same syntax (except for Tooltip) works within Manipulate. Could you please explain, or point me to the right area of documentation that explains, why the higher level plot functions produce no output within a For/While loop. Many thanks David M

POSTED BY: David Mackay
Posted 12 years ago
POSTED BY: pete p
Posted 12 years ago
POSTED BY: Luis Ledesma
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard