Mac OS X Grapher – Plotting Points and Adding Extras

Woot!  We’re back!  Apologies for the radio silence – real life has been kicking me in the teeth.  Nothing like tangling with an insurance company to suck the life out of you.

To ease back into this blogging thing I decided to start with two relatively straightforward topics: plotting points and adding extras (arrows, labels, etc.).  Not very exciting but sometimes useful for the purposes of decorating and/or clarifying your plot.  As before, click on any picture to enlarge.

I. Plotting Individual Points

We’ll start with the parametric equation plot from the previous blog post:

While this graph is interesting, it can be a little confusing to interpret, especially for people unfamiliar with parametric equations. Essentially, we are plotting the trajectory of a moving particle.  Our particle starts at point (2,0) @time t=0, and moves through this looping, sinusoidal path (officially called a Lissajous curve) before finally returning to (2,0) @ time t=2π.

It would be nice to be able to show the location of our particle at specific times, so that we can get a better idea of how it moves.  We therefore would like to plot individual points, as opposed to a continuous curve, on our graph.

Grapher handles individual points via matrix notation, which you can access from the Equation Palette:

Make a new equation (Command-Option-n), and plot a point at (x,y) = (3,2) as follows:

Voilá, our point!  As with most things Grapher, we can modify the appearance of our point by selecting its equation in the Equation List and using the Inspector. Here’s our point after setting Line=black, Fill=red, Marks=circle (which I adjusted in size), and Polygon=off:

Plotting a point @(3, 2) is all very well, but it’s not germane to this particular graph. We want to plot several points, and we want them to be spaced along the curve. The best way to do this is to use parameters.  Make a duplicate of your original parametric equation, but change the continuous parameter “t” to a discrete parameter (I used “u”), with values stepping from 0 to 2π in π/6 intervals:

Note the different effects of the two equations. The first equation plotted the trajectory as a smooth curve, since t varied continuously from 0 to 2π.  The second equation plotted the same trajectory as a series of discrete points at time intervals of π/6.  So now we know exactly where our particle is at time t=0, t=π/6, t=π/3, etc.

Aside – You can connect your discrete points with straight lines by selecting their equation in the Inspector and checking the Polygon box.

II. Adding Text Boxes

To further clarify where the particle is at any given time, it would be helpful to label our points.  Unfortunately Grapher cannot do that automatically, but we can achieve the same thing with text boxes.  Go to the Object menu, and select Insert Text.  A text box will appear, usually in the center of the plot or some other inconvenient place.  Fill it with your desired text, and then drag the box to where it needs to be:

You can change the font of your text by selecting it and hitting right click.  In order to avoid the hassle of doing this for each and every text box, it is sometimes more efficient to make one text box with the appropriate font and formatting, and then use copy/paste to duplicate it as many times as needed:

Text boxes can also be modified with the Inspector (see above).  Rotation Angle is self-explanatory.  The Attached to Real Field box is something of a mystery.  If this box is not checked, resizing the plot will grow/shrink the curve, while the text boxes stay in their previous locations.  In other words, the text boxes will become disassociated from the points they are supposed to label.  When checked, text boxes are “attached” to the data on the plot, so that when the plot is rescaled, the text boxes move accordingly.  Unfortunately this does not seem to work consistently, and checking the “Auto” box does not seem to have any effect.

III. Adding Arrows

In order to make the behavior of this set of parametric equations even more clear, we can add arrows to show the direction of particle motion.  Go to Object -> Insert Arrow, and a thin black arrow will magically appear in the middle of your plot.  We can modify the appearance of our arrow with the trusty Inspector, including color, arrowhead design, line thickness, rotation angle, shadow, and Attached to Real Field:

If we wish to insert multiple arrows, the most efficient method is to use copy/paste. Grapher Quirk: Grapher sometimes will paste the arrow outside the field of view (e.g.,  @ (x,y)=(100, 100)), so that you don’t see the arrow after you paste it in. You can either  keep pasting until you get the desired number of arrows within your field of view, or you can zoom out and hunt down the errant arrows.

IV. Making a Legend

Grapher unfortunately will not automatically make a legend for you.  However, with creative use of the Insert Object menu, you can build one for yourself:

This legend was created using a combination of Insert Rectangle (green box with text), Insert Arrow x2 (one headless), and Insert Oval (the red dot).  All were modified appropriately in the Inspector.  As a final step, I selected the entire legend and then did  Object -> Group.  This groups all selected objects together, so that you can move the legend around as a single entity instead of having to move each individual part.

Well, that’s it for this week’s not very exciting but potentially useful entry.  Tune in next time for a discussion of using Grapher to plot data.

This entry was posted in Grapher and tagged , , , , . Bookmark the permalink.

4 Responses to Mac OS X Grapher – Plotting Points and Adding Extras

  1. Jake says:

    Thanks for the post, but how to you keep the objects created, like text boxes and arrows, fixed to the curve when you move the graph, or zoom?

  2. Ritchie says:

    Hi and bravo for your excellent demonstration, can I ask you a question about lissajous model?


  3. Zach says:

    Is there any way to draw a polygonal curve, and especially a filled polygonal curve, with Grapher?

  4. Zach says:

    Actually, something like this can almost be hacked with the judicious use of bits of trig functions in polar coordinates, or sgn() functions as applied to appropriate functions defined on the plane to obtain half-plane symmetry. But is there no easier way for a puny polygon?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s