MathGroup Archive 2008

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

Search the Archive

Re: How can I create a two-axis graph in Mathematica v6

  • To: mathgroup at smc.vnet.net
  • Subject: [mg91776] Re: How can I create a two-axis graph in Mathematica v6
  • From: "David Park" <djmpark at comcast.net>
  • Date: Sun, 7 Sep 2008 05:40:40 -0400 (EDT)
  • References: <g9t6of$ja8$1@smc.vnet.net>

With the Presentations package it is very easy to put any scales on any of 
the axes. The only requirement is that there must be a 1-1 mapping between 
the scale and the underlying plot coordinate. You can also completely 
control the tick values and format. Here is the example from the html link. 
(Putting the x^3 scale on the right is much better than the other way 
around.)

Needs["Presentations`Master`"]

f1[x_] := x^3;
f2[x_] := Sqrt[x];

yrightticks =
  CustomTicks[#/35 &, {0, 70, 10, 5},
   CTNumberFunction -> (Style[#, FontColor -> Red] &)];
yleftticks = CustomTicks[Identity, {0, 2, .5, 5}];
Draw2D[
 {Red, Draw[f1[x]/35, {x, 0, 4}],
  Black, Draw[f2[x], {x, 0, 4}]},
 Frame -> True,
 FrameLabel -> {{f2[x], f1[x]}, {x, None}},
 RotateLabel -> False,
 FrameTicks -> {{yleftticks, yrightticks}, {Automatic, Automatic}},
 PlotLabel -> "Plotting Two Functions with Different Scales",
 ImageSize -> 500]

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


<avteran1 at gmail.com> wrote in message news:g9t6of$ja8$1 at smc.vnet.net...
> Hello All,
>
> In my efforts to create a two-axis graph in Mathematica v6. I came
> across a Mathematica Technical Support FAQ titled "Can I create a two-
> axis graph in Mathematica?" There are two versions of this FAQ the
> most recent and updated version of the FAQ can be found at the
> following URL:
>
> http://support.wolfram.com/mathematica/graphics/combine/twoaxisgraph.en.html
>
> The URL site provides a Mathematica notebook titled "twoaxisgraph.en"
> which may be downloaded.
>
> I have downloaded the "twoaxisgraph.en" notebook and have tried to use
> it for my application but I continue to have problems with this code.
> Without making any changes to the downloaded notebook and when
> evaluating the part of the notebook that is for Mathematica 6.0 and
> later, I do not get the same output plot as originally displayed in
> the downloaded notebook. Specifically I am referring to the output
> plots Out[4], Out[5], Out[7], and Out[8] that appear in the first part
> of the web page. Instead, the output has "Null^4" preceding the plot
> and the image size of the output plot is small and must be resized
> manually to be able to be viewed.
>
> This is one problem with the part of the notebook dealing with
> "Working with Continuous Plots" with "Mathematica 6.0 and Later." The
> second problem is that it seems this code does not entirely do what I
> need it to do.
>
> Ideally I would like to have something similar to the TwoAxisPlot
> command that is used in the section "Working with Continuous Plots"
> for "Mathematica Versions Prior to 6.0." That version allows you to
> specify the common "x-range" to both plots and choose the "y-ranges"
> for each individual plot to be plotted. This way you can see both
> plots in their entirety regardless if one plots range is many times
> larger than the others. Please refer to both the input and output
> graphics of the last section of the web page, specifically In[2],
> In[3], Out[2], and Out[3].
>
> I need help with either making the code for "Working with Continuous
> Plots" with "Mathematica 6.0 and Later" do what the code for "Working
> with Continuous Plots" with "Mathematica Versions Prior to 6.0" does,
> or change the code in "Working with Continuous Plots" with
> "Mathematica Versions Prior to 6.0" so that it will work in
> Mathematica v6. (Please refer to the URL)
>
> I am not very knowledgeable in Mathematica programming so any
> assistance with this matter would be greatly appreciated. Any
> suggestions or insight on how to change this notebook code to apply to
> my needs would also help. As a reminder I am using Mathematica
> v6.0.2.0.
>
> Thank you,
> Tony
> 



  • Prev by Date: Re: How can I create a two-axis graph in Mathematica v6
  • Next by Date: Re: Trouble Implementing Schelling's Segregation Model
  • Previous by thread: Re: How can I create a two-axis graph in Mathematica v6
  • Next by thread: Re: How can I create a two-axis graph in Mathematica v6