Graphing with Gnuplot and Xmgr
Three dimensional surfaces can be generated with the splot command, which has syntax almost identical to plot. An additional range specifies the range of the y variable and the set view command lets the user control the orientation of the plot in space. A simple example would be:
splot x*x-y*y title "Hyperbolic Paraboloid"
Gnuplot also supports hiding lines that are behind other lines with the hidden3d parameter: set hidden3d.
Gnuplot can plot “parametric” functions. A parametric function is one in which both the x and y coordinates are functions of a third variable, which in Gnuplot is t. For example:
set parametric plot 2*sin(t), 2*cos(t)
produces a circle of radius 2. The command:
set trange <range>
sets the values of t that are evaluated. Parametric plots are also valid while doing a three-dimensional splot. In this case, the independent variables under gnuplot are u and v.
Gnuplot can also take data points from the standard output of a Unix command specified on gnuplot's command line. This allows the display of points generated from almost any source. The command should be specified like a filename, preceded by a < character.
Xmgr is oriented more towards plotting data created from an external source, as opposed to plotting a given mathematical function. Xmgr normally reads files, but can also take input piped from its standard input. Once data has been read into an xmgr set, it can be displayed, scaled, and manipulated in many ways.
Xmgr also has an on-line help. When the “help” menu is selected, xmgr runs your favorite HTML browser (Mosaic by default) with the xmgr documentation as input. Several sites on the internet have this page on-line. If you don't have a browser, you end up having to read raw html. Having a program's documentation as a hypertext document is quite nice, as you can jump from subject to subject as well as being able to do text searches. A gallery of graphs produced by xmgr is also included with the xmgr distribution, which gives the user a visual look at the wide range of effects possible with xmgr.
The first step in graphing some data is to read the data into xmgr. The “Read Sets...” option under “File” produces a file browser from which a file can be selected. Several types of data can be read in, but the two column “XY” format is the most common. The format of the data is much the same as in gnuplot—individual points on lines by themselves separated by spaces or tabs. Lines beginning with # are also considered comment lines, and lines without numeric data (like a blank line) separate sets. Lines beginning with the @ symbol can control the actions of xmgr separately from the user.
Xmgr data sets are somewhat like registers, in that only a fixed number are available (fixed at compile time), and they are referred to by number. Once the data is in a set, it is displayed immediately. The left hand side of the xmgr window contains a number of buttons that provide shortcuts for various operations.
Most of the shortcut buttons let the user change the appearance of the graph interactively. A set of four arrow buttons scrolls the data in all four directions—tick marks and tick labels are automatically updated. The “Z” and “z” buttons allow uniform zooming in and out. Arbitrary zooms in are accomplished by using the magnifying glass button. This prompts the user for a rectangle that becomes the new limits of the graph. A text line at the top of xmgr's window constantly displays the current position of the mouse, in the coordinates of the graph. A crosshair extending the length and breadth of the window may be toggled to help position the mouse within a pixel of the desired point.
The “autoO” button provides an autoscaling feature. The cursor changes to a crosshair, which when clicked at some point selects the set nearest to the clicked point. The graph is rescaled such that all points in this set are visible. The “autoT” button immediately rescales the tick marks that can get cramped while doing a zoom.
Each data set has several attributes that control how the set is displayed—which symbol is used for points, the color of the symbol, whether the symbols are connected by lines or not, the color and style of the lines, the legend associated with the data set, and more. One rather packed menu controls all these options.
The user has a great deal of control over how the graph is displayed. Major and minor tick marks chosen by xmgr can be overridden. Simple box and line graphics as well as text strings can be drawn at arbitrary locations. All strings can be displayed in a variety of fonts and sizes, with subscripts, superscripts and some special characters available.
To repeat the earlier example using gnuplot, Figure 2 shows the xmgr display immediately after loading the hits file. Figure 3 shows the symbols and legends menu used to control the appearance of the set and the set's legend respectively, while Figure 4 shows the results. Figure 5 shows us getting ready to fix the X-axis by replacing the numbers with month names with the result in Figure 6. Figure 7 is after the final touch-up, adding a title, giving the Y-axis a name, getting rid of the tenths digit in the tick labels and expanding the X-axis to fill the entire bottom of the graph. Figure 8 is the final PostScript output.
|Designing Electronics with Linux||May 22, 2013|
|Dynamic DNS—an Object Lesson in Problem Solving||May 21, 2013|
|Using Salt Stack and Vagrant for Drupal Development||May 20, 2013|
|Making Linux and Android Get Along (It's Not as Hard as It Sounds)||May 16, 2013|
|Drupal Is a Framework: Why Everyone Needs to Understand This||May 15, 2013|
|Home, My Backup Data Center||May 13, 2013|
- Designing Electronics with Linux
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Dynamic DNS—an Object Lesson in Problem Solving
- New Products
- Using Salt Stack and Vagrant for Drupal Development
- Validate an E-Mail Address with PHP, the Right Way
- Build a Skype Server for Your Home Phone System
- Tech Tip: Really Simple HTTP Server with Python
- Why Python?
- A Topic for Discussion - Open Source Feature-Richness?
- Not free anymore
2 hours 47 min ago
6 hours 35 min ago
- Reply to comment | Linux Journal
6 hours 43 min ago
- Understanding the Linux Kernel
8 hours 57 min ago
11 hours 27 min ago
- Kernel Problem
21 hours 30 min ago
- BASH script to log IPs on public web server
1 day 1 hour ago
1 day 5 hours ago
- Reply to comment | Linux Journal
1 day 6 hours ago
- All the articles you talked
1 day 8 hours ago
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi
It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?