Mathematica Graphics Questions

  1. What's wrong with postscript in MMA with LaTeX?
  2. More problems with postscript in MMA with LaTeX.
  3. How can I permanently change options for Plot[] or ListPlot[]?
  4. How can I make a movie from within MMA?
  5. How do I plot vector fields?
  6. How do I plot polar vector fields?
  7. How do I get my plot axes to intersect at the origin?
  8. How do I get my plot to show the entire range of the function?
  9. Where do I find the functions LogLogPlot[] and LogPlot[]?
  10. How do I display two plots on the same graph without having them show individually first?
  1. I want to use Display["filename",Graphics] to write a graphics file into a postscript file to include in a TeX document. Unfortunately, ghostview doesn't read the ps file properly and I can't print it to a printer either. What is wrong?
  2. MMA's PS is broken (Wolfram would probably prefer the terminology "different" or "proprietary"). It's tailored for display by Mma; there are a bunch of definitions, which Mma already knows, which need to be added to the file to make it useable by any other PS display device. Assuming you're on a unix station, you'll need to run psfix (should be part of your MMA distribution) on the output from Display[].

    Internally, MMA uses a non-standard dialect of PS to more efficiently represent MMA graphics. It defines a number of higher level operators that are understood by MMA's own PS interpreter but not by others. You simply need to add the definitions of these operators to your MMA PS file before passing it to, in your case, ghostview. You can do this using rasterps, which is distributed with MMA. If you're using a Unix version of MMA then at the Unix command line type: rasterps -format ps -file filename will take a file containing Mathematica PS ("filename") and convert it into a file containing standard PS ("") which can be sent to a printer or viewed with an application like ghostview. For a more detailed description refer to the section on Converting Graphics to Other Formats in the MMA Users Guide for your System. If you require more help with this problem I'd suggest that you contact Wolfram Research Technical Support directly:

  3. I have problems converting a MMA graph into an EPS file to be inserted in a LaTeX document. The legend of my graph uses greek letters and brackets which are not correctly displayed in the EPS file when using Display["file.eps", mygraph, "EPS"] in MMA 3 or Export (with the same syntax) in MMA 4. What should I do?
  4. See

  5. I have to change attributes for ListPlot every time I use it. Is there a way to save the attributes of it? For example, everytime I restore a Saved[] file, I want the aspect ratio to be 1 for all my plots.
  6. You can use SetOptions to change the default option values for functions. For example:

    SetOptions[ Plot, DefaultFont -> {"Times-Bold", 14} ]

    will change the default font for plots to 14pt Times bold. If you want a given change to be present every time you run MMA you can place the command in the init.m initialisation filer. For another example,

    In[3]:= SetOptions[ListPlot, AspectRatio -> 1] Out[3]= {AspectRatio -> 1, Axes -> Automatic, AxesLabel -> None, ...etc}
  7. How does one make a "movie", or animated graphics on MMA?
  8. All versions of MMA are able to display sequences of graphics as animations. The details vary on different platforms. The following command generates a sequence of graphics:

    Table[ Plot[ Sin[ a x], {x, 0, 10}], {a, 1, 6}]

    When using the notebook front end, double clicking on one of the resulting graphics will run the animation. If you are running a version of MMA without a notebook front end you'll want to use the Graphics`Animation` package which is documented in the "Guide to Standard MMA Packages Technical Report".

    Whether you can make a movie depends on the particular implementation of MMA. Sometimes there is a function called Animate. Other times there is a menu item called Animate Selected Graphics. With this one, you just select the frames that you want to show in sequence and then go to that menu item.

    You could animate the plots you've made by selecting all of them and using the "Animate Selected Graphics Command" which is somewhere in the menus (it depends on which system you are using). If you use a Mac, you can also save the graphs as a QuickTime movie by selecting all of them and use Convert To Quicktime in the Graph menu.

    You might want to look at this:

    (* Movie-2: An Attempt At Crude Animation of Wave Equation *)
    (* by Geoff Baldwin, 26 April 1996.                        *)
    (* PDE class, San Francisco State University               *)
    (* Find Serviceable "Bump Function"                        *)
    Plot[ Exp[-(2 x)^2], {x, -1, 1}, PlotRange->{0,1}]
    f[y_] := Exp[-(2 x)^2]
    (* Make a list of plots *)
    t = Table [
    	Plot[f[x-t] + f[x+t], {x,0,10}, PlotRange->{0,2}], {t, -5,5,1}]
    (* Irrelevant, but interesting aside.  Shows that list was built: *)
    (* Show each element of the list, successively (crude animation): *)
    Do[ Show[t[[i]], {i,1,Count[t,_]}]
  9. I keep seeing MMA graphs of vector fields. How is it done?
  10. 2D and 3D vector plots are defined in Graphics`PlotField` and Graphics `PlotField3D` respectively, two of the standard packages distributed with every copy of MMA. They're documented in the Guide to Standard MMA Packages Technical Report (pp 183-191). Here's a simple example taken from the documentation:

    Needs[ "Graphics`PlotField`"] PlotVectorField[ {Sin[x], Cos[y]}, {x, 0, Pi}, {y, 0, Pi}]
  11. I have a piecewise vector function of rho and phi, with components in the rho and phi hat directions. Can I plot the vector field as is, or do I need to convert the components and unit vectors to Cartesian coordinates?
  12. You'll probably have to convert from polar to cartesian coordinates, but there should be some functions in Calculus`VectorAnalysis` to help you convert between the systems.

  13. How do I get my plot axes to intersect at the origin?
  14. Plot[f[r], {r, 0, 10}, AxesOrigin -> {0, 0}]

  15. How do I get my plot to show the entire range of the function?
  16. Plot[f[r], {r, 0, 10}, PlotRange->all]

  17. Where do I find the functions LogLogPlot[] and LogPlot[]?
  18. LogPlot[] and LogLogPlot[] are defined in Graphics`Graphics`, one of the standard packages distributed with MMA. The Graphics`Graphics` package is documented in "The Guide to Standard Mathematica Packages Technical Report", pp 140-152.

  19. How do I display two plots on the same graph without having them show individually first?
  20. This is surprisingly difficult for something that should be a very common operation. You'd think this would work:

    p1=Plot[ x^2, {x, 0, 5} ];
    p2=Plot[ x^3, {x, 0, 5} ];

    But it doesn't. The semi-colon just supresses the "-Graphics-". You end up with three graphs. But try this:

    hide   = DisplayFunction->Identity;
    unHide = DisplayFunction->$DisplayFunction;
    p1=Plot[ x^2, {x, 0, 5}, Evaluate[hide] ];
    p2=Plot[ x^3, {x, 0, 5}, Evaluate[hide] ];
    Show[p1, p2, Evaluate[unHide]];