MathGroup Archive 1989

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

Search the Archive

[no subject]

  • To: stevec at yoda.ncsa.uiuc.edu
  • From: lie at itk.unit.no
  • Date: Sun, 19 Nov 89 15:53:17 GMT

Subject: Re: Combining plots
     
A partial solution to the problem of combining plots.
     
This is a *partial* solution to the problem of combining different types of
graphics in one plot. By partial is meant that the solution is cumbersome,
and not very elegant.
     
In general, two plots of different types (e.g., Plot and ContourPlot) cannot be
combined in one plot by means of the Mathematica Show command. A solution to
this problem is to save the plots with the Display["file",%out] command, one
file per plot. The files are then merged into one file as they are. Finally,
use the Wolfram Research program x11ps to display the merged file:
     ..path../x11ps < merged_file_name
     
x11ps displays the file on an X11 terminal. For other types of terminals, use:
sunps, tekps, ttyps (!), ... instead of x11ps.
     
The PROBLEM is that it is highly unlikely that you are able to produce the plots
such that the axis of the two plots coincide (i.e., I haven't found how to do
it). Even by use of the Show options PlotRange and Axes, I didn't succed.
     
A "dirty" way to solve this problem when combining a ContourPlot and a two-
dimensional plot is examplified  below:
     
-Problem:  Combine the plots (ContourPlot) of the object function:
                f[x_,y_]=x^2+2y^2
           and the constraint:
                y[x_]=5-x
           in the region {x,-5,5}, {y,-5,5}
     
-Amateurs solution:
           1. ContourPlot[f[x,y],{x,-5,5},{y,-5,5}]
               --> out[n] (for instance)
           2. It is very difficult to use Plot[y[x],{x,-5,5}], then
                 Show[%,PlotRange->{-5,5},AspectRatio->Automatic] and make
                 the axis overlay perfectly!! (i.e., for me).
               Solution: restate the constraint as:
                  z[x_,y_]=5-x-y
               ContourPlot[z[x,y],{x,-5,5},{y,-5,5}] gives you a heap of contour
                  lines, where the sought one is that at z[x,y]=0. Now you just
                  Show the previous ContourPlot for z in the range of, say
                  {-.001,.001}: Show[%,PlotRange->{-.001,.001}]
                       --> out[m] (for instance)
                  If z is plotted in the range {-.1,.1}, the "line" will become
                  rather thick.
            3. Display["fxy",%n] and Display["zxy",%m] will save the files,
               which may then be merged into file "fzxy".
            4. The combined plots are shown with the command (on an x11-
               terminal):
                  ...path../x11ps < fzxy
     
As stated above, this is not a very professional way to do it. *Someone*
should write a general Mathematica command/routine to do it in one batch.
     
- Bernt Lie
     
PS. Valuable tips has been received from rgf at terra.... and nb at Polya...
     
     
     
     
     


----- End Included Message -----



  • Prev by Date: Re: Combining plots
  • Next by Date: EMACS front end for Mathematica
  • Previous by thread: Re: Combining plots
  • Next by thread: EMACS front end for Mathematica