Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

RE: RE: change PlotStyle in Graphics object after the fact?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg47337] RE: [mg47291] RE: [mg47253] change PlotStyle in Graphics object after the fact?
  • From: Jonas at iui.se
  • Date: Tue, 6 Apr 2004 06:36:20 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

The function Show can change the options of a Graphic, but not the
individual properties of 
plots defined by PlotStyle. Show can be redefined to accept the PlotStyle
option:

Definition

In[1]:=
Unprotect[Show];

In[2]:=
Show::PlotStyleParams="Plot style has to have the same number of styles as \
the Graphic.";

In[3]:=
Show[g_,PlotStyle->op_]:=If[Length[g[[1]]]==Length[op],
    Show[Head[g]@@{MapThread[Prepend,{g[[1]],op}],g[[2]]}],
    Message[Show::PlotStyleParams]]

In[4]:=
Protect[Show];

Testing

In[5]:=
p1=Plot[Sin[x],{x,-Pi,Pi},DisplayFunction->Identity];

In[6]:=
p2=Plot[Cos[x],{x,-Pi,Pi},DisplayFunction->Identity];

In[7]:=
p3=Show[p1,p2,DisplayFunction->$DisplayFunction];

In[8]:=
Show[p3,PlotStyle->{Hue[.3],Hue[.6]}];

To make the redefinition more complete, 

Show[g1_, g2__, PlotStyle -> op_]

could also be defined, applying the PlotStyles to several Graphics objects.
One could also allow for other options at the same time. 

Jonas

> -----Original Message-----
> From: David Park [mailto:djmp at earthlink.net] 
To: mathgroup at smc.vnet.net
> Sent: den 2 april 2004 10:31
> To: mathgroup at smc.vnet.net
> Subject: [mg47337] [mg47291] RE: [mg47253] change PlotStyle in Graphics 
> object after the fact?
> 
> 
> Jose,
> 
> p1 = Plot[x^3, {x, -1, 1}];
> 
> Needs["Graphics`Colors`"]
> 
> Show[Graphics[
>       {Blue, First[p1]}],
>     Axes -> True,
>     PlotRange -> All];
> 
> On your destroyed email address: Spammers and virus generated 
> email ruined my email address, especially since I'm using a 
> modem and the virus generated email was fairly long. I 
> subscribed to a challenge-response system, in my case 
> SpamArrest, and that completely solved the problem. (About 
> once a month an advertiser will actually respond and slip an 
> email through, but I immediately put them on my block list.) 
> It is much better than all these schemes where recipients 
> must decode the email address.
> 
> David Park
> djmp at earthlink.net
> http://home.earthlink.net/~djmp/
> 
> 
> From: jose flanigan [mailto:jflanigan at netzero.net]
To: mathgroup at smc.vnet.net
> To: mathgroup at smc.vnet.net
> 
> Hi,
> 
> I have a number of graphics objects created like
> 
> p1=Plot[f[x],{x,-1,1}]
> p2=Plot[g[x], {x,-1,2}]
> 
> and I was wondering if I can change the PlotStyle on p1 and 
> p2 by doing something like
> 
> p2/.PlotStyle->{new plot style options}
> 
> Any ideas?
> 
> Thanks in advance.
> 
> PS. Please reply to this group. Spammers have destroyed this 
> e-mail address.
> 
> 


  • Prev by Date: Re: webMathematica question
  • Next by Date: RE: combining two contour plots
  • Previous by thread: RE: change PlotStyle in Graphics object after the fact?
  • Next by thread: Re: Overflow --> Abort evaluation