Message Boards Message Boards

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

Displaying Graphics Objects in Loops - How?

Posted 10 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 10 years ago

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

POSTED BY: pete p
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 10 years ago
POSTED BY: pete p
Posted 10 years ago

You can use the command Table as following

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

I think you want to do something like this

Table[Graphics[Line[{{-3, -1}, {i, -1}}], Axes -> True], {i, 1, 3}]

I hope you've given any idea to solve your problem

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

Group Abstract Group Abstract