MathGroup Archive 2002

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

Search the Archive

RE: plotting against a variable

  • To: mathgroup at smc.vnet.net
  • Subject: [mg37850] RE: [mg37838] plotting against a variable
  • From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
  • Date: Fri, 15 Nov 2002 01:35:04 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

>-----Original Message-----
>From: Urijah Kaplan [mailto:uak at sas.upenn.edu]
To: mathgroup at smc.vnet.net
>Sent: Thursday, November 14, 2002 12:12 PM
>To: mathgroup at smc.vnet.net
>Subject: [mg37850] [mg37838] plotting against a variable
>
>
>I looked all over the Mathematica documentation, and I haven't found an
>answer...I would like to know how to make a plot, for example Sin[x/P] such
>that the x axis, instead of ranging from say, 0 to 10, ranges from 0 to 10
P,
>with the tick marks on the axis showing that. I mainly want to use this
>technique to find the zeroes of complicated transcendental functions that
>Mathematica can't solve explicitly in terms of another variable. Thank you
>very much.
>
>
>
>                           --Urijah Kaplan
>
>

Some ideas:

(1) write your own TickFunction for the abscissa.

(2) get the standard Mathematica TickFunction (is burried somewhere in
Tom-Wickham Jones' Package ExtendGraphics available for free at MathSource),
and put in the right parameters.

(3) search the archive of MathGroup (this is a FAQ).

(4) explicitely construct the ticks for a certain plot.

(5) ad-hoc modify the output of Plot; as it goes here:

In[27]:=
g = Block[{P = 1}, 
    Plot[Sin[x/P], {x, P 0, P 2 Pi}, DisplayFunction -> Identity]]

(* make a graphics object first *)

In[28]:=
Show[g, ReplacePart[#1, 
        Part[##1] /. {n_?NumericQ, nn_, r__} /; nn =!= "" :> 
                     {n, ToString[nn] <> " P", r}, {##2}] &
        [AbsoluteOptions[g, Ticks], 1, 2, 1],
     DisplayFunction -> $DisplayFunction]

(* modify the tick marks of interest *)


AbsoluteOptions[g, Ticks] gives you the effective tick option as of Graphics
g; this becomes #1 of ReplacePart.

{1,2,1} is the position of the x-ticks; to be used in ReplacePart {##2} and
in Part (contained in ##1).

We replace the labels of the major tick marks (1., 2., ..., 6. here) with
"1. P", "2. P",...,"6. P"

The minor tick marks are not affected due to the Condition nn =!= ""


--
Hartmut Wolf


P.S. you may consider this way to modify part of an expression as a design
pattern. I used it here, because it was not so easy to change only the ticks
for the x-axis but not for y; (call it ReplaceAt).



  • Prev by Date: Re: How to generate synthetic econometric time series?
  • Next by Date: Random number Newbie Question
  • Previous by thread: RE: plotting against a variable
  • Next by thread: How to generate synthetic econometric time series?