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

MathGroup Archive 2001

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

Search the Archive

RE: Plotting

  • To: mathgroup at smc.vnet.net
  • Subject: [mg28737] RE: [mg28694] Plotting
  • From: "David Park" <djmp at earthlink.net>
  • Date: Fri, 11 May 2001 03:38:52 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Here is a simple example of plotting two functions with different scales.

Needs["Graphics`Colors`"]

f1[x_] := Sin[x];
f2[x_] := 20*x^2 - 5*x + 100

Plot[{f1[x], f2[x]/500},
   {x, 0, 10},
   PlotStyle -> {Black, Blue},
   Frame -> True,
   FrameLabel -> {x, f1, None, StyleForm[f2, FontColor -> Blue]},
   PlotLabel -> "Plotting Two Functions",
   FrameTicks -> {Automatic, Automatic, Automatic,
     Table[{y, StyleForm[
        500*y, FontColor ->
         Blue]}, {y, -1, 4, 1}]},
   ImageSize -> 450];

1) First I plotted f1 and f2/scale, with various scales until I obtained a
reasonable looking plot. I used scale = 500 in this case.
2) I used two different colors, Black and Blue, so I could key the functions
to the frame scales.
3) I used FrameTicks to put tick marks and labels (scaled up) on the right
hand side of the frame.
4) I used StyleForm to display the right hand labels in Blue, and did the
same with the frame label.

How does it look?

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/

> From: Yahsi [mailto:yahsi at marun.edu.tr]
To: mathgroup at smc.vnet.net
>
> Hi,
>
> I have a question regarding the plot. Suppose that you have two separate
> functions and you would like to plot them on the same graph. Both
> are not so
> scaled to plot it using the single y axis. Sometimes we need to draw the
> plots of two functions (f1 and f2) on two separate y axis (one is on the
> left as usual and the other on the right). This features are common even
> very primitive versions of the graph programs such as grapher and excel. I
> am not able to figure out how to do this in Mathematica.
> Thanks for your replies in advance.
> Uður
>
> Assoc. Prof. Dr. Uður Yahþi
> Marmara University Faculty of Arts and Sciences
> Physica Department, 81040 Goztepe, Istanbul-TURKEY
> yahsi at marun.edu.tr
>




  • Prev by Date: List of bits to String
  • Next by Date: Peculiar behavior of DiscreteDelta
  • Previous by thread: RE: Win2000
  • Next by thread: Re: Plotting