Re: Two independent y axes ?

*To*: mathgroup at smc.vnet.net*Subject*: [mg65420] Re: Two independent y axes ?*From*: Bill Rowe <readnewsciv at earthlink.net>*Date*: Fri, 31 Mar 2006 06:09:15 -0500 (EST)*Sender*: owner-wri-mathgroup at wolfram.com

On 3/30/06 at 5:29 AM, spam at spam.invalid (Geico Caveman) wrote: >Bill Rowe wrote: >>On 3/27/06 at 6:56 AM, spam at spam.invalid (Geico Caveman) wrote: >>>I am trying to plot a bunch of functions and some data together. >>>Some of the data and some of the functions have *very* different >>>y range from the others. How do I create 2 independent y axes >>>(like gnuplot - y and y2 axes) to show the data effectively ? >>Is something like the following what you are looking for >>In[8]:= x = Sort[Table[Random[], {10}]]; y = >>20*Reverse[Sort[Table[Random[], {10}]]]; >> In[8]:= >> x = Sort[Table[Random[], {10}]]; >> y = 20*Reverse[Sort[Table[Random[], {10}]]]; >> >> In[10]:= >> Show[Block[{$DisplayFunction = Identity}, >> {ListPlot[Rescale[x], PlotStyle -> Blue], >> ListPlot[Rescale[y], PlotStyle -> Red]}], >> Frame -> True, FrameTicks -> {Automatic, >> Range[0, 1, 0.2], None, ({#1, 20*#1} & ) /@ >> Range[0, 1, 0.2]}]; >No. I am plotting velocity and acceleration for a particle as a >function of time. These are physically distinct quantities and >cannot share a y axis. Having colorful legends will not cut it. Either you did not bother to try the example code or you gave the resulting plot and code a very superficial review. There are two vertical scales in the resulting plot. The left hand scale runs from 0 to 1 representing the values of the x data which is a sorted list of random values between 0 and 1. The right scale runs from 0 to 20 representing the values of the y data which is a reverse sorted list of random values between 0 and 20. The only purpose of using color was to clearly separate the y data from the x data. Rescale was used with both data sets to cause each set to be have a common scale for plotting purposes. The option Frame was set to True as a simple means to get Mathematica to put an axis on both the right and left hand sides of the plot. FrameTicks was then set to show the correct range of values for each data set. If this were intended for a publication rather than as a simple example, I would have added many additional features to the plot such as labels and something to clearly indicate which data points were associated with which scale. I assumed this was something you would work out for yourself. I also intentionally made this example with functions found in the standard Mathematica distribution. For similar plots I produce intended for publication, I make use of a couple of third party packages to allow me to easily customize the plot to a greater degree than the standard built in commands. -- To reply via email subtract one hundred and four