Annika Peter

Research & Interests

CV

Graphical Guide to SM

Photos

Travel

Links

Graphical Guide to SM:

Basic Plotting (and hints to make your plots both beautiful and legible)

In this section, I will show you how to make a basic plot, check that you like the looks of it, and print it to a file. I will also show you how to beautify your plot even further, and how to make sure that it will print well in a journal.

Getting Started

The first thing you need to do is make sure you have SM installed on your computer. To check this, you should type "sm" at the prompt in your shell. When I do this, this is what I get:

Hello Annika, please give me a command
:


If you don't see a prompt like this, contact your systems administrator. By the way ":" is the prompt; do not type the initial ":"s when writing commands.

OK, assuming you have a prompt, let's make the following simple graph using the following set of commands. We'll worry about making it pretty later.
:dev x11
:ctype black
:set x=0.0,10.0,1.0
:set y=x**2
:lim x y
:box
:con x y
:ptype 10 3
:points x y
:xlabel x
:ylabel y

I'll go through these commands step-by-step to show you what they mean, and then show you how to modify the commands to make your simple plot much more beautiful. Once the plot is beautiful enough for my taste, I will show you how to print it to postscript, and how to save your command history so that you can remake the plot in one second or less.

v
  • :dev x11
    This line specifies that you want your commands to go to the x11 device ("dev"). When you type this command, a window like the one on the left should appear. From then on, all plotting commands will be displayed in this window. There are several other devices you can send your plotting commands to, but this is likely to be your workhorse. If you use a Unix-based operating system (including Mac OS), X11 should be installed or should come on the install disk. Check out X.org for more information. To find out what other devices are available to you, type list device at the prompt. Most devices will enable you to print to a file in the format of your choice. Farther down in this section, I will show you how to print to a file.
  • :ctype black
    This command tells the device in which color to display the following plotting commands. For a list of available colors, and a description of how to define your own, see below. Let us say that we wish for the lines and points in the plot above to be in a color other than black, say red. If we use the following set of commands:

    :dev x11
    :ctype black
    :set x=0.0,10.0,1.0
    :set y=x**2
    :lim x y
    :box
    :ctype red
    :con x y
    :ptype 10 3
    :points x y
    :ctype black
    :xlabel x
    :ylabel y


    we will obtain the plot on the left.
  • :set x=0.0,10.0,1.0
    :set y=x**2
    These commands create Supermongo structures called vectors. There are several ways to define vectors; two ways are given above. The way to read the first command is that you want to create a list of numbers from 0 to 10, spaced by units of one. The second command tells Supermongo that the vector y is the square of x. There are other ways to set vectors, and to create string vectors, which I will discuss in more detail in a section on syntax. You might find it useful to read Robert Lupton's discussion of vectors.
  • :lim x y
    :box

    The first of these commands tells Supermongo over what range of values to plot, for the x and y directions. Here, I am using my pre-defined vectors to set the range. You can also set the limits using the following syntax:
    :lim xmin xmax ymin ymax

    if you prefer. The second command, "box", tells Supermongo to plot the box for the plot, with the dimensions specified by "lim", and with automatically set axis ticks. You can adjust the axis ticks manually if you want, although this involves considerably more work than simply writing "box" at the command prompt. I will go through the topic of defining your own axes/boxes in gory detail in a separate section.
Note that tic marks are labeled when you invoke the "box" command. Also note that the font labeling the tics is really small. You can alter the font size using the "expand" command. For example, if you use the following set of commands, you will get the plot on the left:

:ctype black
:set x=0.0,10.0,1.0
:set y=x**2
:expand 1.5
:lim x y
:box

Much better!
  • :con x y
    With this command, you are telling Supermongo to plot x against y, using lines to connect the elements of the vectors. "con" is short for the full "connect" command. You can use either to specify a line connection, but my guess is that you will use "con" and not "connect" unless you REALLY like to type an extra four characters. You can change the color, thickness, and type of line. Follow the hyperlinks for more information on these topics, or scroll further down the page.
  • :ptype 10 3
    :points x y

    With these commands, you are specifying a point symbol, and then plotting x against y using point markers. In this particular case, ptype 10 3 tells Supermongo to use a ten-sided polygon that is filled in. There is a lot more information about point types and sizes here.
  • :xlabel x
    :ylabel y

    With these commands, you are giving the axes names. The syntax here should be pretty self-explanatory. Note that if you use the "expand" function before typing in the axis label commands, the font size will grow or shrink according to the expand factor.
  • :toplabel My first Supermongo plot!
    The last thing you might want to do is to give your plot a title. This is done using the "toplabel" command, the results of which you can see on the left.
Ta da! You have created your first Supermongo plot. It is not terribly beautiful, but that will come later. I hope you have learned a lot already; in the sections below, I show in a bit more detail how to make your plot a bit prettier and how to print it to something other than the screen. I also unleash a series of rants on what not to do when making a plot. Other, separate sections will address some more sophisticated plotting techniques and tricks. As you can see so far, it is pretty simple to make a first-pass plot; however, as with Apple products, it is way trickier to customize the plot to your exact specifications, but I'll show you how to do it.

Colors

These are the basic colors in Supermongo. You can change colors (e.g., red) using the following command:

:ctype red
This is what the colors look like when you convert to greyscale using a conventional color-to-greyscale mapping. Keep this in mind when you ask that your pretty color plots be printed in greyscale in a journal.
There are several ways to expand the color palette in SuperMongo. Probably the easiest thing to do is to load the "xtcolors" (or "xtcolours" for Anglophiles) macro, which is located in the "default" file in the SuperMongo "macro" folder. You load this simply by writing
:xtcolors
on the command line. You can also add a color type using an RGB coding using the "add_cytpe" macro, which has syntax:
:add_ctype darkgold 170 170 0
In the plot on the left, I show the colors included in xtcolors as well as a few I made using the "add_ctype" macro.
FYI, this is what the colors look like using a typical greyscale mapping.
The macros for the color plots may be found here. In order to make greyscale versions of these plots, I used ImageMagick's "convert" tool, using the option "-type GrayScale". You can customize your own greyscale by hacking into the postscript file. However, this is occasionally a pain in the butt, and a better strategy is to use colors on your plot that will appear sufficiently dark using a conventional greyscale mapping.

Line Types

There are seven basic line types in SM, which you can implement at any thickness you might desire. Here is what they look like. The Supermongo macro for this plot is "lineplot" in this script.

Point Types

As you can see from the plot on the left, there are many possible symbols you can choose for your points, and you can make them any size you want. In addition, you can rotate them. The syntax is "ptype Number-of-sides-on-the-symbol Type-of-fill". For "Type-of-fill", "0" corresponds to having an outline but no fill, "1" corresponds to having lines run from the corners of what would have been the outline of the point to the center, "2" corresponds to having the outline of the symbol pinched in at the halfway point on each line segment, and "3" corresponds to having a filled symbol. You can also rotate symbols, which is most useful for triangles, as you can see in the right-most symbols on the plot. The syntax for the top-right symbol is "angle 90 ptype 3 0". Remember to set the angle to zero after making the points or else all your text and so forth will be rotated. One thing I'd like to point out (ha ha ha) is that it is usually better to use "ptype 10 0" or "ptype 10 3" to make unfilled or filled circular points instead of "ptype 1 0", for the reason that you get a much bigger (and easier-to-read) symbol. You can see the script for this plot here.

Printing to a File

So far, we have only printed to screen using X11. However, it would be really nice to have the plot in file form. The easiest way to get a file is to print to encapsulated postscript. The process for this is shown below, with the extra print commands highlighted:

:dev postencap my_first_plot.eps
:ctype black
:set x=0.0,10.0,1.0
:set y=x**2
:lim x y
:box
:con x y
:ptype 10 3
:points x y
:xlabel x
:ylabel y
:dev x11

Calling "dev x11" at the end is important. The process to writing to files is greatly simplified once we get to scripts.

Annika's Rants Re: Plot Readability

There are a few mistakes that people make when making plots for publications. The basic rule is that you can't read your own plot when printed in greyscale and at the size the plot will be printed in a journal, you're doing something wrong.
  • Too-small font for any text on the plot. When I make plots, I usually use "expand 1.5" at the very least for all text.
  • Too many lines! It's generally a bad idea to have more than five lines on a plot. Sometimes, given the nature of the point you are trying to make with the plot, five lines is still way too many. One test to see if you have too many lines on a plot is to try to summarize the main point of the plot to yourself in words (you can speak aloud to yourself, although that is not a great idea if you have a noise-sensitive office mate). If it takes you more than about 20 seconds to describe each line and the point of it, you have too much going on in your plot. Remember, a picture is worth a thousand words only if it takes you less time to figure out a plot than to read a thousand words.
  • All lines have the same style. Even if you have a fancy color printer, remember that your less-well-funded (or frugal!) colleagues may not. If you can't understand your own plot printed in greyscale, it's time to change your line style.
  • Lines are too light. This can happen if the line is too thin or the color is too light. Choose dark-ish colors for your lines and use a line width of at least 3.
  • Can't distinguish among symbols. It's time to make your symbols bigger and alternate between filled and open points.


Last updated: 01/02/2011. Happy birthday, Little Brother!