MathGroup Archive 2007

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

Search the Archive

Re: New graphics primitive: "Curve"?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg79284] Re: [mg79248] New graphics primitive: "Curve"?
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Mon, 23 Jul 2007 03:47:13 -0400 (EDT)
  • Reply-to: hanlonr at cox.net

An advantage of using Plot rather than just mapping the functions on a list of points is that Plot adaptively samples the range.

f1[x_] := (x - 2) (x - 3);
f2[x_] := x - 3/2;

You can either use Part

curveA = Plot[f1[x], {x, 1, 4}][[1, 1, 3, 2]];
curveB = Plot[f2[x], {x, 1, 4}][[1, 1, 3, 2]];

Show[Graphics[{curveA, curveB}]]

or select the Line

curveA = Cases[Plot[f1[x], {x, 1, 4}],
   Line[__], Infinity];
curveB = Cases[Plot[f2[x], {x, 1, 4}],
   Line[__], Infinity];

Show[Graphics[{curveA, curveB}]]


Bob Hanlon

---- AES <siegman at stanford.edu> wrote: 
> I'd like to create named graphics elements ["curves"] that would contain 
> the graphic content of just a single curve in a Plot or ParametricPlot 
> (no axes or anything else, just the data curve), and that could then be 
> displayed as graphics elements like pseudo primitives, e.g.
> 
>    curveA = Graphics[<some coding>]
>    curveB = Graphics[<more coding>]
>    Show[curveA, curveB, <other graphics stuff>]
> 
> What might be preferred ways to do this?  
> 
> I suppose one way would be to make a Plot or ParametricPlot with 
> everything but the function curve suppressed?
> 
>    curveA = Plot[f, range, <options to suppress Axes, etc>]
> 
> Or, is there a way to pull just the curve out of a plot?
> 
>    curveA = Part[Plot[], i]   ????
> 
> (and if so, is that Part a graphic element already?  Or must it then be 
> wrapped in Graphics[]?)
> 
> Or, generate a Line or a Polygon with lots of points?  (Sounds 
> inefficient)
> 
> Or, what other approaches might be easy, fast, and efficient?
> 
> [Thanks for any ideas.  I've been reading Section 2.10, "The Structure 
> of Graphics" in The Mathematica Book 5.2, but it's hard going.]
> 
> [And P.S. -- Are there any good reasons to choose between wrapping each 
> individual graphics element in Graphics[] as above and then Show-ing 
> them using the syntax at the top of this msg, or alternatively leaving 
> the individual named elements unwrapped and using instead
> 
>    Show[Graphics[{ curveA, curveB, <other stuff> }]]
> 
> ]
> 



  • Prev by Date: Re: Re: Wolfram Workbench 1.1 now available
  • Next by Date: Re: Re: Wolfram Workbench 1.1 now available
  • Previous by thread: Re: New graphics primitive: "Curve"?
  • Next by thread: Locator question