![]() |
Intro to Scientific Computing |
![]() |
Let's examine this idea of scientific visualization. Here is a definition taken from a tutorial on the website of the Georgia Tech Scientific Visualization Laboratory--an entire institute set up to help scientists and engineers with visualization at GT.
Thus scientific visualization is a means of using graphical techniques to allow the incredibly powerful, massively parallel processing, high performance, neuro-optical wetware (your eyes and your brain), to look for patterns in the data.
I would also argue that once you have understood your data, the very next step is to present your results to others! To do that, you take the graphics of your visualization studies, clean them up, add helpful guides and text, and make presentation graphics for publication or oral presentations. So, the two are very closely related.
Shortly, we will get a tool which will serve us for both aspects.
First however, follow the link below to look at a few very impressive visualizations of some interesting data from the Wall Street Journal's Classroom page.
prepared by Karl Hartig, for the from the Wall Street Journal Classroom Edition.
These are best viewed in their PDF versions (because you can zoom in deeply), reached by clicking on the PDF icon below the image on each page.
In particular, be sure to look at
However, I find many of these presentations very thought provoking.
There are many software applications for doing SciVis.
A non-authoritative list is here.
Many of these are very powerful, and many are very expensive (>$3000).
Your computer may already have a software program to graph data (for example, Excel and other spreadsheets used in business computing will make simple graphs of data). Also, you may have had experience with other scientific analysis programs, such as Matlab, Maple, and others. These are powerful and very good applications. If you have experience with these, will come in useful since the more applications you are familiar with, the more versitile you will be as a scientist or engineer. Furthermore, your career is likely to involve several employers as you begin to build expertise in you area. Different employers will have different resources; Lawrence Livermore National Laboratory, for example, will have many different software packages, and may not blink if you ask your boss to buy Matlab at $10,000 because that is what you are familiar with.
My philosophy in this course is to, as often as possible, provide you with free tools, which you can "take with you" to your next position, and the one after that. Cygwin provides a platform for many of these tools, and Gnuplot is one of the easiest to use.
That pretty much sums it up. Gnuplot is an amazingly powerful plotting and data fitting program capable of making 2 and 3-D plots such as y = f(x), and z = f(x,y). I use it for most of the data visualization in my research.
First, let's keep our gnuplot exercises in a separate directory.
We'll save gnuplot files and data here.
We'll use Gnuplot to display three primary types of plots, often
on the same graph for comparison. These are:
This will start the gnuplot program and you should see something like this on your screen:
G N U P L O T
Version 4.2 patchlevel 2
last modified 31 Aug 2007
System: CYGWIN_NT-5.1 1.5.25(0.156/4/2)
Copyright (C) 1986 - 1993, 1998, 2004, 2007
Thomas Williams, Colin Kelley and many others
Type `help` to access the on-line reference manual.
The gnuplot FAQ is available from http://www.gnuplot.info/faq/
Send bug reports and suggestions to
Terminal type set to 'x11'
gnuplot>
This last line: gnuplot> is the Gnuplot prompt which is where you type gnuplot commands.
At the gnuplot> prompt, type
gnuplot> plot xand hit Enter. For now I will highlight what you are to type in red.
You should see a graph window with a diagonal red line. This is a plot
of the function f(x) = x.
Gnuplot's default plotting range
for x is [-10:10]
(the range between x = -10 and x = +10).
You just plotted your first function.
Next, let's add a quadratic function: f(x) = 2x2 -3x + 1
To do this, hit the UP arrow to bring back the previously entered command and now add the following, then press Enter.
gnuplot> plot x, 2*x**2 - 3*x + 1Does your plot look correct? (There should be a line and a parabola).
Notice how we entered 2x2 -3x + 1, as
2*x**2 - 3*x + 1.
We must explicitly tell gnuplot about multiplication with the * operator.
For the quadratic term, x2, we use the notation x**2, where the ** operator represents exponentiation. For example, we could do x**0.5 for the square root of x, however gnuplot has a builtin function: sqrt(x) for this.
Also, we have two functions plotted, f(x) = x, a linear
function, and f(x) = 2x2 -3x + 1, a quadratic
function.
They are both plotted with one plot command,
separating the two functions x and 2*x**2 - 3*x + 1
with a comma ,
We could plot several more functions
on this same graph, we would simply put commas between each function
to be plotted.
gnuplot> set zeroaxisThen use the UP arrow to recall your last plot command. Press Enter.
Now, let's zoom in a bit. The interesting area of the graph is where the two functions intersect. Let's narrow the plot range.
Using the UP arrow, recall your previous plot command.
Now use the LEFT arrow to move the cursor to just after the plot command, and insert a range specifier [-0.5:2] as shown below:
gnuplot> plot [-0.5:2] x, 2*x**2 - 3*x + 1Notice what this does (press Enter to execute the plot command if you haven't already). The graph should zoom in on the area btween x = -0.5 and x = 2.0.
You can also limit the y range by adding a second range specifier for the y axis.
gnuplot> plot [-0.5:2][-0.5:3] x, 2*x**2 - 3*x + 1which also limits the y range of the plot to lie between particular values.
There is a key telling us which plotted lines correspond to which
function.
The default Key is to draw short examples of the lines used and copy the
function that you typed to plot beside the associated line.
Notice that the key is run over by the plot lines. You can move the key to another place by typing
gnuplot> set key bottom right box gnuplot> replotThe replot command re-draws the last plot command.
You can get rid of the box if you don't like it by typing
gnuplot> set key nobox gnuplot> replot
A graph also needs labels. We can add these with
gnuplot> set xlabel "x" gnuplot> set ylabel "f(x)" gnuplot> set title "My First Plot" gnuplot> replotThis should label the x and y axes, and put a title above the the graph.
Also, notice that the words you want to appear in the labels must be enclosed in ""s. Words such as these in labels, etc. are called strings, and all "strings" must be enclosed in ""s
You can even clean up the Key a bit, by giving labels to the lines.
Look at the Key as it is now in your plot.
Call back your previous plot command with the UP arrow, and add
the following title option to each function
gnuplot> plot [-0.5:2][-0.5:3] x title "linear", 2*x**2 - 3*x + 1 title "quadratic"Do you see what that did to the Key?
You can learn more about the possible settings for the Key by typing
gnuplot> help set keyThis will display Help contents on the options and usage of the set key command.
One more thing. Suppose we want a bit finer resolution on the x axis
than small tics in steps of 0.5.
Suppose we wanted them every 0.25 instead. We can accomplish this by doing
gnuplot> set xtics 0.25How do you think you would adjust the y tics?
At this point, your plot should look like this.
To see what I mean: Try plot y**2, then try plot x**2
We could easily add more by separating each function by a comma.
Division is done with the forward slash: /
as in 1/x**2 for
Next: More Fun with Gnuplot