MathGroup Archive 1997

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Graphics Elements

  • To: mathgroup at smc.vnet.net
  • Subject: [mg8817] Re: [mg8779] Graphics Elements
  • From: Allan Hayes <hay at haystack.demon.co.uk>
  • Date: Fri, 26 Sep 1997 00:33:41 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

Edwin Wright <edwin.wright at ns.sympatico.ca>
[mg8779] Graphics Elements

> Does anyone know (Version 2.1.0) how to delete graphics elements
> from an existing graphic using AppendTo?

Edwin:

Consider the following (please enter the inputs to see the pictures)

In[1]:=
gr = Show[Graphics[{Circle[{0,0},1],Line[{{0,0},{1,1}}]}]]

Out[1]=
	-Graphics-
	
The graphics expression
 	Graphics[{Circle[{0,0},1],Line[{{0,0},{1,1}}]}]
has been displayed by using the function Show. The picture is a  
side effect. The output is hidden away in the special symbol  
-Graphics-.
However, we can see it as follows

In[2]:=
InputForm[%]

Out[2]//InputForm=
	Graphics[{Circle[{0, 0}, 1], Line[{{0, 0}, {1, 1}}]}]
	
(It is just the expression that we used Show on; we have called it gr)

Like any other Mathematica expression, we can manipulate  it
In[3]:=
DeleteCases[gr,_Line, Infinity]  (*remove any parts of the form  
Line[...]*)

Out[3]=
	-Graphics-

If we wish we cah see what has been done
In[4]:=
InputForm[%]

Out[4]//InputForm=
	Graphics[{Circle[{0, 0}, 1]}]

We can show the picture that this defines
In[5]:=
Show[%]
Out[5]=
	-Graphics-

We can alter the expression and show it with one line of code

In[6]:=
Show[gr/.Circle[p_,r_]:>{Hue[0],Circle[p-{1,0},r]}]
Out[6]=
	-Graphics-
	
Allan Hayes
hay at haystack.demon.co.uk
http://www.haystack.demon.co.uk/training.html
voice:+44 (0)116 2714198
fax: +44 (0)116 2718642
Leicester,  UK


  • Prev by Date: Re: FindRoot
  • Next by Date: Re: $Prefereces and Cache
  • Previous by thread: Graphics Elements
  • Next by thread: MathLink for Visual Basic Workshop