Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

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

Search the Archive

Re: Axis in two scales

  • To: mathgroup at smc.vnet.net
  • Subject: [mg92602] Re: Axis in two scales
  • From: "David Park" <djmpark at comcast.net>
  • Date: Wed, 8 Oct 2008 06:23:34 -0400 (EDT)
  • References: <gcchas$s1q$1@smc.vnet.net> <gcffqv$f62$1@smc.vnet.net>

That is a very nice idea Szabolcs! (But I would use a Frame rather than an
Axis plot so the tick values weren't obscured by the plot.)

--
David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/


"Szabolcs Horv=E1t" <szhorvat at gmail.com> wrote in message
news:gcffqv$f62$1 at smc.vnet.net...
> Nacho wrote:
>> Hello everyone.
>>
>> I have a dataset in pairs (x,y) that I would like to plot. The main
>> problem is that the data set has interesting parts in the beginning
>> that I would like to view clearly.
>>
>> As an example, create the following table:
>>
>> t = Table[{x, If[x < .5, Sin[100*x], Sin[x]]}, {x, 0, 5, 0.001}];
>> ListPlot[t]
>>
>> You have a very detailed sine in the beginnng and the rest is less
>> interesting.
>>
>> I would like to "split" the X axis in two, so the left half of the
>> plot covers x={0,0.5} and the second half x={0.5,5}] in the same p=
lot
>> and with the right ticks.
>>
>> It is like a piecewise axis... is it possible?
>>
>
> You can use custom tick marks, take a look at Ticks and FrameTicks.
>
> Here's a way to do it:
>
> First we define a function to transform x coordinates:
>
> trafo = \[Piecewise] {
>     {#, # <= 0.5},
>     {Rescale[#, {0.5, 5}, {0.5, 1}], # > 0.5}
>    } &
>
> In our case this is just a piecewise linear rescaling.
>
> Then apply this function to x coordinates and to the tick positions tha=
t
> we wish to show:
>
> ListPlot[
>  {trafo[#1], #2} & @@@ t,
>  Ticks ->
>    {{trafo[#], #} & /@ Join[Range[0, 0.5, 0.1], Range[1, 5]],
>     Automatic}
> ]
>
> The advantage of this approach is that it is easily generalized: we
> could have used trafo = #^(1/3) & for a fancy non-linear scaling, or
> just trafo = Log to mimic ListLogLinearPlot (better not try to put a
> tick mark at 0 in this case).
>
>



  • Prev by Date: Re: Why is Mathematica assuming k==l and how do I make it not to?
  • Next by Date: Re: Why is Mathematica assuming k==l and how do I make it
  • Previous by thread: Re: Axis in two scales
  • Next by thread: Re: Axis in two scales