professional graphics cookbookfaculty.ses.wsu.edu/lafrance/linux-server/gauss-plot-cookbook.pdf ·...

127
GAUSSplot TM Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplot 1

Upload: others

Post on 08-Jul-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

GAUSSplotTM

Professional Graphics

Cookbook

Aptech Systems, Inc.

Powered by Tecplotr

1

Page 2: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Information in this document is subject to change without notice and does not represent acommitment on the part of Aptech Systems, Inc. The software described in this document isfurnished under a license agreement or nondisclosure agreement. The software may be used orcopied only in accordance with the terms of the agreement. The purchaser may make one copyof the software for backup purposes. No part of this manual may be reproduced or transmittedin any form or by any means, electronic or mechanical, including photocopying and recording,for any purpose other than the purchaser’s personal use without the written permission ofAptech Systems, Inc.

c©Copyright 1988-2005 by Aptech Systems, Inc., Maple Valley, WA.All Rights Reserved.

ENCSA Hierarchical Data Format (HDF) Software Library and Utilities Copyright (C)1988-1998 The Board of Trustees of the University of Illinois. All rights reserved. Contributorsinclude National Center for Supercomputing Applications (NCSA) at the University of Illinois,Fortner Software (Windows and Mac), Unidata Program Center (netCDF), The IndependentJPEG Group (JPEG), Jean-loup Gailly and Mark Adler (gzip). Bmptopnm, NetpbmCopyright (C) 1992 David W. Sanderson. Dlcompat Copyright (C) 2002 Jorge Acereda,additions and modifications by Peter O’Gorman. Ppmtopict Copyright (C) 1990 Ken Yap.

GAUSSplot, GAUSS and GAUSS Engine are trademarks of Aptech Systems, Inc.

Tecplot RS, Tecplot, Preplot, Framer and Amtec are registered trademarks or trademarks ofAmtec Engineering, Inc.

Encapsulated PostScript, FrameMaker, PageMaker, PostScript, Premier–Adobe Systems,

Incorporated. Ghostscript–Aladdin Enterprises. Linotronic, Helvetica, Times–Allied

Corporation. LaserWriter, Mac OS X–Apple Computers, Incorporated. AutoCAD,

DXF–Autodesk, Incorporated. Chears–ChevronTexaco Corporation. Compaq Computer

Corporation. Elan License Manager is a trademark of Elan Computer Group, Incorporated.

Alpha, DEC, Digital, LaserJet, HP-GL, HP-GL/2, PaintJet–Hewlett-Packard Company.

X-Designer–Imperial Software Technology. Builder Xcessory–Integrated Computer Solutions,

Incorporated. IBM, RS6000, PC/DOS–International Business Machines Corporation.

Bookman–ITC Corporation. VIP–Landmark Graphics Corporation. X

Windows–Massachusetts Institute of Technology. MGI VideoWave–MGI Software

Corporation. ActiveX, Excel, MS-DOS, Microsoft, Visual Basic, Visual C++, Visual J++,

Visual Studio, Windows, Windows Metafile–Microsoft Corporation. HDF, NCSA–National

Center for Supercomputing Applications. UNIX, OPEN LOOK–Novell, Incorporated.

Motif–Open Software Foundation, Incorporated. Gridgen–Pointwise, Incorporated. Eclipse,

FrontSim–Schlumberger, Limited. IRIS, IRIX, OpenGL–Silicon Graphics, Incorporated. Open

Windows, Solaris, Sun, Sun Raster–Sun MicroSystems, Incorporated. All other product names

mentioned herein are trademarks or registered trademarks of their respective owners.

Documentation Revision: 860 July 20, 2007

Part Number: 004785

2

Page 3: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Contents

1 Introduction 1

1.1 The GAUSSPlot API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

1.2 The GAUSSplot GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

1.3 A Note About Structure Pointers . . . . . . . . . . . . . . . . . . . . . . . 2

2 XY Line Plots 5

2.1 xylineplot1.e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

2.1.1 The Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

2.1.2 Setup and Initialization . . . . . . . . . . . . . . . . . . . . . . . . 6

2.1.3 Creating Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

2.1.4 Setting Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

2.1.5 Plotting the Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

2.2 xylineplot2.e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

2.2.1 The Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

2.2.2 Setup and Initialization . . . . . . . . . . . . . . . . . . . . . . . . 9

2.2.3 Creating Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

2.2.4 Setting Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

i

Page 4: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

2.2.5 Plotting the Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

2.3 xylineplot3.e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

2.3.1 The Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

2.3.2 Setup and Initialization . . . . . . . . . . . . . . . . . . . . . . . . 14

2.3.3 Creating Data and Writing the Data File . . . . . . . . . . . . . . 14

2.3.4 Setting Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

2.3.5 Plotting the Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

2.4 xylineplot4.e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

2.4.1 The Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

2.4.2 Setup and Initialization . . . . . . . . . . . . . . . . . . . . . . . . 24

2.4.3 Creating Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

2.4.4 Setting Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

2.4.5 Plotting the Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

3 Bar Plots 27

3.1 barplot1.e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

3.1.1 The Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

3.1.2 Setup and Initialization . . . . . . . . . . . . . . . . . . . . . . . . 28

3.1.3 Creating Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

3.1.4 Setting Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

3.1.5 Plotting the Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

3.2 barplot2.e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

3.2.1 The Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

3.2.2 Setup and Initialization . . . . . . . . . . . . . . . . . . . . . . . . 33

3.2.3 Creating Data and Writing the Data File . . . . . . . . . . . . . . 34

3.2.4 Setting Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

3.2.5 Plotting the Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

ii

Page 5: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

4 Polar Line Plots 43

4.1 polarlineplot1.e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

4.1.1 The Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

4.1.2 Setup and Initialization . . . . . . . . . . . . . . . . . . . . . . . . 44

4.1.3 Creating Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

4.1.4 Setting Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

4.1.5 Plotting the Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

4.2 polarlineplot3.e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

4.2.1 The Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46

4.2.2 Setup and Initialization . . . . . . . . . . . . . . . . . . . . . . . . 48

4.2.3 Creating Data and Writing the Data File . . . . . . . . . . . . . . 48

4.2.4 Setting Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49

4.2.5 Plotting the Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

5 2D and 3D Cartesian Plots 53

5.1 cartesianplot1.e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

5.1.1 The Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

5.1.2 Setup and Initialization . . . . . . . . . . . . . . . . . . . . . . . . 54

5.1.3 Creating Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55

5.1.4 Setting Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55

5.1.5 Plotting the Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

5.2 cartesianplot2.e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

5.2.1 The Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

5.2.2 Setup and Initialization . . . . . . . . . . . . . . . . . . . . . . . . 59

5.2.3 Creating Data and Writing the Data File . . . . . . . . . . . . . . 59

iii

Page 6: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

5.2.4 Setting Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62

5.2.5 Plotting the Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

5.3 cartesianplot3.e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

5.3.1 The Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

5.3.2 Setup and Initialization . . . . . . . . . . . . . . . . . . . . . . . . 68

5.3.3 Creating Data and Writing the Data File . . . . . . . . . . . . . . 68

5.3.4 Setting Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71

5.3.5 Plotting the Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . 74

5.4 cartesianplot5.e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74

5.4.1 The Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74

5.4.2 Setup and Initialization . . . . . . . . . . . . . . . . . . . . . . . . 77

5.4.3 Creating Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77

5.4.4 Setting Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79

5.4.5 Plotting the Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . 83

5.5 cartesianplot6.e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84

5.5.1 The Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84

5.5.2 Setup and Initialization . . . . . . . . . . . . . . . . . . . . . . . . 86

5.5.3 Creating Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87

5.5.4 Setting Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89

5.5.5 Plotting the Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . 91

5.6 volumeplot1.e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91

5.6.1 The Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92

5.6.2 Setup and Initialization . . . . . . . . . . . . . . . . . . . . . . . . 93

5.6.3 Creating Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93

5.6.4 Setting Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94

5.6.5 Plotting the Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . 96

5.7 animate2.e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96

5.7.1 The Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96

5.7.2 Setup and Initialization . . . . . . . . . . . . . . . . . . . . . . . . 99

5.7.3 Creating Data and Writing the Data File . . . . . . . . . . . . . . 99

5.7.4 Setting Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102

5.7.5 Plotting the Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . 103

iv

Page 7: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

6 2D and 3D Contour Plots 105

6.1 contourplot1.e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105

6.1.1 The Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105

6.1.2 Setup and Initialization . . . . . . . . . . . . . . . . . . . . . . . . 106

6.1.3 Creating Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107

6.1.4 Setting Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107

6.1.5 Plotting the Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . 108

6.2 contourplot3.e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108

6.2.1 The Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108

6.2.2 Setup and Initialization . . . . . . . . . . . . . . . . . . . . . . . . 111

6.2.3 Creating Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111

6.2.4 Setting Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113

6.2.5 Plotting the Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . 116

v

Page 8: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

vi

Page 9: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Introduction

1. INTRODUCTION

Chapter 1

Introduction

This manual is intended to help you learn how to write GAUSSplot programs quicklyand effectively by stepping you through many of the examples in thegaussplot/examples subdirectory of your GAUSS installation directory andexplaining each line of code. This is both a ‘cookbook’, giving you documentedexamples that you can copy and edit for your own use, and a training manual, teachingyou how to use the GAUSSplot API.

See the OVERVIEW chapter of the GAUSSplot Professional Graphics manual forexplanation of terms or concepts that are unfamiliar.

1.1 The GAUSSPlot API

The GAUSSplot API allows you to create simple graphs with only a few lines ofGAUSS code as well as generate complex, highly customized graphs which incorporatedifferent types of plots. The GAUSSplot API supports the following plot types:

XY Line plotsBar plotsPolar Line plots2D Cartesian plots2D Contour plots3D Cartesian plots3D Contour plots

It also contains commands for adding text, legends, arrows, and symbols to a graph, aswell as configuring a wide variety of output and view options.

1

Page 10: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

1. INTRODUCTION

The GAUSSplot API is fully documented in the COMMAND REFERENCE chapter ofthe GAUSSplot Professional Graphics manual. This manual is in gaussplot8.0.pdf.

1.2 The GAUSSplot GUI

When you create a graph using the GAUSSplot API, it is displayed in the GAUSSplot

graphical user interface (GUI). You may continue to customize the graph after it hasbeen displayed by using the various buttons and menu options supplied by the GUI.

Not all of the options that are available in the GUI are supported by the GAUSSplot

API. For information on how to include some of these extra GUI options in yourGAUSSplot program, see the WHAT NEXT: HOW TO CUSTOMIZE YOUR GRAPH

section in the GAUSSplot Professional Graphics manual.

The GAUSSplot GUI is documented in the Tecplotr

User’s Manual in the filetpum.pdf.

1.3 A Note About Structure Pointers

All of the information for a GAUSSplot graph is stored in a gpPlotControl structure,which you must create and initialize at the beginning of your program. You can createa gpPlotControl structure with the following line:

struct gpPlotControl gp;

To initialize a plot control structure, you may call gpPlotCreate or one of the plot typespecific gpPlotTypePlotCreate commands. For example:

gp = gpXYLinePlotCreate;

initializes gp using default values for an XY Line plot.

GAUSSplot commands are implemented using structure pointers, which hold theaddress of a structure in the GAUSS symbol table. You may input a pointer to astructure into a command by placing an ‘&’ in front of the structure name, indicatingthat you are passing in the address of that structure. For example:

call gpSetLineColor(&gp,1,1,"blue");

Or you may create a structure pointer and set it to point at the plot control structurecreated above with the following lines of code:

struct gpPlotControl *pgp;

pgp = &gp;

2

Page 11: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Introduction

1. INTRODUCTION

In the first line, placing a ‘*’ in front of pgp tells GAUSS to make pgp a pointer to aplot control structure. The second line sets pgp to the address of gp, making it apointer to gp. If you create a structure pointer this way, then you may input it into aGAUSSplot command like this:

call gpSetLineColor(pgp,1,1,"blue");

The GAUSSplot data file creation commands are also implemented using structurepointers; however, they operate on gpData structures, rather than plot controlstructures.

Structure pointers are not yet fully implemented in GAUSS . Enough functionalityexists to support the GAUSSplot API. However, you may run into problems if you tryto use them in ways that are not documented here.

3

Page 12: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

1. INTRODUCTION

4

Page 13: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

XY Line Plots

2. XY LINE PLOTS

Chapter 2

XY Line Plots

The following examples demonstrate how to create XY Line plots of varying degrees ofcomplexity.

2.1 xylineplot1.e

See Figure 2.1 for the graph produced by this example.

2.1.1 The Code

// Set up library and include file with structure definitions

library gaussplot;

#include gp.sdf

// Create gpPlotControl structure and set members to default values

struct gpPlotControl gp;

gp = gpXYLinePlotCreate;

// Generate data

x = seqa(0.2,.2,15);

y = log(x/5);

// Set the names of macro and data files to create

gpSetMacroFile(&gp,"xylineplot1.mcr");

ret = gpSetDataFile(&gp,0,"xylineplot1.plt");

5

Page 14: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

2. XY LINE PLOTS

V1

V2

0.5 1 1.5 2 2.5 3

-1.2

-1

-0.8

-0.6

-0.4

Frame 001 26 Jan 2005 xylineplot1.plt

Figure 2.1: xylineplot1.e

// Create graph

ret = gpMakeXYLinePlot(&gp,x,y,"");

2.1.2 Setup and Initialization

library gaussplot;

Activate the library containing all of the GAUSSplot commands.

#include gp.sdf

Include the file containing definitions of all GAUSSplot structures.

struct gpPlotControl gp;

Create an instance of a plot control structure.

gp = gpXYLinePlotCreate;

6

Page 15: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

XY Line Plots

2. XY LINE PLOTS

Initialize the members of gp to default values for an XY Line plot.

2.1.3 Creating Data

x = seqa(0.2,.2,15);

y = log(x/5);

Generate variables to be associated with the X and Y axes in the graph. Both x and y

are 15 × 1 vectors, and graphed together, they specify a line map with 15 data pointsdescribed by (x, y).

2.1.4 Setting Options

gpSetMacroFile(&gp,"xylineplot1.mcr");

Specify the name of the macro file to be created. If no call to gpSetMacroFile is made,then gpMakeXYLinePlot generates a temporary file, placing it in the GAUSS

temporary file directory, which is set in gauss.cfg. You are responsible for deletingtemporary files created in this manner. You may call gpCleanUp after your graph hasbeen created to delete these files.

ret = gpSetDataFile(&gp,0,"xylineplot1.plt");

Specify the name of the data file to be created. If no call to gpSetDataFile is made,then gpMakeXYLinePlot generates a temporary file. You must either delete thistemporary data file manually or call gpCleanUp after running your program to delete it.

2.1.5 Plotting the Graph

ret = gpMakeXYLinePlot(&gp,x,y,"");

Write the data file and plot the graph, using x as the X-axis variable and y as theY-axis variable. Since variable names are not specified in the last argument,gpMakeXYLinePlot will generate default variable names (V1, V2).

7

Page 16: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

2. XY LINE PLOTS

x

f(x)

0.5 1 1.5 2 2.5 3

-3

-2

-1

0

1

V2V3V4

Frame 001 26 Jan 2005 xylineplot2.plt

Figure 2.2: xylineplot2.e

2.2 xylineplot2.e

See Figure 2.2 for the graph produced by this example.

2.2.1 The Code

// Set up library and include file with structure definitions

library gaussplot;

#include gp.sdf

// Create gpPlotControl structure and set members to default values

struct gpPlotControl gp;

gp = gpXYLinePlotCreate;

// Generate data

x = seqa(0.2,.2,15);

y = log(x/5)~ln(x/5)~exp(x/5);

// Set axes titles

ret = gpSetXAxisTitle(&gp,1,1,"x");

ret = gpSetYAxisTitle(&gp,1,1,"f(x)");

8

Page 17: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

XY Line Plots

2. XY LINE PLOTS

// Add line legend

ret = gpAddLineLegend(&gp,1);

ret = gpMoveLineLegend(&gp,1,85,40);

// Set the names of macro and data files to create

gpSetMacroFile(&gp,"xylineplot2.mcr");

ret = gpSetDataFile(&gp,0,"xylineplot2.plt");

// Create graph

ret = gpMakeXYLinePlot(&gp,x,y,"");

2.2.2 Setup and Initialization

library gaussplot;

Activate the library containing all of the GAUSSplot commands.

#include gp.sdf

Include the file containing definitions of all GAUSSplot structures.

struct gpPlotControl gp;

Create an instance of a plot control structure.

gp = gpXYLinePlotCreate;

Initialize the members of gp to default values for an XY Line plot.

2.2.3 Creating Data

x = seqa(0.2,.2,15);

y = log(x/5)~ln(x/5)~exp(x/5);

Generate variables to be associated with the X and Y axes in the graph. In thisexample, x is a 15 × 1 vector, and y is a 15 × 3 matrix. When x and y are graphedtogether, the vector in x is graphed against each of the three columns in y, creatingthree distinct line maps, which each contain 15 data points.

9

Page 18: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

2. XY LINE PLOTS

2.2.4 Setting Options

ret = gpSetXAxisTitle(&gp,1,1,"x");

Specify a title for the X-axis.

ret = gpSetYAxisTitle(&gp,1,1,"f(x)");

Specify a title for the Y-axis.

ret = gpAddLineLegend(&gp,1);

Add a legend identifying each line map in the frame.

ret = gpMoveLineLegend(&gp,1,85,40);

Move the line legend to a specified location in the frame in frame units (0 − 100).

gpSetMacroFile(&gp,"xylineplot2.mcr");

Specify the name of the macro file to be created. If no call to gpSetMacroFile is made,then gpMakeXYLinePlot generates a temporary file, placing it in the GAUSS

temporary file directory, which is set in gauss.cfg. You are responsible for deletingtemporary files created in this manner. You may call gpCleanUp after your graph hasbeen created to delete these files.

ret = gpSetDataFile(&gp,0,"xylineplot2.plt");

Specify the name of the data file to be created. If no call to gpSetDataFile is made,then gpMakeXYLinePlot generates a temporary file. You must either delete thistemporary data file manually or call gpCleanUp after running your program to delete it.

2.2.5 Plotting the Graph

ret = gpMakeXYLinePlot(&gp,x,y,"");

Write the data file and plot the graph, using the vector x as the X-axis variable and thecolumns in y as the Y-axis variables. Since variable names are not specified in the lastargument, gpMakeXYLinePlot will generate default variable names (V1, V2, V3, V4).

10

Page 19: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

XY Line Plots

2. XY LINE PLOTS

X AXIS

YA

XIS

1 2 3 4

-1.2

-1

-0.8

-0.6

-0.4

-0.2

log(x/5)Frame 001 26 Jan 2005 xylineplot3.plt

X AXIS

YA

XIS

1 2 3 4

-3

-2.5

-2

-1.5

-1

-0.5

ln(x/5)Frame 002 26 Jan 2005 xylineplot3.plt

$$

$$

$$

$$

$$

∫ ∫ ∫ ∫∫

∫∫

∫∫

π π π π π π π ππ

π

ξ ξ ξ ξ ξ ξ ξ ξ ξ ξ

X

F(X

)

1 2 3 4

0.6

0.8

1

1.2

1.4

1.6

1.8

2

2.2exp(x/5)

using math/Greekcharacters assymbols

Frame 003 26 Jan 2005 xylineplot3.plt

Figure 2.3: xylineplot3.e

2.3 xylineplot3.e

See Figure 2.3 for the graph produced by this example.

2.3.1 The Code

// Set up library and include file with structure definitions

library gaussplot;

#include gp.sdf

// Create gpPlotControl structure and set members to default values

struct gpPlotControl gp;

gp = gpXYLinePlotCreate;

// Create gpData structure

struct gpData gdat;

// Generate data

// X-axis variable

x = seqa(.2,.2,20);

11

Page 20: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

2. XY LINE PLOTS

// Y-axis variables

z = log(x[.,1]/5);

z2 = ln(x[.,1]/5);

z3 = exp(x[.,1]/5);

x = x~z;

x = x~z*0.8;

x = x~z*0.6;

x = x~z*0.4;

x = x~z*0.2;

x = x~z2;

x = x~z2*0.6;

x = x~z2*0.2;

x = x~z3;

x = x~z3*0.8;

x = x~z3*0.6;

x = x~z3*0.4;

// List variable names

string vnames = { "X1", "Y1", "Y2", "Y3", "Y4", "Y5", "Y6", "Y7", "Y8", "Y9",

"Y10", "Y11", "Y12" };

// Set data in gpdata structure

gdat = gpSetPlotData(x,vnames);

// Write data file

ret = gpWritePlotData(&gdat,"xylineplot3.plt");

if (ret);

print gpGetErrorMessage(ret);

endif;

// Set error level to 2 - print error messages if errors are encountered

call gpSetErrorLevel(&gp,2);

// Specify names for macro file to be created and data file to be opened

gpSetMacroFile(&gp,"xylineplot3.mcr");

call gpSetDataFile(&gp,0,"xylineplot3.plt");

// Specify line maps for all three frames

string linemaps1 = { "X1" "Y1", "X1" "Y2", "X1" "Y3", "X1" "Y4", "X1" "Y5" };

call gpSetLineMaps(&gp,1,linemaps1);

string linemaps2 = { "X1" "Y6", "X1" "Y7", "X1" "Y8" };

call gpSetLineMaps(&gp,2,linemaps2);

string linemaps3 = { "X1" "Y9", "X1" "Y10", "X1" "Y11", "X1" "Y12" };

call gpSetLineMaps(&gp,3,linemaps3);

// Show symbol layer and change symbol options

12

Page 21: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

XY Line Plots

2. XY LINE PLOTS

call gpShowSymbolLayer(&gp,1|2|3,1);

call gpSetSymbolSkip(&gp,1,1|3|5,2,2);

call gpSetSymbolSkip(&gp,1,2|4,3,2);

call gpSetSymbolSkip(&gp,2,seqa(1,1,3),15,3);

call gpSetSymbolSkip(&gp,3,seqa(1,1,4),2,2);

call gpSetSymbolSize(&gp,1,seqa(1,1,5),2);

call gpSetSymbolSize(&gp,2,seqa(1,1,3),3);

call gpSetSymbolSize(&gp,3,seqa(1,1,4),2);

call gpSetSymbolShape(&gp,1,2,"circle");

call gpSetSymbolShape(&gp,1,3,"rtri");

call gpSetSymbolShape(&gp,1,4,"diamond");

call gpSetSymbolShape(&gp,1,5,"ltri");

call gpSetSymbolShape(&gp,2,2,"circle");

call gpSetSymbolShape(&gp,2,3,"rtri");

call gpSetSymbolShapeASCII(&gp,3,1,1,"$");

call gpSetSymbolShapeASCII(&gp,3,2,3,"r");

call gpSetSymbolShapeASCII(&gp,3,3,2,"p");

call gpSetSymbolShapeASCII(&gp,3,4,2,"x");

call gpSetSymbolColor(&gp,1,5,"purple");

call gpSetSymbolLineThickness(&gp,2,1,0.8);

call gpSetSymbolFillMode(&gp,2,2,2,"");

call gpSetSymbolFillMode(&gp,2,3,4,"CUSTOM34");

// Change line options

call gpSetLineColor(&gp,1,5,"purple");

call gpSetLineThickness(&gp,3,1|4,0.8);

call gpSetLinePattern(&gp,3,1|2,"dashdot");

call gpSetLinePatternLength(&gp,3,1,6);

// Resize and move frames to show all three in window

call gpMoveFrame(&gp,1,1,0.25,4.425,3.925);

call gpMoveFrame(&gp,2,5.575,0.25,4.425,3.925);

call gpMoveFrame(&gp,3,1,4.325,9,3.925);

// Specify titles of axes

call gpSetXAxisTitle(&gp,1,1,"X AXIS");

call gpSetYAxisTitle(&gp,1,1,"Y AXIS");

call gpSetXAxisTitle(&gp,2,1,"X AXIS");

call gpSetYAxisTitle(&gp,2,1,"Y AXIS");

call gpSetXAxisTitle(&gp,3,1,"X");

call gpSetYAxisTitle(&gp,3,1,"F(X)");

// Add titles for each frame

call gpAddTextObject(&gp,1,"title1",44,89,1,"log(x/5)");

call gpAddTextObject(&gp,2,"title2",44,89,1,"ln(x/5)");

call gpAddTextObject(&gp,3,"title3",46,89,1,"exp(x/5)");

13

Page 22: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

2. XY LINE PLOTS

// Add text box in frame 3

call gpAddTextObject(&gp,3,"text1",32,56,1,

"using math/Greek characters as symbols");

call gpSetTextObjectFont(&gp,3,"text1","times",13,2);

call gpSetTextObjectColor(&gp,3,"text1","custom41");

call gpSetTextObjectBoxType(&gp,3,"text1",2);

call gpSetTextObjectBoxColor(&gp,3,"text1","custom41","");

call gpSetTextObjectMargin(&gp,3,"text1",40);

call gpRotateTextObject(&gp,3,"text1",15);

// Show each frame one at a time and pause between each frame

gpShowDrawing(&gp,2);

call gpFramePause(&gp,1|2,0.1);

// Create graph

call gpPlot(&gp);

2.3.2 Setup and Initialization

library gaussplot;

Activate the library containing all of the GAUSSplot commands.

#include gp.sdf

Include the file containing definitions of all GAUSSplot structures.

struct gpPlotControl gp;

Create an instance of a plot control structure.

gp = gpXYLinePlotCreate;

Initialize the members of gp to default values for an XY Line plot.

2.3.3 Creating Data and Writing the Data File

struct gpData gdat;

14

Page 23: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

XY Line Plots

2. XY LINE PLOTS

Create an instance of a data structure.

x = seqa(.2,.2,20);

y = log(x[.,1]/5);

y2 = ln(x[.,1]/5);

y3 = exp(x[.,1]/5);

x = x~y;

x = x~y*0.8;

x = x~y*0.6;

x = x~y*0.4;

x = x~y*0.2;

x = x~y2;

x = x~y2*0.6;

x = x~y2*0.2;

x = x~y3;

x = x~y3*0.8;

x = x~y3*0.6;

x = x~y3*0.4;

Generate variables to be associated with the X and Y axes in all three frames. Thevariables are horizontally concatenated, so they may be input into the gpData structurewith gpSetPlotData, which takes all of the variables in a single matrix argument.

string vnames = { "X1", "Y1", "Y2", "Y3", "Y4", "Y5", "Y6", "Y7", "Y8", "Y9",

"Y10", "Y11", "Y12" };

Specify names for all of the variables.

gdat = gpSetPlotData(x,vnames);

Initialize the data structure and put the variable names and data into it.

ret = gpWritePlotData(&gdat,"xylineplot3.plt");

Write the variable names and data in gdat to the file xylineplot3.plt. See Table 2.1for a description of how the variables are laid out. The ‘Index’ column refers to theindex of the variable in the data file. You may use either the name or index of avariable to specify it in GAUSSplot commands.

if (ret);

print gpGetErrorMessage(ret);

endif;

15

Page 24: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

2. XY LINE PLOTS

Variable Name Index Definition Frame Line MapX1 1 seqa(.2,.2,20) all allY1 2 log(x[.,1]/5) 1 1Y2 3 log(x[.,1]/5)*0.8 1 2Y3 4 log(x[.,1]/5)*0.6 1 3Y4 5 log(x[.,1]/5)*0.4 1 4Y5 6 log(x[.,1]/5)*0.2 1 5Y6 7 ln(x[.,1]/5) 2 1Y7 8 ln(x[.,1]/5)*0.6 2 2Y8 9 ln(x[.,1]/5)*0.2 2 3Y9 10 exp(x[.,1]/5) 3 1Y10 11 exp(x[.,1]/5)*0.8 3 2Y11 12 exp(x[.,1]/5)*0.6 3 3Y12 13 exp(x[.,1]/5)*0.4 3 4

Table 2.1: Layout of variables in xylineplot3.e

Check the return from gpWritePlotData and print the associated error message if anerror code is returned.

2.3.4 Setting Options

call gpSetErrorLevel(&gp,2);

Set the error handling level to 2, which causes error messages to be printed if an erroris encountered. There is no need to check the returns from the commands that follow,since error messages will be printed if any of the commands fail.

gpSetMacroFile(&gp,"xylineplot3.mcr");

Specify the name of the macro file to be created. If no call to gpSetMacroFile is made,then gpPlot generates a temporary file, placing it in the GAUSS temporary filedirectory, which is set in gauss.cfg. You are responsible for deleting temporary filescreated in this manner. You may call gpCleanUp after your graph has been created todelete these files.

call gpSetDataFile(&gp,0,"xylineplot3.plt");

Specify the name of the data file to be used. It is necessary to call gpSetDataFile beforethe plotting the graph with gpPlot. gpPlot will error out if no data file is specified.

16

Page 25: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

XY Line Plots

2. XY LINE PLOTS

string linemaps1 = { "X1" "Y1", "X1" "Y2", "X1" "Y3", "X1" "Y4", "X1" "Y5" };

call gpSetLineMaps(&gp,1,linemaps1);

Specify the line maps for the first frame. A line map is a set of data points described by(x, y), where x is the variable associated with the X-axis for that line map, and y is thevariable associated with the Y-axis. Each line map is distinct and may be controlledseparately.

By default, an XY Line frame has one line map, in which the first variable in the datafile is associated with the X-axis and the second variable with the Y-axis. CallinggpSetLineMaps overrides the default and specifies all of the line maps for a frame.

Each row in linemap1 specifies a different line map, making five line maps in the firstframe. The variables in the first column are associated with the X-axis, and thevariables in the second column with the Y-axis. See Table 2.1 for a complete list of thevariables used for the line maps in each frame. As you can see in the table, the firstvariable in the data file, ‘X1’ is used as the independent variable in all of the line mapsin each frame.

string linemaps2 = { "X1" "Y6", "X1" "Y7", "X1" "Y8" };

call gpSetLineMaps(&gp,2,linemaps2);

Set three line maps in the second frame, using linemaps2.

string linemaps3 = { "X1" "Y9", "X1" "Y10", "X1" "Y11", "X1" "Y12" };

call gpSetLineMaps(&gp,3,linemaps3);

Set four line maps in the third frame, using linemaps3.

call gpShowSymbolLayer(&gp,1|2|3,1);

Activate the symbol layer in all three frames, so symbols will be shown at the datapoints.

By default, only the line layer is activated in XY Line plots.

call gpSetSymbolSkip(&gp,1,1|3|5,2,2);

Show symbols at only one in every two data points in the first, third and fifth line mapsin frame one.

call gpSetSymbolSkip(&gp,1,2|4,3,2);

17

Page 26: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

2. XY LINE PLOTS

Show symbols at only one in every three data points in the second and fourth line mapsin frame one.

call gpSetSymbolSkip(&gp,2,seqa(1,1,3),15,3);

Show symbols at the first data point and each successive data point that is at least 15%of the frame height from the previous symbol for all three line maps in frame two.

call gpSetSymbolSkip(&gp,3,seqa(1,1,4),2,2);

Show symbols at only one in every two data points in all four line maps in frame three.

call gpSetSymbolSize(&gp,1,seqa(1,1,5),2);

Set the size of the symbols in all line maps in the first frame to 2% of the frame height.

call gpSetSymbolSize(&gp,2,seqa(1,1,3),3);

Set the size of the symbols in all line maps in the second frame to 3% of the frameheight.

call gpSetSymbolSize(&gp,3,seqa(1,1,4),2);

Set the size of the symbols in all line maps in the third frame to 2% of the frame height.

call gpSetSymbolShape(&gp,1,2,"circle");

Use ‘◦’ symbols in the second line map in the first frame.

call gpSetSymbolShape(&gp,1,3,"rtri");

Use ‘⊲’ symbols in the third line map in the first frame.

call gpSetSymbolShape(&gp,1,4,"diamond");

Use ‘⋄’ symbols in the fourth line map in the first frame.

18

Page 27: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

XY Line Plots

2. XY LINE PLOTS

call gpSetSymbolShape(&gp,1,5,"ltri");

Use ‘⊳’ symbols in the fifth line map in the first frame.

call gpSetSymbolShape(&gp,2,2,"circle");

Use ‘◦’ symbols in the second line map in the second frame.

call gpSetSymbolShape(&gp,2,3,"rtri");

Use ‘⊲’ as symbols in the third line map in the second frame.

call gpSetSymbolShapeASCII(&gp,3,1,1,"$");

Use ‘$’ symbols in the first line map in the third frame.

call gpSetSymbolShapeASCII(&gp,3,2,3,"r");

Use ‘∫

’ symbols in the second line map in the third frame.

call gpSetSymbolShapeASCII(&gp,3,3,2,"p");

Use ‘π’ symbols in the first line map in the third frame.

call gpSetSymbolShapeASCII(&gp,3,4,2,"x");

Use ‘ξ’ symbols in the first line map in the third frame.

call gpSetSymbolColor(&gp,1,5,"purple");

Set the color of the symbols in the fifth line map in the first frame to purple.

call gpSetSymbolLineThickness(&gp,2,1,0.8);

Set the line thickness of the symbols in the first line map in the second frame to 0.8%of the frame height.

19

Page 28: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

2. XY LINE PLOTS

call gpSetSymbolFillMode(&gp,2,2,2,"");

Fill the symbols in the second line map in the second frame with the same color as thesymbol lines.

call gpSetSymbolFillMode(&gp,2,3,4,"CUSTOM34");

Fill the symbols in the third line map in the second frame with the color ‘custom34’.

call gpSetLineColor(&gp,1,5,"purple");

Set the color of the line in the fifth line map in the first frame to purple.

call gpSetLineThickness(&gp,3,1|4,0.8);

Set the thickness of the lines in the first and fourth line maps in the third frame to0.8% of the frame height.

call gpSetLinePattern(&gp,3,1|2,"dashdot");

Set the line pattern of the lines in the first and second line maps in the fourth frame to‘dashdot’.

call gpSetLinePatternLength(&gp,3,1,6);

Set the length of one cycle of the ‘dashdot’ pattern of the line in the first line map inthe fourth frame to 6% of the frame height.

call gpMoveFrame(&gp,1,1,0.25,4.425,3.925);

Move the first frame to the upper left-hand corner of the workspace, and resize it toroughly a quarter of the size of the workspace.

call gpMoveFrame(&gp,2,5.575,0.25,4.425,3.925);

Move the second frame to the upper right-hand corner of the workspace, and resize itto roughly a quarter of the size of the workspace.

20

Page 29: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

XY Line Plots

2. XY LINE PLOTS

call gpMoveFrame(&gp,3,1,4.325,9,3.925);

Move the third frame to the bottom of the workspace, and resize it to roughly a half ofthe size of the workspace.

call gpSetXAxisTitle(&gp,1,1,"X AXIS");

Specify a title for the X-axis in the first frame.

call gpSetYAxisTitle(&gp,1,1,"Y AXIS");

Specify a title for the Y-axis in the first frame.

call gpSetXAxisTitle(&gp,2,1,"X AXIS");

Specify a title for the X-axis in the second frame.

call gpSetYAxisTitle(&gp,2,1,"Y AXIS");

Specify a title for the Y-axis in the second frame.

call gpSetXAxisTitle(&gp,3,1,"X");

Specify a title for the X-axis in the third frame.

call gpSetYAxisTitle(&gp,3,1,"F(X)");

Specify a title for the Y-axis in the third frame.

call gpAddTextObject(&gp,1,"title1",44,89,1,"log(x/5)");

Add a text object to the top of the first frame as a title.

call gpAddTextObject(&gp,2,"title2",44,89,1,"ln(x/5)");

Add a text object to the top of the second frame as a title.

21

Page 30: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

2. XY LINE PLOTS

call gpAddTextObject(&gp,3,"title3",46,89,1,"exp(x/5)");

Add a text object to the top of the third frame as a title.

call gpAddTextObject(&gp,3,"text1",32,56,1,

"using math/Greek characters as symbols");

Add a text object named ‘text1’ to the third frame.

call gpSetTextObjectFont(&gp,3,"text1","times",13,2);

Set the font for the ‘text1’ text object to 13pt ‘times’.

call gpSetTextObjectColor(&gp,3,"text1","custom41");

Set the color of the text in ‘text1’ to ‘custom41’.

call gpSetTextObjectBoxType(&gp,3,"text1",2);

Enclose the text in ‘text1’ in a hollow box, i.e. a box with no background.

call gpSetTextObjectBoxColor(&gp,3,"text1","custom41","");

Set the color of the ‘text1’ box to ‘custom41’.

call gpSetTextObjectMargin(&gp,3,"text1",40);

Set the margin between the text in ‘text1’ and the surrounding box to 40% of the textheight.

call gpRotateTextObject(&gp,3,"text1",15);

Rotate ‘text1‘ counterclockwise 15 degrees.

gpShowDrawing(&gp,2);

Do not display drawing while each frame is being created, but display each frame afterthe drawing for that frame is completed.

22

Page 31: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

XY Line Plots

2. XY LINE PLOTS

Days

Pric

e

20 40 60 80 100 120 140

46

48

50

52

54

56

Frame 001 26 Jan 2005 xylineplot4.plt

Figure 2.4: xylineplot4.e

call gpFramePause(&gp,1|2,0.1);

Pause for 0.1 seconds after the first frame is displayed and again after the second frameis displayed.

2.3.5 Plotting the Graph

call gpPlot(&gp);

Plot the graph, using the information contained in gp.

2.4 xylineplot4.e

See Figure 2.4 for the graph produced by this example.

2.4.1 The Code

// Set up library and include file with structure definitions

23

Page 32: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

2. XY LINE PLOTS

library gaussplot;

#include gp.sdf

// Create gpPlotControl structure and set members to default values

struct gpPlotControl gp;

gp = gpXYLinePlotCreate;

// Simulate data

rndseed 345456;

pr = zeros(150,1);

pr[1] = 50;

for i(2,150,1);

pr[i] = pr[i-1] + .01*rndn(1,1)*pr[i-1];

endfor;

x = seqa(1,1,150);

// Set axes titles

ret = gpSetXAxisTitle(&gp,1,1,"Days");

ret = gpSetYAxisTitle(&gp,1,1,"Price");

// Specify the names of the macro and data files to create

gpSetMacroFile(&gp,"xylineplot4.mcr");

ret = gpSetDataFile(&gp,0,"xylineplot4.plt");

// Create line graph

ret = gpMakeXYLinePlot(&gp,x,pr,"");

2.4.2 Setup and Initialization

library gaussplot;

Activate the library containing all of the GAUSSplot commands.

#include gp.sdf

Include the file containing definitions of all GAUSSplot structures.

struct gpPlotControl gp;

Create an instance of a plot control structure.

24

Page 33: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

XY Line Plots

2. XY LINE PLOTS

gp = gpXYLinePlotCreate;

Initialize the members of gp to default values for an XY Line plot.

2.4.3 Creating Data

rndseed 345456;

pr = zeros(150,1);

pr[1] = 50;

for i(2,150,1);

pr[i] = pr[i-1] + .01*rndn(1,1)*pr[i-1];

endfor;

x = seqa(1,1,150);

Simulate data for a plot of the price of an item over time measured in days, where x isthe variable that represents time, and pr represents price.

2.4.4 Setting Options

ret = gpSetXAxisTitle(&gp,1,1,"Days");

Specify a title for the X-axis.

ret = gpSetYAxisTitle(&gp,1,1,"Price");

Specify a title for the Y-axis.

gpSetMacroFile(&gp,"xylineplot4.mcr");

Specify the name of the macro file to be created. If no call to gpSetMacroFile is made,then gpMakeXYLinePlot generates a temporary file, placing it in the GAUSS

temporary file directory, which is set in gauss.cfg. You are responsible for deletingtemporary files created in this manner. You may call gpCleanUp after your graph hasbeen created to delete these files.

ret = gpSetDataFile(&gp,0,"xylineplot4.plt");

Specify the name of the data file to be created. If no call to gpSetDataFile is made,then gpMakeXYLinePlot generates a temporary file. You must either delete thistemporary data file manually or call gpCleanUp after running your program to delete it.

25

Page 34: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

2. XY LINE PLOTS

2.4.5 Plotting the Graph

ret = gpMakeXYLinePlot(&gp,x,pr,"");

Write the data file and plot the graph, using x as the X-axis variable and pr as theY-axis variable. Since variable names are not specified in the last argument,gpMakeXYLinePlot will generate default variable names (V1, V2).

26

Page 35: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Bar Plots

3. BAR PLOTS

Chapter 3

Bar Plots

3.1 barplot1.e

See Figure 3.1 for the graph produced by this example.

3.1.1 The Code

// Set up library and include file with structure definitions

library gaussplot;

#include gp.sdf

// Create gpPlotControl structure and set members to default values

struct gpPlotControl gp;

gp = gpBarPlotCreate;

// Generate data

p = pi;

x = seqa(0,p/4,15)~seqa(p/8,p/4,15);

y = sin(x[.,1]/3)~cos(x[.,1]/3);

// Specify names for macro and data files to be created

gpSetMacroFile(&gp,"barplot1.mcr");

ret = gpSetDataFile(&gp,0,"barplot1.plt");

// Create bar graph

ret = gpMakeBarPlot(&gp,x,y,"");

27

Page 36: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

3. BAR PLOTS

V1, V2

V3,

V4

0 2 4 6 8 10-1

-0.5

0

0.5

1

Frame 001 26 Jan 2005 barplot1.plt

Figure 3.1: barplot1.e

3.1.2 Setup and Initialization

library gaussplot;

Activate the library containing all of the GAUSSplot commands.

#include gp.sdf

Include the file containing definitions of all GAUSSplot structures.

struct gpPlotControl gp;

Create an instance of a plot control structure.

gp = gpBarPlotCreate;

Initialize the members of gp to default values for a Bar plot.

28

Page 37: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Bar Plots

3. BAR PLOTS

3.1.3 Creating Data

p = pi;

x = seqa(0,p/4,15)~seqa(p/8,p/4,15);

y = sin(x[.,1]/3)~cos(x[.,1]/3);

Generate variables to be associated with the X and Y axes in the graph. Both x and y

are 15 × 2 matrices. When graphed together, each column in x is graphed against thecorresponding column in y, creating two distinct line maps, which each contain 15 datapoints.

3.1.4 Setting Options

gpSetMacroFile(&gp,"barplot1.mcr");

Specify the name of the macro file to be created. If no call to gpSetMacroFile is made,then gpMakeBarPlot generates a temporary file, placing it in the GAUSS temporaryfile directory, which is set in gauss.cfg. You are responsible for deleting temporaryfiles created in this manner. You may call gpCleanUp after your graph has beencreated to delete these files.

ret = gpSetDataFile(&gp,0,"barplot1.plt");

Specify the name of the data file to be created. If no call to gpSetDataFile is made,then gpMakeBarPlot generates a temporary file. You must either delete this temporarydata file manually or call gpCleanUp after running your program to delete it.

3.1.5 Plotting the Graph

ret = gpMakeBarPlot(&gp,x,y,"");

Write the data file and plot the graph, using the columns in x as the X-axis variablesand the columns in y as the Y-axis variables. Since variable names are not specified inthe last argument, gpMakeBarPlot will generate default variable names (V1, V2, V3,V4).

29

Page 38: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

3. BAR PLOTS

X AXIS

YA

XIS

0 10

-0.5

0

0.5

sin(x/3)Frame 001 26 Jan 2005 barplot2.plt

X AXIS

YA

XIS

0 5 10

-0.5

0

0.5

1cos(x/3)

Frame 002 26 Jan 2005 barplot2.plt

F(X)

F(X

)

0 2 4 6 8 10 12 14

-1

-0.5

0

0.5

1

sin(x/3)+cos(x/3)

(sin(x/3)+cos(x/3))*.8

(sin(x/3)+cos(x/3))*.6

(sin(x/3)+cos(x/3))*.4

sin(x/3)+cos(x/3)

Placetexthere

Figure 3.2: barplot2.e

3.2 barplot2.e

See Figure 3.2 for the graph produced by this example.

3.2.1 The Code

// Set up library and include file with structure definitions

library gaussplot;

#include gp.sdf

// Create gpPlotControl structure and set members to default values

struct gpPlotControl gp;

gp = gpBarPlotCreate;

// Create gpData structure

struct gpData gdat;

// Generate data

// X-axis variable

x = seqa(0,1,15);

x = x~x[.,1]+.2;

30

Page 39: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Bar Plots

3. BAR PLOTS

x = x~x[.,1]+.4;

x = x~x[.,1]+.6;

x = x~x[.,1]+.8;

// Y-axis variables

y = sin(x[.,1]/3);

y2 = cos(x[.,1]/3);

y3 = sin(x[.,1]/3)+cos(x[.,1]/3);

x = x~y;

x = x~y*0.8;

x = x~y*0.6;

x = x~y*0.4;

x = x~y*0.2;

x = x~y2;

x = x~y2*0.6;

x = x~y2*0.2;

x = x~y3;

x = x~y3*0.8;

x = x~y3*0.6;

x = x~y3*0.4;

// List variable names

string vnames = { "X1", "X2", "X3", "X4", "X5", "Y1", "Y2", "Y3", "Y4", "Y5",

"Y6", "Y7", "Y8", "Y9", "Y10", "Y11", "Y12" };

// Set data in gpdata structure

gdat = gpSetPlotData(x,vnames);

// Write data file

ret = gpWritePlotData(&gdat,"barplot2.plt");

// Specify names for macro file to be created and data file to be opened

gpSetMacroFile(&gp,"barplot2.mcr");

ret = gpSetDataFile(&gp,0,"barplot2.plt");

// Specify line maps for all three frames

string linemaps1 = { "X1" "Y1", "X2" "Y2", "X3" "Y3", "X4" "Y4", "X5" "Y5" };

ret = gpSetLineMaps(&gp,1,linemaps1);

string linemaps2 = { "X1" "Y6", "X2" "Y7", "X3" "Y8" };

ret = gpSetLineMaps(&gp,2,linemaps2);

string linemaps3 = { "X1" "Y9", "X1" "Y10", "X1" "Y11", "X1" "Y12" };

ret = gpSetLineMaps(&gp,3,linemaps3);

// Change the bar size to 1 for all line maps in frames 1 and 2

ret = gpSetBarWidth(&gp,1,seqa(1,1,5),1);

ret = gpSetBarWidth(&gp,2,seqa(1,1,3),1);

31

Page 40: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

3. BAR PLOTS

// Change the bar color to purple for line map 1 in frame 3

ret = gpSetBarColor(&gp,3,1,"purple","purple");

// Resize and move frames to show all three in window

ret = gpMoveFrame(&gp,1,1,0.25,4.425,3.925);

ret = gpMoveFrame(&gp,2,5.575,0.25,4.425,3.925);

ret = gpMoveFrame(&gp,3,1,4.325,9,3.925);

// Specify titles of axes

ret = gpSetXAxisTitle(&gp,1,1,"X AXIS");

ret = gpSetYAxisTitle(&gp,1,1,"Y AXIS");

ret = gpSetXAxisTitle(&gp,2,1,"X AXIS");

ret = gpSetYAxisTitle(&gp,2,1,"Y AXIS");

ret = gpSetXAxisTitle(&gp,3,1,"F(X)");

ret = gpSetYAxisTitle(&gp,3,1,"F(X)");

// Add titles for each frame

ret = gpAddTextObject(&gp,1,"text1",43,89,1,"sin(x/3)");

ret = gpAddTextObject(&gp,2,"text2",43,89,1,"cos(x/3)");

ret = gpAddTextObject(&gp,3,"text3",43,89,1,"sin(x/3)+cos(x/3)");

// Add text box in frame 3

ret = gpAddTextObject(&gp,3,"text1",30,20,1,"Place"$|"text"$|"here");

ret = gpSetTextObjectFont(&gp,3,"text1","timesitalicbold",16,2);

ret = gpSetTextObjectColor(&gp,3,"text1","custom41");

ret = gpSetTextObjectLineSpacing(&gp,3,"text1",1.25);

ret = gpSetTextObjectBoxStyle(&gp,3,"text1","filled",0.8,"custom41","custom2");

ret = gpSetTextObjectMargin(&gp,3,"text1",50);

// Add arrows in frame 3

ret = gpAddArrow(&gp,3,"arrow1",6.25,0.5,7.75,0.75,2);

ret = gpAddArrow(&gp,3,"arrow2",8.25,0,10.75,0.75,2);

ret = gpSetArrowColor(&gp,3,"arrow1","custom54");

ret = gpSetArrowHeadAttachment(&gp,3,"arrow1","bothends");

ret = gpSetArrowHeadType(&gp,3,"arrow1","filled");

ret = gpSetArrowLineThickness(&gp,3,"arrow1",0.8);

ret = gpSetArrowColor(&gp,3,"arrow2","custom28");

ret = gpSetArrowHeadStyle(&gp,3,"arrow2","filled","beginning",5,20);

ret = gpSetArrowLineThickness(&gp,3,"arrow2",1);

// Set axis label styles

ret = gpSetXAxisLabelFont(&gp,1,1,"courierbold",11,2);

ret = gpSetXAxisLabelSkip(&gp,1,1,2);

ret = gpSetXAxisLabelColor(&gp,1,1,3);

ret = gpSetYAxisLabelFont(&gp,1,1,"timesitalic",4,1);

32

Page 41: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Bar Plots

3. BAR PLOTS

ret = gpSetYAxisLabelOffset(&gp,1,1,4);

// Set axis title styles

ret = gpSetXAxisTitleFont(&gp,1,1,"courierbold",15,2);

ret = gpSetXAxisTitleColor(&gp,1,1,3);

ret = gpSetXAxisColor(&gp,1,1,3);

ret = gpSetXAxisThickness(&gp,1,1,0.8);

ret = gpSetYAxisTitleFont(&gp,1,1,"timesitalic",5,1);

ret = gpSetYAxisTitleOffset(&gp,1,1,7);

// Set axes in frame 2 to xydependent

ret = gpMakeAxesXYDependent(&gp,2,.175);

// Add line legend for frame 3

names = "sin(x/3)+cos(x/3)"$|"(sin(x/3)+cos(x/3))*.8"$|

"(sin(x/3)+cos(x/3))*.6"$|"(sin(x/3)+cos(x/3))*.4";

ret = gpSetLineMapNames(&gp,3,names);

ret = gpAddLineLegend(&gp,3);

ret = gpMoveLineLegend(&gp,3,90,95);

ret = gpSetLineLegendLineSpacing(&gp,3,1.5);

ret = gpSetLineLegendBoxType(&gp,3,"hollow");

ret = gpSetLineLegendMargin(&gp,3,5);

// Do not show border for frame 3

ret = gpSetFrameStyle(&gp,3,0,0,1);

// Create bar graph

ret = gpPlot(&gp);

3.2.2 Setup and Initialization

library gaussplot;

Activate the library containing all of the GAUSSplot commands.

#include gp.sdf

Include the file containing definitions of all GAUSSplot structures.

struct gpPlotControl gp;

33

Page 42: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

3. BAR PLOTS

Create an instance of a plot control structure.

gp = gpBarPlotCreate;

Initialize the members of gp to default values for a Bar plot.

3.2.3 Creating Data and Writing the Data File

struct gpData gdat;

Create an instance of a data structure.

x = seqa(0,1,15);

x = x~x[.,1]+.2;

x = x~x[.,1]+.4;

x = x~x[.,1]+.6;

x = x~x[.,1]+.8;

y = sin(x[.,1]/3);

y2 = cos(x[.,1]/3);

y3 = sin(x[.,1]/3)+cos(x[.,1]/3);

x = x~y;

x = x~y*0.8;

x = x~y*0.6;

x = x~y*0.4;

x = x~y*0.2;

x = x~y2;

x = x~y2*0.6;

x = x~y2*0.2;

x = x~y3;

x = x~y3*0.8;

x = x~y3*0.6;

x = x~y3*0.4;

Generate variables to be associated with the X and Y axes in all three frames. Thevariables are horizontally concatenated, so they may be inputted into the gpData

structure with gpSetPlotData, which takes all of the variables in a single matrixargument. Table 3.1 displays how the variables are laid out.

string vnames = { "X1", "X2", "X3", "X4", "X5", "Y1", "Y2", "Y3", "Y4", "Y5",

"Y6", "Y7", "Y8", "Y9", "Y10", "Y11", "Y12" };

34

Page 43: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Bar Plots

3. BAR PLOTS

Variable Name Index Definition Frame Line MapX1 1 seqa(0,1,15) 1 1

2 13 1,2,3,4

X2 2 seqa(0,1,15)+0.2 1 22 2

X3 3 seqa(0,1,15)+0.4 1 32 3

X4 4 seqa(0,1,15)+0.6 1 4X5 5 seqa(0,1,15)+0.8 1 5Y1 6 sin(x[.,1]/3) 1 1Y2 7 sin(x[.,1]/3)*0.8 1 2Y3 8 sin(x[.,1]/3)*0.6 1 3Y4 9 sin(x[.,1]/3)*0.4 1 4Y5 10 sin(x[.,1]/3)*0.2 1 5Y6 11 cos(x[.,1]/3) 2 1Y7 12 cos(x[.,1]/3)*0.6 2 2Y8 13 cos(x[.,1]/3)*0.2 2 3Y9 14 sin(x[.,1]/3)+cos(x[.,1]/3) 3 1Y10 15 sin(x[.,1]/3)+cos(x[.,1]/3)*0.8 3 2Y11 16 sin(x[.,1]/3)+cos(x[.,1]/3)*0.6 3 3Y12 17 sin(x[.,1]/3)+cos(x[.,1]/3)*0.4 3 4

Table 3.1: Layout of variables in barplot2.e

Specify names for all of the variables.

gdat = gpSetPlotData(x,vnames);

Initialize the data structure and put the variable names and data into it.

ret = gpWritePlotData(&gdat,"barplot2.plt");

Write the variable names and data in gdat to the file barplot2.plt. See Table 3.1 for adescription of how the variables are laid out. The ‘Index’ column refers to the index ofthe variable in the data file. You may use either the name or index of a variable tospecify it in GAUSSplot commands.

3.2.4 Setting Options

gpSetMacroFile(&gp,"barplot2.mcr");

35

Page 44: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

3. BAR PLOTS

Specify the name of the macro file to be created. If no call to gpSetMacroFile is made,then gpPlot generates a temporary file, placing it in the GAUSS temporary filedirectory, which is set in gauss.cfg. You are responsible for deleting temporary filescreated in this manner. You may call gpCleanUp after your graph has been created todelete these files.

ret = gpSetDataFile(&gp,0,"barplot2.plt");

Specify the name of the data file to be used. It is necessary to call gpSetDataFile beforethe plotting the graph with gpPlot. gpPlot will error out if no data file is specified.

string linemaps1 = { "X1" "Y1", "X2" "Y2", "X3" "Y3", "X4" "Y4", "X5" "Y5" };

ret = gpSetLineMaps(&gp,1,linemaps1);

Specify the line maps for the first frame. A line map is a set of data points described by(x, y), where x is the variable associated with the X-axis for that line map, and y is thevariable associated with the Y-axis. Each line map is distinct and may be controlledseparately.

Each row in linemap1 specifies a different line map, making five line maps in the firstframe. The variables in the first column are associated with the X-axis, and thevariables in the second column with the Y-axis. See Table 3.1 for a complete list of thevariables used for the line maps in each frame. As you can see in the table, some of thevariables are used for more than one line map. For example, the first variable in thedata file, ‘X1’, is used for the first line map in the first frame, the first line map in thesecond frame, and all four line maps in the third frame.

string linemaps2 = { "X1" "Y6", "X2" "Y7", "X3" "Y8" };

ret = gpSetLineMaps(&gp,2,linemaps2);

Set three line maps in the second frame, using linemaps2.

string linemaps3 = { "X1" "Y9", "X1" "Y10", "X1" "Y11", "X1" "Y12" };

ret = gpSetLineMaps(&gp,3,linemaps3);

Set four line maps in the third frame, using linemaps3.

ret = gpSetBarWidth(&gp,1,seqa(1,1,5),1);

Set the width of the bars in all five line maps in the first frame to 1% of the frameheight. The bar layer is activated by default in Bar plots.

36

Page 45: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Bar Plots

3. BAR PLOTS

ret = gpSetBarWidth(&gp,2,seqa(1,1,3),1);

Set the width of the bars in all three line maps in the second frame to 1% of the frameheight.

ret = gpSetBarColor(&gp,3,1,"purple","purple");

Set the line and fill color of the bars in the first line map in the third frame to purple.

ret = gpMoveFrame(&gp,1,1,0.25,4.425,3.925);

Move the first frame to the upper left-hand corner of the workspace, and resize it toroughly one quarter of the size of the workspace.

ret = gpMoveFrame(&gp,2,5.575,0.25,4.425,3.925);

Move the second frame to the upper right-hand corner of the workspace, and resize itto roughly one quarter of the size of the workspace.

ret = gpMoveFrame(&gp,3,1,4.325,9,3.925);

Move the third frame to the bottom of the workspace, and resize it to roughly one halfof the size of the workspace.

ret = gpSetXAxisTitle(&gp,1,1,"X AXIS");

Specify a title for the X-axis in the first frame.

ret = gpSetYAxisTitle(&gp,1,1,"Y AXIS");

Specify a title for the Y-axis in the first frame.

ret = gpSetXAxisTitle(&gp,2,1,"X AXIS");

Specify a title for the X-axis in the second frame.

ret = gpSetYAxisTitle(&gp,2,1,"Y AXIS");

37

Page 46: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

3. BAR PLOTS

Specify a title for the Y-axis in the second frame.

ret = gpSetXAxisTitle(&gp,3,1,"F(X)");

Specify a title for the X-axis in the third frame.

ret = gpSetYAxisTitle(&gp,3,1,"F(X)");

Specify a title for the Y-axis in the third frame.

ret = gpAddTextObject(&gp,1,"text1",43,89,1,"sin(x/3)");

Add a text object to the top of the first frame as a title.

ret = gpAddTextObject(&gp,2,"text2",43,89,1,"cos(x/3)");

Add a text object to the top of the second frame as a title.

ret = gpAddTextObject(&gp,3,"text3",43,89,1,"sin(x/3)+cos(x/3)");

Add a text object to the top of the third frame as a title.

ret = gpAddTextObject(&gp,3,"text1",30,20,1,"Place"$|"text"$|"here");

Add a multi-line text object named ‘text1’ to the third frame.

ret = gpSetTextObjectFont(&gp,3,"text1","timesitalicbold",16,2);

Set the font of the text in the ‘text1’ text object to 16pt ‘timesitalicbold’.

ret = gpSetTextObjectColor(&gp,3,"text1","custom41");

Set the color of the text in ‘text1’ to ‘custom41’.

ret = gpSetTextObjectLineSpacing(&gp,3,"text1",1.25);

38

Page 47: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Bar Plots

3. BAR PLOTS

Set the line spacing in ‘text1’ to 1.25.

ret = gpSetTextObjectBoxStyle(&gp,3,"text1","filled",0.8,"custom41","custom2");

Enclose the text in ‘text1’ in a filled box. Set the thickness of the box outline to 0.8%of the frame height, and use ‘custom41’ as the box outline color and ‘custom2’ as thebox fill color.

ret = gpSetTextObjectMargin(&gp,3,"text1",50);

Set the margin between the text in ‘text1’ and the surrounding box to 50% of the textheight.

ret = gpAddArrow(&gp,3,"arrow1",6.25,0.5,7.75,0.75,2);

Add an arrow named ‘arrow1’ to the third frame.

ret = gpAddArrow(&gp,3,"arrow2",8.25,0,10.75,0.75,2);

Add an arrow named ‘arrow2’ to the third frame.

ret = gpSetArrowColor(&gp,3,"arrow1","custom54");

Set the color of ‘arrow1’ to ‘custom54’.

ret = gpSetArrowHeadAttachment(&gp,3,"arrow1","bothends");

Attach arrow heads to both ends of ‘arrow1’

ret = gpSetArrowHeadType(&gp,3,"arrow1","filled");

Use filled arrow heads for ‘arrow1’.

ret = gpSetArrowLineThickness(&gp,3,"arrow1",0.8);

Set the line thickness of ‘arrow1’ to 0.8% of the frame height.

39

Page 48: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

3. BAR PLOTS

ret = gpSetArrowColor(&gp,3,"arrow2","custom28");

Set the color of ‘arrow2’ to ‘custom28’.

ret = gpSetArrowHeadStyle(&gp,3,"arrow2","filled","beginning",5,20);

Attach a filled arrow head to the beginning of ‘arrow2’. Set the arrow head size to 5%of the frame height, and set the angle that the arrow head makes with the line segmentto 20 degrees.

ret = gpSetArrowLineThickness(&gp,3,"arrow2",1);

Set the line thickness of ‘arrow2’ to 1% of the frame height.

ret = gpSetXAxisLabelFont(&gp,1,1,"courierbold",11,2);

Use 11pt ‘courierbold’ as the font type for the X-axis tick labels in the first frame.

ret = gpSetXAxisLabelSkip(&gp,1,1,2);

Show labels at only one in every two tick marks on the X-axis in the first frame.

ret = gpSetXAxisLabelColor(&gp,1,1,3);

Set the color of the X-axis tick labels in the first frame to red.

ret = gpSetYAxisLabelFont(&gp,1,1,"timesitalic",4,1);

Use a ‘timesitalic’ font that is 4% of the frame height for the Y-axis tick labels in thefirst frame.

ret = gpSetYAxisLabelOffset(&gp,1,1,4);

Set the offset of the tick labels from the Y-axis line in the first frame to 4% of theframe width.

ret = gpSetXAxisTitleFont(&gp,1,1,"courierbold",15,2);

40

Page 49: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Bar Plots

3. BAR PLOTS

Use a 15pt ‘courierbold’ font for the X-axis title in the first frame.

ret = gpSetXAxisTitleColor(&gp,1,1,3);

Set the color of the X-axis title in the first frame to red.

ret = gpSetXAxisColor(&gp,1,1,3);

Set the color of the X-axis line in the first frame to red.

ret = gpSetXAxisThickness(&gp,1,1,0.8);

Set the thickness of the X-axis line in the first frame to 0.8% of the frame height.

ret = gpSetYAxisTitleFont(&gp,1,1,"timesitalic",5,1);

Use a ‘timesitalic’ font that is 5% of the frame height for the Y-axis title in the firstframe.

ret = gpSetYAxisTitleOffset(&gp,1,1,7);

Set the offset of the title from the Y-axis line in the first frame to 7% of the framewidth.

ret = gpMakeAxesXYDependent(&gp,2,.175);

Set 0.175 units on the Y-axis equal in length to one unit on the X-axis in the secondframe.

names = "sin(x/3)+cos(x/3)"$|"(sin(x/3)+cos(x/3))*.8"$|

"(sin(x/3)+cos(x/3))*.6"$|"(sin(x/3)+cos(x/3))*.4";

ret = gpSetLineMapNames(&gp,3,names);

Set the names of the line maps in frame three to definitions of the dependent variablesused in each line map. These names are used in the line legend that is added below.

ret = gpAddLineLegend(&gp,3);

41

Page 50: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

3. BAR PLOTS

Add a legend identifying each line map in frame three.

ret = gpMoveLineLegend(&gp,3,90,95);

Move the line legend to the upper right-hand corner of the frame.

ret = gpSetLineLegendLineSpacing(&gp,3,1.5);

Set the line spacing in the line legend to 1.5.

ret = gpSetLineLegendBoxType(&gp,3,"hollow");

Enclose the line legend in a hollow box, i.e. a box with no background.

ret = gpSetLineLegendMargin(&gp,3,5);

Set the margin between the line legend text and the surrounding box to 5% of thelegend box width.

ret = gpSetFrameStyle(&gp,3,0,0,1);

Do not display the frame header or border for the third frame.

3.2.5 Plotting the Graph

ret = gpPlot(&gp);

Plot the graph using the information contained in gp.

42

Page 51: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Polar Line Plots

4. POLAR LINE PLOTS

Chapter 4

Polar Line Plots

4.1 polarlineplot1.e

See Figure 4.1 for the graph produced by this example.

4.1.1 The Code

// Set up library and include file with structure definitions

library gaussplot;

#include gp.sdf

// Create gpPlotControl structure and set members to default values

struct gpPlotControl gp;

gp = gpPolarLinePlotCreate;

// Generate data

theta = seqa(0,5,37);

r = sin(theta*pi/180);

// Set the names of macro and data files to create

gpSetMacroFile(&gp,"polarlineplot1.mcr");

ret = gpSetDataFile(&gp,0,"polarlineplot1.plt");

// Create graph

ret = gpMakePolarLinePlot(&gp,theta,r,"");

43

Page 52: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

4. POLAR LINE PLOTS

V1

V2

0

30

60

90

120

150

180

210

240

270

300

330

0 0.2 0.4 0.6 0.8

Frame 001 26 Jan 2005 polarlineplot1.plt

Figure 4.1: polarlineplot1.e

4.1.2 Setup and Initialization

library gaussplot;

Activate the library containing all of the GAUSSplot commands.

#include gp.sdf

Include the file containing definitions of all GAUSSplot structures.

struct gpPlotControl gp;

Create an instance of a plot control structure.

gp = gpPolarLinePlotCreate;

Initialize the members of gp to default values for a Polar Line plot.

44

Page 53: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Polar Line Plots

4. POLAR LINE PLOTS

4.1.3 Creating Data

theta = seqa(0,5,37);

r = sin(theta*pi/180);

Generate variables to be associated with the Theta and R axes in the graph. Boththeta and r are 37 × 1 vectors, and graphed together, they specify a line map with 37data points described by (theta, r).

4.1.4 Setting Options

gpSetMacroFile(&gp,"polarlineplot1.mcr");

Specify the name of the macro file to be created. If no call to gpSetMacroFile is made,then gpMakePolarLinePlot generates a temporary file, placing it in the GAUSS

temporary file directory, which is set in gauss.cfg. You are responsible for deletingtemporary files created in this manner. You may call gpCleanUp after your graph hasbeen created to delete these files.

ret = gpSetDataFile(&gp,0,"polarlineplot1.plt");

Specify the name of the data file to be created. If no call to gpSetDataFile is made,then gpMakePolarLinePlot generates a temporary file. You must either delete thistemporary data file manually or call gpCleanUp after running your program to delete it.

4.1.5 Plotting the Graph

ret = gpMakePolarLinePlot(&gp,theta,r,"");

Write the data file and plot the graph, using theta as the Theta-axis variable and r asthe R-axis variable. Since variable names are not specified in the last argument,gpMakePolarLinePlot will generate default variable names (V1, V2).

4.2 polarlineplot3.e

See Figure 4.2 for the graph produced by this example.

45

Page 54: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

4. POLAR LINE PLOTS

ThetaR

0

1__ π6

1__ π3

1__ π2

2__ π3

5__ π6

π

7__ π6

4__ π3

3__ π2

5__ π3

11___ π6

0 0.2 0.4 0.6 0.8

(θ1,sin(0.5*θ1))(θ2,sin(0.5*θ1))(θ2,abs(sin(θ1)))(abs(cos(θ1)),abs(sin(θ1)))

Frame 001 26 Jan 2005 polarlineplot3.plt

Figure 4.2: polarlineplot3.e

4.2.1 The Code

// Set up library and include file with structure definitions

library gaussplot;

#include gp.sdf

// Create gpPlotControl structure and set members to default values

struct gpPlotControl gp;

struct gpData gdat;

gp = gpPolarLinePlotCreate;

// Generate data

n = seqa(0,1,101);

theta1 = n.*pi/50;

radius1 = sin(0.5.*theta1);

theta2 = seqa(0,pi/100,101);

radius2 = abs(sin(theta1));

radius3 = abs(cos(theta1));

string vnames = { "V1","V2","V3","V4","V5" };

// Set data in gpData structure

gdat = gpSetPlotData(theta1~theta2~radius1~radius2~radius3,vnames);

46

Page 55: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Polar Line Plots

4. POLAR LINE PLOTS

// Write data file

ret = gpWritePlotData(&gdat,"polarlineplot3.plt");

// Set names of data file to use and macro file to create

ret = gpSetDataFile(&gp,0,"polarlineplot3.plt");

gpSetMacroFile(&gp,"polarlineplot3.mcr");

// Specify line maps

string linemaps = { "V1" "V3", "V2" "V3", "V2" "V4", "V5" "V4" };

ret = gpSetLineMaps(&gp,1,linemaps);

// Specify line thickness for line layer

ret = gpSetLineThickness(&gp,1,1|2|3|4,0.3);

// Show symbol layer and set symbol options

ret = gpShowSymbolLayer(&gp,1,1);

ret = gpSetSymbolSize(&gp,1,1|2|3|4,1);

ret = gpSetSymbolFillMode(&gp,1,1|2|3|4,2,"");

ret = gpSetSymbolShape(&gp,1,2,"circle");

ret = gpSetSymbolSkip(&gp,1,seqa(1,1,4),5,2);

ret = gpSetSymbolShape(&gp,1,3,"rtri");

ret = gpSetSymbolShape(&gp,1,4,"diamond");

// Add line legend

string names = {

"(<greek>q</greek><sub>1</sub>,sin(0.5*<greek>q</greek><sub>1</sub>))",

"(<greek>q</greek><sub>2</sub>,sin(0.5*<greek>q</greek><sub>1</sub>))",

"(<greek>q</greek><sub>2</sub>,abs(sin(<greek>q</greek><sub>1</sub>)))",

"(abs(cos(<greek>q</greek><sub>1</sub>)),

abs(sin(<greek>q</greek><sub>1</sub>)))" };

ret = gpSetLineMapNames(&gp,1,names);

ret = gpAddLineLegend(&gp,1);

ret = gpMoveLineLegend(&gp,1,100,16);

ret = gpSetLineLegendMargin(&gp,1,5);

ret = gpSetLineLegendBoxType(&gp,1,1);

ret = gpSetLineLegendFont(&gp,1,"times",14,2);

// Resize plot to make room for legend

ret = gpSetMagnification(&gp,1,0.7);

ret = gpSetTranslation(&gp,1,-9,3.5);

// Set theta mode to radians and set polar axes titles

ret = gpSetThetaMode(&gp,1,2);

ret = gpSetPolarAxesTitles(&gp,1,"Theta","R");

47

Page 56: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

4. POLAR LINE PLOTS

// Create graph

ret = gpPlot(&gp);

4.2.2 Setup and Initialization

library gaussplot;

Activate the library containing all of the GAUSSplot commands.

#include gp.sdf

Include the file containing definitions of all GAUSSplot structures.

struct gpPlotControl gp;

Create an instance of a plot control structure.

struct gpData gdat;

Create an instance of a data structure.

gp = gpPolarLinePlotCreate;

Initialize the members of gp to default values for a Polar Line plot.

4.2.3 Creating Data and Writing the Data File

n = seqa(0,1,101);

theta1 = n.*pi/50;

radius1 = sin(0.5.*theta1);

theta2 = seqa(0,pi/100,101);

radius2 = abs(sin(theta1));

radius3 = abs(cos(theta1));

Generate variables to be associated with the Theta and R axes in all three frames.

48

Page 57: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Polar Line Plots

4. POLAR LINE PLOTS

GAUSSplot Index GAUSS Line Map AxisVariable Name Variable NameV1 1 theta1 1 ThetaV2 2 theta2 2,3 ThetaV3 3 radius1 1,2 RV4 4 radius2 3,4 RV5 5 radius3 4 Theta

Table 4.1: Layout of variables in polarlineplot3.e

string vnames = { "V1","V2","V3","V4","V5" };

Specify names for all of the variables.

gdat = gpSetPlotData(theta1~theta2~radius1~radius2~radius3,vnames);

Initialize the data structure and put the variable names and data into it. The variablesare horizontally concatenated because gpSetPlotData takes all of the variables in asingle matrix argument.

ret = gpWritePlotData(&gdat,"polarlineplot3.plt");

Write the variable names and data in gdat to the file polarlineplot3.plt. See Table4.1 for a description of how the variables are laid out. The ‘Index’ column refers to theindex of the variable in the data file. You may use either the name or index of avariable to specify it in GAUSSplot commands.

4.2.4 Setting Options

ret = gpSetDataFile(&gp,0,"polarlineplot3.plt");

Specify the name of the data file to be used. It is necessary to call gpSetDataFile beforethe plotting the graph with gpPlot. gpPlot will error out if no data file is specified.

gpSetMacroFile(&gp,"polarlineplot3.mcr");

Specify the name of the macro file to be created. If no call to gpSetMacroFile is made,then gpPlot generates a temporary file, placing it in the GAUSS temporary filedirectory, which is set in gauss.cfg. You are responsible for deleting temporary filescreated in this manner. You may call gpCleanUp after your graph has been created todelete these files.

49

Page 58: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

4. POLAR LINE PLOTS

string linemaps = { "V1" "V3", "V2" "V3", "V2" "V4", "V5" "V4" };

ret = gpSetLineMaps(&gp,1,linemaps);

Specify the line maps for the first frame. A line map for a Polar Line plot is a set ofdata points described by (theta, r), where theta is the variable associated with theTheta-axis for that line map, and r is the variable associated with the R-axis. Each linemap is distinct and may be controlled separately.

By default, a Polar Line frames have one line map, in which the first variable in thedata file is associated with the Theta-axis and the second variable with the R-axis.Calling gpSetLineMaps overrides the default and specifies all of the line maps for aframe.

Each row in linemaps specifies a different line map, making four line maps in the frame.The variables in the first column are associated with the Theta-axis, and the variablesin the second column with the R-axis. See Table 4.1 for a complete list of the variablesused for each of the line maps and which axis each variable is associated with. Forexample, as you can see in the table, the second variable in the data file, ‘V2’ is used asthe Theta-axis variable for the second and third line maps.

ret = gpSetLineThickness(&gp,1,1|2|3|4,0.3);

Set the thickness of the lines in every line map to 0.3% of the frame height.

ret = gpShowSymbolLayer(&gp,1,1);

Activate the symbol layer in the frame, so symbols will be shown at the data points.

By default, only the line layer is activated in Polar Line plots.

ret = gpSetSymbolSize(&gp,1,1|2|3|4,1);

Set the size of the symbols for all four line maps to 1% of the frame height.

ret = gpSetSymbolFillMode(&gp,1,1|2|3|4,2,"");

Fill the symbols in the all four line maps with the same color as the symbol lines.

ret = gpSetSymbolShape(&gp,1,2,"circle");

Use ‘◦’ symbols in the second line map.

50

Page 59: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Polar Line Plots

4. POLAR LINE PLOTS

ret = gpSetSymbolSkip(&gp,1,seqa(1,1,4),5,2);

Show symbols at only one in every five data points for all line maps.

ret = gpSetSymbolShape(&gp,1,3,"rtri");

Use ‘⊲’ symbols in the third line map.

ret = gpSetSymbolShape(&gp,1,4,"diamond");

Use ‘⋄’ symbols in the fourth line map.

string names = {

"(<greek>q</greek><sub>1</sub>,sin(0.5*<greek>q</greek><sub>1</sub>))",

"(<greek>q</greek><sub>2</sub>,sin(0.5*<greek>q</greek><sub>1</sub>))",

"(<greek>q</greek><sub>2</sub>,abs(sin(<greek>q</greek><sub>1</sub>)))",

"(abs(cos(<greek>q</greek><sub>1</sub>)),

abs(sin(<greek>q</greek><sub>1</sub>)))" };

ret = gpSetLineMapNames(&gp,1,names);

Set the names of the line maps to descriptions of both the independent and dependentvariables used in each line map. These names are used in the line legend that is addedbelow.

The string array names includes some formatting substrings. The following string:

‘<fontname> . . . </fontname>’

writes the enclosed text in the font denoted by fontname. This allows you to use onefont inside another (e.g. to use Greek characters inside a normal text string, as above).

This string:

‘<sub> . . . </sub>’

subscripts the enclosed text.

See gpAddTextObject in the Command Reference section of the GAUSSplot

Professional Graphics manual for more information on formatting text.

ret = gpAddLineLegend(&gp,1);

Add a legend identifying each line map in the frame.

51

Page 60: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

4. POLAR LINE PLOTS

ret = gpMoveLineLegend(&gp,1,100,16);

Move the line legend to the bottom right-hand corner of the frame.

ret = gpSetLineLegendMargin(&gp,1,5);

Sets the margin between the line legend text and the outline of the legend box to 5% ofthe legend width.

ret = gpSetLineLegendBoxType(&gp,1,1);

Do not draw the outline of the legend box.

ret = gpSetLineLegendFont(&gp,1,"times",14,2);

Use a 14pt ‘times’ font for the line legend text.

ret = gpSetMagnification(&gp,1,0.7);

Set the plot magnification factor to 0.7. A magnification factor of 1 makes the plot aslarge as possible while still fitting all of the data points in the frame.

ret = gpSetTranslation(&gp,1,-9,3.5);

Translate the plot 9% of the frame width to the left and 3.5% of the frame height up.

ret = gpSetThetaMode(&gp,1,2);

Use radians for the Theta-axis.

ret = gpSetPolarAxesTitles(&gp,1,"Theta","R");

Specify titles for both axes.

4.2.5 Plotting the Graph

ret = gpPlot(&gp);

Plot the graph using the information contained in gp.

52

Page 61: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Cartesian Plots

5. 2D AND 3D CARTESIAN PLOTS

Chapter 5

2D and 3D Cartesian Plots

5.1 cartesianplot1.e

See Figure 5.1 for the graph produced by this example.

5.1.1 The Code

// Set up library and include file with structure definitions

library gaussplot;

#include gp.sdf

// Create gpPlotControl structure and set members to default values

struct gpPlotControl gp;

gp = gp3DCartesianPlotCreate;

// Generate data

xl = 51;

yl = 51;

pix = pi/(xl-1);

piy = pi/(yl-1);

x = seqa(-88,2.5,xl)’*pix;

y = seqa(-88,2.5,yl)*piy;

z = sin(x).*cos(x-y);

x = x.*ones(51,51);

y = y.*ones(51,51);

// List variable names

53

Page 62: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

5. 2D AND 3D CARTESIAN PLOTS

X

-4

-2

0

2

Y

-4

-2

0

2

X Y

Z3D Cartesian Plot

Frame 001 26 Jan 2005 cartesianplot1.plt

Figure 5.1: cartesianplot1.e

string vnames = { "X", "Y", "Z" };

// Specify names for macro file to be created and data file to be opened

gpSetMacroFile(&gp,"cartesianplot1.mcr");

ret = gpSetDataFile(&gp,0,"cartesianplot1.plt");

// Add title for frame

ret = gpAddTextObject(&gp,1,"",43,93,1,"3D Cartesian Plot");

// Create cartesian plot

ret = gpMake3DCartesianPlot(&gp,x,y,z,vnames);

5.1.2 Setup and Initialization

library gaussplot;

Activate the library containing all of the GAUSSplot commands.

#include gp.sdf

54

Page 63: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Cartesian Plots

5. 2D AND 3D CARTESIAN PLOTS

Include the file containing definitions of all GAUSSplot structures.

struct gpPlotControl gp;

Create an instance of a plot control structure.

gp = gp3DCartesianPlotCreate;

Initialize the members of gp to default values for a 3D Cartesian plot.

5.1.3 Creating Data

xl = 51;

yl = 51;

pix = pi/(xl-1);

piy = pi/(yl-1);

x = seqa(-88,2.5,xl)’*pix;

y = seqa(-88,2.5,yl)*piy;

z = sin(x).*cos(x-y);

x = x.*ones(51,51);

y = y.*ones(51,51);

Generate variables to be associated with the X, Y and Z axes in the graph. All threevariables, x, y and z, are 51 × 51 matrices. When graphed together, they create a locusof points in 3D space described by (x, y, z). This set of data points is called a field zone.

string vnames = { "X", "Y", "Z" };

Specify names for all of the variables.

5.1.4 Setting Options

gpSetMacroFile(&gp,"cartesianplot1.mcr");

Specify the name of the macro file to be created. If no call to gpSetMacroFile is made,then gpMake3DCartesianPlot generates a temporary file, placing it in the GAUSS

temporary file directory, which is set in gauss.cfg. You are responsible for deletingtemporary files created in this manner. You may call gpCleanUp after your graph hasbeen created to delete these files.

55

Page 64: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

5. 2D AND 3D CARTESIAN PLOTS

ret = gpSetDataFile(&gp,0,"cartesianplot1.plt");

Specify the name of the data file to be created. If no call to gpSetDataFile is made,then gpMake3DCartesianPlot generates a temporary file. You must either delete thistemporary data file manually or call gpCleanUp after running your program to delete it.

ret = gpAddTextObject(&gp,1,"",43,93,1,"3D Cartesian Plot");

Add a text object at the top of the frame as a title.

5.1.5 Plotting the Graph

ret = gpMake3DCartesianPlot(&gp,x,y,z,vnames);

Write the data file and plot the graph, using x as the X-axis variable, y as the Y-axisvariable and z as the Z-axis variable.

5.2 cartesianplot2.e

See Figure 5.2 for the graph produced by this example.

5.2.1 The Code

// Set up library and include file with structure definitions

library gaussplot;

#include gp.sdf

// Create gpPlotControl structure and set members to default values

struct gpPlotControl gp;

gp = gp3DCartesianPlotCreate;

// Create gpData structure

struct gpData gdat;

// Generate data

xl = 31;

yl = 31;

pix = pi/(xl-1);

piy = pi/(yl-1);

x = seqa(-88,2.5,xl)’*pix;

56

Page 65: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Cartesian Plots

5. 2D AND 3D CARTESIAN PLOTS

X

-8

-6

-4

-2

0

Y

-8

-6

-4

-2

0

Z

0

2

4

X Y

ZFrame 001 26 Jan 2005 cartesianplot2.plt

Figure 5.2: cartesianplot2.e

x2 = x[5:20]+4;

y = seqa(-88,2.5,yl)*piy;

y2 = y[5:20]+4;

// Z-axis variable

z = (cos(y)^2).*(sin(x-y)^2);

z2 = sin(x2).*cos(x2-y2)+4;

// X and Y-axis variables

x = x.*ones(31,31);

x2 = x2.*ones(16,16);

y = y.*ones(31,31);

y2 = y2.*ones(16,16);

// Put data for each zone into a different array

a = aconcat(x,y,3);

a = aconcat(a,z,3);

a2 = aconcat(x2,y2,3);

a2 = aconcat(a2,z2,3);

// List variable names

string vnames = { "X", "Y", "Z" };

57

Page 66: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

5. 2D AND 3D CARTESIAN PLOTS

// Set data in gpdata structure

gdat = gpInitPlotData(vnames);

ret = gpAddZone(&gdat,"Zone One",a);

ret = gpAddZone(&gdat,"Zone Two",a2);

// Write data file

ret = gpWritePlotData(&gdat,"cartesianplot2.plt");

// Specify names for macro file to be created and data file to use

gpSetMacroFile(&gp,"cartesianplot2.mcr");

ret = gpSetDataFile(&gp,0,"cartesianplot2.plt");

// Resize and move frame

ret = gpMoveFrame(&gp,1,0.25,0.25,10.5,8);

// Turn off mesh layer in field zone one

// And change mesh color in field zone two

ret = gpShowFieldZoneMeshLayer(&gp,1,1,0);

ret = gpSetMeshColor(&gp,1,2,"custom33");

// Show shade layer in field zone two and set shade color

ret = gpShowFieldZoneShadeLayer(&gp,1,1|2,0|1);

ret = gpSetShadeColor(&gp,1,2,"green");

// Use translucency and set value

ret = gpUseTranslucencyEffect(&gp,1,1);

ret = gpSetTranslucency(&gp,1,2,70);

// Set boundary color for both zones

ret = gpSetBoundaryColor(&gp,1,1,"custom46");

ret = gpSetBoundaryColor(&gp,1,2,"custom33");

// Show vector layer in field zone one

ret = gpShowFieldZoneVectorLayer(&gp,1,1|2,1|0);

ret = gpMakeVectorsTangent(&gp,1,1,1);

ret = gpSetVectorColor(&gp,1,1,"custom46");

ret = gpSetVectorType(&gp,1,1,3);

ret = gpSetVectorArrowHeadType(&gp,1,1,2);

// Animate rotation about the X, Y and Z axes

ret = gpAnimateXAxisRotation(&gp,1,120,3);

ret = gpAnimateYAxisRotation(&gp,1,120,3);

ret = gpAnimateZAxisRotation(&gp,1,120,3);

// Change plot fit type

58

Page 67: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Cartesian Plots

5. 2D AND 3D CARTESIAN PLOTS

ret = gpSetPlotFit(&gp,1,2);

// Make axes independent of one another

ret = gpMakeAxesIndependent(&gp,1);

// Create plot

ret = gpPlot(&gp);

5.2.2 Setup and Initialization

library gaussplot;

Activate the library containing all of the GAUSSplot commands.

#include gp.sdf

Include the file containing definitions of all GAUSSplot structures.

struct gpPlotControl gp;

Create an instance of a plot control structure.

gp = gp3DCartesianPlotCreate;

Initialize the members of gp to default values for a 3D Cartesian plot.

5.2.3 Creating Data and Writing the Data File

struct gpData gdat;

Create an instance of a data structure.

xl = 31;

yl = 31;

pix = pi/(xl-1);

piy = pi/(yl-1);

x = seqa(-88,2.5,xl)’*pix;

59

Page 68: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

5. 2D AND 3D CARTESIAN PLOTS

x2 = x[5:20]+4;

y = seqa(-88,2.5,yl)*piy;

y2 = y[5:20]+4;

z = (cos(y)^2).*(sin(x-y)^2);

z2 = sin(x2).*cos(x2-y2)+4;

x = x.*ones(31,31);

x2 = x2.*ones(16,16);

y = y.*ones(31,31);

y2 = y2.*ones(16,16);

Generate variables to be associated with the X, Y and Z axes in the graph. Thisexample creates a data file with two zones (i.e., two sets of variables), so here wegenerate x, y and z as well as x2, y2, and z2. The first set of variables, x, y and z, are all31 × 31 matrices. When graphed together, they create a locus of 961 (i.e., 31 ∗ 31)points in 3D space described by (x, y, z). This is the first field zone in the graph. Thesecond field zone is created by the second set of variables, x2, y2 and z2, which are all16 × 16 matrices. When graphed together, they create a set of 256 data pointsdescribed by (x2, y2, z2).

a = aconcat(x,y,3);

a = aconcat(a,z,3);

Concatenate x, y and z in the third dimension, in that order, to create a 3 × 31 × 31array, which is laid out as follows:

a[1,.,.] = xa[2,.,.] = ya[3,.,.] = z

It is necessary to concatenate x, y and z into a 3-dimensional array before putting thedata in the gpData structure with a call to gpAddZone because gpAddZone inputs allof the data for one zone as one argument. This gives you the flexibility to create a datafile according to your specifications.

Multiple zone data files must have the same number of variables (with the same variablenames) in each zone. However, the number of variables in a zone may vary betweendata files. Since gpAddZone inputs all of the variables for a zone as a single argument,you may specify the number of variables in the zone by the size of the data argument.

See Table 5.1 for a description of the assumptions that gpAddZone makes about thedata, depending on the type of data argument it receives.

a2 = aconcat(x2,y2,3);

a2 = aconcat(a2,z2,3);

60

Page 69: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Cartesian Plots

5. 2D AND 3D CARTESIAN PLOTS

Data Argument AssumptionN × K matrix Contains K variables that are N × 1K × N × 1 array Contains K variables that are N × 1K × N × P array Contains K variables that are N × P

K × L × N × P array Contains K variables that are L × N × P

Table 5.1: Assumptions made by gpAddZone

Concatenate x2, y2 and z2 in the third dimension, in that order, to create a 3 × 16 × 16array, which is laid out as follows:

a2[1,.,.] = x2a2[2,.,.] = y2a2[3,.,.] = z2

string vnames = { "X", "Y", "Z" };

Specify names for the variables.

gdat = gpInitPlotData(vnames);

Initialize the gpData structure and write the variable names to it. The number ofvariables that you input in succeeding calls to gpAddZone must match the number ofnames in vnames.

ret = gpAddZone(&gdat,"Zone One",a);

Add the data for zone one to the data structure.

ret = gpAddZone(&gdat,"Zone Two",a2);

Add the data for zone two to the data structure.

ret = gpWritePlotData(&gdat,"cartesianplot2.plt");

Write the variable names and data in gdat to the file cartesianplot2.plt. See Table5.2 for a description of how the variables are laid out. The ‘Index’ column refers to theindex of the variable in the data file. Each variable name has an associated index in thedata file, so the index does not change from zone to zone. You may use either the nameor index of a variable to specify it in GAUSSplot commands.

61

Page 70: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

5. 2D AND 3D CARTESIAN PLOTS

GAUSSplot Index GAUSS Field ZoneVariable Name Variable Name

Zone 1X 1 x 1Y 2 y 1Z 3 z 1

Zone 2X 1 x2 2Y 2 y2 2Z 3 z2 2

Table 5.2: Layout of variables in cartesianplot2.e

5.2.4 Setting Options

gpSetMacroFile(&gp,"cartesianplot2.mcr");

Specify the name of the macro file to be created. If no call to gpSetMacroFile is made,then gpPlot generates a temporary file, placing it in the GAUSS temporary filedirectory, which is set in gauss.cfg. You are responsible for deleting temporary filescreated in this manner. You may call gpCleanUp after your graph has been created todelete these files.

ret = gpSetDataFile(&gp,0,"cartesianplot2.plt");

Specify the name of the data file to be used. It is necessary to call gpSetDataFile beforethe plotting the graph with gpPlot. gpPlot will error out if no data file is specified.

Since cartesianplot2.plt has two zones, the resulting graph will have two field zones.

ret = gpMoveFrame(&gp,1,0.25,0.25,10.5,8);

Resize the frame to fill the workspace.

ret = gpShowFieldZoneMeshLayer(&gp,1,1,0);

Deactivate the mesh layer in the first field zone. Layers are controlled on two levels: inthe frame and in each field zone. When a layer is activated in a frame, then it isactivated in each of the field zones in the frame by default.

In 2D and 3D Cartesian plots, the mesh and boundary layers are activated by default.

62

Page 71: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Cartesian Plots

5. 2D AND 3D CARTESIAN PLOTS

ret = gpSetMeshColor(&gp,1,2,"custom33");

Set the color of the mesh in the second field zone to ‘custom33’.

ret = gpShowFieldZoneShadeLayer(&gp,1,1|2,0|1);

Activate the shade layer for the second field zone in the frame.

ret = gpSetShadeColor(&gp,1,2,"green");

Set the color of the shading in the second field zone to green.

ret = gpUseTranslucencyEffect(&gp,1,1);

Activate the translucency effect in the frame. This causes any shading and/or contourflooding to become translucent.

Translucency is not used in the graph in Figure 5.2 because of file size considerations.

ret = gpSetTranslucency(&gp,1,2,70);

Set the percentage of translucency for the second field zone to 70%.

ret = gpSetBoundaryColor(&gp,1,1,"custom46");

Set the color of the boundary line around the first field zone to ‘custom46’.

ret = gpSetBoundaryColor(&gp,1,2,"custom33");

Set the color of the boundary line around the second field zone to ‘custom33’.

ret = gpShowFieldZoneVectorLayer(&gp,1,1|2,1|0);

Activate the vector layer for the first field zone.

ret = gpMakeVectorsTangent(&gp,1,1,1);

63

Page 72: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

5. 2D AND 3D CARTESIAN PLOTS

Project the vectors in the first field zone onto the 3D field zone surface, making thevectors tangent to that surface.

ret = gpSetVectorColor(&gp,1,1,"custom46");

Set the color of the vectors in the first field zone to ‘custom46’.

ret = gpSetVectorType(&gp,1,1,3);

Set midpoint of each vector at data point.

ret = gpSetVectorArrowHeadType(&gp,1,1,2);

Use filled arrow heads for vectors.

ret = gpAnimateXAxisRotation(&gp,1,120,3);

Create an animation loop with 120 iterations, in which the plot is rotated 3 degreesaround the X-axis in each iteration. The animation will be displayed immediately afterthe graph has been completed. If you put multiple animation commands in yourprogram (see below), they will run in the order in which they appear in your program.

ret = gpAnimateYAxisRotation(&gp,1,120,3);

Create an animation loop with 120 iterations, in which the plot is rotated 3 degreesaround the Y-axis in each iteration.

ret = gpAnimateZAxisRotation(&gp,1,120,3);

Create an animation loop with 120 iterations, in which the plot is rotated 3 degreesaround the Z-axis in each iteration.

ret = gpSetPlotFit(&gp,1,2);

Resize the plot to fit all data points, axes and text inside the frame.

ret = gpMakeAxesIndependent(&gp,1);

Allow the axes to be sized independently.

64

Page 73: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Cartesian Plots

5. 2D AND 3D CARTESIAN PLOTS

X

Y

20 40 60 800

50

100

150

200

2D Cartesian Plotwith Surface Inset

Frame 001 26 Jan 2005 cartesianplot3a.plt

X Y

Z

Figure 5.3: cartesianplot3.e

5.2.5 Plotting the Graph

ret = gpPlot(&gp);

Plot the graph using the information contained in gp.

5.3 cartesianplot3.e

See Figure 5.3 for the graph produced by this example.

5.3.1 The Code

// Set up library and include file with structure definitions

library gaussplot;

#include gp.sdf

// Create gpPlotControl structure and set members to default values

struct gpPlotControl gp;

65

Page 74: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

5. 2D AND 3D CARTESIAN PLOTS

gp = gpPlotCreate;

// Create gpData structure

struct gpData gdat;

// Generate data for 2D Cartesian frame

xl = 20;

x = seqa(1,5,xl);

y = seqa(10,5,xl);

y = y.*log(x’);

x = x’.*ones(xl,xl);

// Put data into an array

a = aconcat(x,y,3);

// List variable names

string vnames = { "X", "Y" };

// Set data in gpData structure

gdat = gpInitPlotData(vnames);

ret = gpAddZone(&gdat,"",a);

if (ret);

print gpGetErrorMessage(ret);

endif;

// Write data file

ret = gpWritePlotData(&gdat,"cartesianplot3a.plt");

if (ret);

print gpGetErrorMessage(ret);

endif;

// Generate data for 3D Cartesian frame

a = seqa(0,pi/12,25)’;

r = seqa(6,-0.25,25);

x = r.*cos(a);

y = r.*sin(a);

z = rev(1.5*r).*ones(25,25);

a = aconcat(x,y,3);

a = aconcat(a,z,3);

// List variable names

string vnames = { "X", "Y", "Z" };

// Set data in gpdata structure

gdat = gpInitPlotData(vnames);

66

Page 75: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Cartesian Plots

5. 2D AND 3D CARTESIAN PLOTS

ret = gpAddZone(&gdat,"Zone One",a);

if (ret);

print gpGetErrorMessage(ret);

endif;

// Write data file

ret = gpWritePlotData(&gdat,"cartesianplot3b.plt");

if (ret);

print gpGetErrorMessage(ret);

endif;

// Set error level to 2 - print error messages if errors are encountered

call gpSetErrorLevel(&gp,2);

// Add a 2-D cartesian frame and a 3-D cartesian frame

gpAdd2DCartesianFrame(&gp);

gpAdd3DCartesianFrame(&gp);

// Specify names for macro file to be created and data file to be opened

gpSetMacroFile(&gp,"cartesianplot3.mcr");

call gpSetDataFile(&gp,1,"cartesianplot3a.plt");

call gpSetDataFile(&gp,2,"cartesianplot3b.plt");

// Resize and move frames

call gpMoveFrame(&gp,1,0.25,0.25,10.5,8);

call gpMoveFrame(&gp,2,5.6,3.1,3.5,2.5);

// Set mesh and boundary color for frame two

call gpSetMeshColor(&gp,2,1,"blue");

call gpSetBoundaryColor(&gp,2,1,"blue");

// Show shade layer and set shade colors for frame two

call gpShowShadeLayer(&gp,2,1);

call gpSetShadeColor(&gp,2,1,"blue");

// Use translucency and set value for frame two

call gpUseTranslucencyEffect(&gp,2,1);

call gpSetTranslucency(&gp,2,1,70);

// Make X and Y axes independent of one another in both frames

call gpMakeAxesIndependent(&gp,1);

call gpMakeAxesIndependent(&gp,2);

// Do not show border or axes on frame 2

call gpSetFrameStyle(&gp,2,0,0,0);

call gpShowXAxis(&gp,2,0,0);

67

Page 76: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

5. 2D AND 3D CARTESIAN PLOTS

call gpShowYAxis(&gp,2,0,0);

call gpShowZAxis(&gp,2,0);

// Add title for frame 1

call gpAddTextObject(&gp,1,"",41,86,1,

"2D Cartesian Plot"$|"with Surface Inset");

// Create cartesian plot

call gpPlot(&gp);

5.3.2 Setup and Initialization

library gaussplot;

Activate the library containing all of the GAUSSplot commands.

#include gp.sdf

Include the file containing definitions of all GAUSSplot structures.

struct gpPlotControl gp;

Create an instance of a plot control structure.

gp = gpPlotCreate;

Initialize the members of gp to default values for a plot without an associated plot type.This command is used to initialize a plot control structure for a multiple frame graphcontaining plots of different types. Since there is no plot type associated with the plotcontrol structure, the graph contains no frames by default. Frames must be addedusing the various gpAddPlotTypeFrame commands.

5.3.3 Creating Data and Writing the Data File

struct gpData gdat;

Create an instance of a data structure.

68

Page 77: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Cartesian Plots

5. 2D AND 3D CARTESIAN PLOTS

xl = 20;

x = seqa(1,5,xl);

y = seqa(10,5,xl);

y = y.*log(x’);

x = x’.*ones(xl,xl);

Generate variables to be associated with the X and Y axes in a 2D Cartesian frame.Both x and y are 20 × 20 matrices, and graphed together, they specify a locus of 400points described by (x, y).

a = aconcat(x,y,3);

Concatenate x and y in the third dimension, in that order, to create a 2× 20× 20 array,which is laid out as follows:

a[1,.,.] = xa[2,.,.] = y

It is necessary to concatenate x and y into a 3-dimensional array before putting thedata in the gpData structure with a call to gpAddZone because gpAddZone inputs allof the data for one zone as one argument. This gives you the flexibility to create a datafile according to your specifications.

See Table 5.1 for a description of the assumptions that gpAddZone makes about thedata depending on the type of data argument it receives.

string vnames = { "X", "Y" };

Specify names for the variables.

gdat = gpInitPlotData(vnames);

Initialize the gpData structure and write the variable names to it. The number ofvariables that you input in succeeding calls to gpAddZone must match the number ofnames in vnames.

ret = gpAddZone(&gdat,"",a);

Add the data to the data structure.

if (ret);

print gpGetErrorMessage(ret);

endif;

69

Page 78: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

5. 2D AND 3D CARTESIAN PLOTS

Check the return from the call to gpAddZone and print the associated error message ifan error code is returned.

ret = gpWritePlotData(&gdat,"cartesianplot3a.plt");

Write the variable names and data in gdat to the file cartesianplot3a.plt.

if (ret);

print gpGetErrorMessage(ret);

endif;

Check the return from the call to gpWritePlotData and print the associated errormessage if an error code is returned.

a = seqa(0,pi/12,25)’;

r = seqa(6,-0.25,25);

x = r.*cos(a);

y = r.*sin(a);

z = rev(1.5*r).*ones(25,25);

Generate variables to be associated with the X, Y and Z axes in a 3D Cartesian frame.All three variables, x, y and z are 25 × 25 matrices, and graphed together, they specifya locus of 625 points described by (x, y, z).

a = aconcat(x,y,3);

a = aconcat(a,z,3);

Concatenate x, y and z in the third dimension, in that order, to create a 3 × 25 × 25array, which is laid out as follows:

a[1,.,.] = xa[2,.,.] = ya[3,.,.] = z

Since gpAddZone inputs all of the data for one zone as a single argument, you mustconcatenate x, y and z into a 3-dimensional array before calling gpAddZone to add thedata to the data structure.

string vnames = { "X", "Y", "Z" };

Specify names for the variables.

70

Page 79: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Cartesian Plots

5. 2D AND 3D CARTESIAN PLOTS

gdat = gpInitPlotData(vnames);

Reinitialize the gpData structure and write the variable names to it.

ret = gpAddZone(&gdat,"Zone One",a);

Add the data to the data structure.

if (ret);

print gpGetErrorMessage(ret);

endif;

Check the return from the call to gpAddZone and print the associated error message ifan error code is returned.

ret = gpWritePlotData(&gdat,"cartesianplot3b.plt");

Write the variable names and data in gdat to the file cartesianplot3b.plt.

if (ret);

print gpGetErrorMessage(ret);

endif;

Check the return from the call to gpWritePlotData and print the associated errormessage if an error code is returned.

5.3.4 Setting Options

call gpSetErrorLevel(&gp,2);

Set the error handling level to 2, which causes error messages to be printed if an erroris encountered. There is no need to check the returns from the commands that follow,since error messages will be printed if any of the commands fail.

gpAdd2DCartesianFrame(&gp);

Add a 2D Cartesian frame to the graph. This is the first frame in the graph.

71

Page 80: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

5. 2D AND 3D CARTESIAN PLOTS

gpAdd3DCartesianFrame(&gp);

Add a 3D Cartesian frame to the graph.

gpSetMacroFile(&gp,"cartesianplot3.mcr");

Specify the name of the macro file to be created. If no call to gpSetMacroFile is made,then gpPlot generates a temporary file, placing it in the GAUSS temporary filedirectory, which is set in gauss.cfg. You are responsible for deleting temporary filescreated in this manner. You may call gpCleanUp after your graph has been created todelete these files.

call gpSetDataFile(&gp,1,"cartesianplot3a.plt");

Specify the name of the data file to be used for the first frame. It is necessary to callgpSetDataFile before the plotting the graph with gpPlot. gpPlot will error out if nodata file(s) are specified.

call gpSetDataFile(&gp,2,"cartesianplot3b.plt");

Specify the name of the data file to be used for the second frame.

call gpMoveFrame(&gp,1,0.25,0.25,10.5,8);

Resize the first frame to fill the workspace.

call gpMoveFrame(&gp,2,5.6,3.1,3.5,2.5);

Resize and move the second frame to make it an inset in the first frame.

call gpSetMeshColor(&gp,2,1,"blue");

Set the color of mesh in the second frame to blue.

call gpSetBoundaryColor(&gp,2,1,"blue");

Set the color of the boundary around the field zone in the second frame to blue.

72

Page 81: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Cartesian Plots

5. 2D AND 3D CARTESIAN PLOTS

call gpShowShadeLayer(&gp,2,1);

Activate the shade layer in frame two. In 2D and 3D Cartesian plots, only the meshand boundary layers are activated by default.

The shade layer is not displayed in the graph in Figure 5.3 because of file sizeconsiderations.

call gpSetShadeColor(&gp,2,1,"blue");

Set the color of the shading in the second frame to blue.

call gpUseTranslucencyEffect(&gp,2,1);

Activate the translucency effect in frame two, causing the shading to appeartranslucent.

call gpSetTranslucency(&gp,2,1,70);

Set the percentage of surface translucency in the second frame to 70%.

call gpMakeAxesIndependent(&gp,1);

Allow the axes in the first frame to be sized independently.

call gpMakeAxesIndependent(&gp,2);

Allow the axes in the second frame to be sized independently.

call gpSetFrameStyle(&gp,2,0,0,0);

Do not show the frame header, border or background in the second frame.

call gpShowXAxis(&gp,2,0,0);

Do not display the X-axis in the second frame.

call gpShowYAxis(&gp,2,0,0);

73

Page 82: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

5. 2D AND 3D CARTESIAN PLOTS

Do not display the Y-axis in the second frame.

call gpShowZAxis(&gp,2,0);

Do not display the Z-axis in the second frame.

call gpAddTextObject(&gp,1,"",41,86,1,

"2D Cartesian Plot"$|"with Surface Inset");

Add a text object to the top of the first frame as a title.

5.3.5 Plotting the Graph

call gpPlot(&gp);

Plot the graph using the information contained in gp.

5.4 cartesianplot5.e

See Figure 5.4 for the graph produced by this example.

5.4.1 The Code

// Set up library and include file with structure definitions

library gaussplot;

#include gp.sdf

// Create gpPlotControl structure and set members to default values

struct gpPlotControl gp;

gp = gp3DCartesianPlotCreate;

// Create gpData structure

struct gpData gdat;

// Generate data

xl = 31;

yl = 31;

pix = pi/(xl-1);

piy = pi/(yl-1);

74

Page 83: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Cartesian Plots

5. 2D AND 3D CARTESIAN PLOTS

X

-8

-6

-4

-2

0

Y

-8

-6

-4

-2

0

Z1

-1

0

1

2

3

4

XY

Z

Frame 001 21 Feb 2005 cartesianplot5.plt

Z2

100

102

104

Figure 5.4: cartesianplot5.e

x = seqa(-88,2.5,xl)’*pix;

x2 = x[5:20]+4;

y = seqa(-88,2.5,yl)*piy;

y2 = y[5:20]+4;

// Z-axis variable

z = (cos(y)^2).*(sin(x-y)^2);

z2 = sin(x2).*cos(x2-y2)+4;

z2 = z2+100;

// X and Y-axis variables

x = x.*ones(31,31);

x2 = x2.*ones(16,16);

y = y.*ones(31,31);

y2 = y2.*ones(16,16);

// Put data for each zone into a different array

a = aconcat(x,y,3);

a = aconcat(a,z,3);

a2 = aconcat(x2,y2,3);

a2 = aconcat(a2,z2,3);

75

Page 84: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

5. 2D AND 3D CARTESIAN PLOTS

// List variable names

string vnames = { "X", "Y", "Z" };

// Set data in gpData structure

gdat = gpInitPlotData(vnames);

ret = gpAddZone(&gdat,"Zone One",a); // field zone one

ret = gpAddZone(&gdat,"Zone Two",a2); // field zone two

// Write data file

ret = gpWritePlotData(&gdat,"cartesianplot5.plt");

// Specify names for macro file to be created and data file to use

gpSetMacroFile(&gp,"cartesianplot5.mcr");

ret = gpSetDataFile(&gp,0,"cartesianplot5.plt");

// Add second frame

gpAdd3DCartesianFrame(&gp);

// Use the first field zone in the first frame

// And the second field zone in the second frame

ret = gpSetActiveFieldZones(&gp,1,1);

ret = gpSetActiveFieldZones(&gp,2,2);

// Set the range of the Z axes for both frames

ret = gpSetZAxisRange(&gp,1,minc(vecr(z))-1,maxc(vecr(z))+4);

ret = gpSetZAxisRange(&gp,2,minc(vecr(z2))-4,maxc(vecr(z2))+1);

// Rename the Z axes, so you can distinguish them from each other

ret = gpSetZAxisTitle(&gp,1,"Z1");

ret = gpSetZAxisTitle(&gp,2,"Z2");

// Do not show the X, Y or 3D Orientation axes in the second frame

// And do not show frame header, border or background in the second frame

ret = gpShowXAxis(&gp,2,1,0);

ret = gpShowYAxis(&gp,2,1,0);

ret = gpShow3DOrientationAxis(&gp,2,0);

ret = gpSetFrameStyle(&gp,2,0,0,0);

// Change plot fit type so that you can see the entire grid in the frame

ret = gpSetPlotFit(&gp,1,2);

ret = gpSetPlotFit(&gp,2,2);

// Make axes independent of one another

ret = gpMakeAxesIndependent(&gp,1);

ret = gpMakeAxesIndependent(&gp,2);

76

Page 85: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Cartesian Plots

5. 2D AND 3D CARTESIAN PLOTS

// Rotate plot about the X, Y and Z axes

ret = gpRotateAxes(&gp,1,-15,-15,20);

ret = gpRotateAxes(&gp,2,-15,-15,20);

// Add the macro file guiedits.mcr

gpAddMacroFile(&gp,sysstate(2,0)$+"gaussplot/examples/guiedits.mcr");

// Plot the graph

ret = gpPlot(&gp);

5.4.2 Setup and Initialization

library gaussplot;

Activate the library containing all of the GAUSSplot commands.

#include gp.sdf

Include the file containing definitions of all GAUSSplot structures.

struct gpPlotControl gp;

Create an instance of a plot control structure.

gp = gp3DCartesianPlotCreate;

Initialize the members of gp to default values for a 3D Cartesian plot.

5.4.3 Creating Data

struct gpData gdat;

Create an instance of a data structure.

xl = 31;

yl = 31;

pix = pi/(xl-1);

77

Page 86: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

5. 2D AND 3D CARTESIAN PLOTS

piy = pi/(yl-1);

x = seqa(-88,2.5,xl)’*pix;

x2 = x[5:20]+4;

y = seqa(-88,2.5,yl)*piy;

y2 = y[5:20]+4;

z = (cos(y)^2).*(sin(x-y)^2);

z2 = sin(x2).*cos(x2-y2)+4;

z2 = z2+100;

x = x.*ones(31,31);

x2 = x2.*ones(16,16);

y = y.*ones(31,31);

y2 = y2.*ones(16,16);

Generate variables to be associated with the X, Y and Z axes in the graph. Thisexample creates a data file with two zones (i.e., two sets of variables), so here wegenerate x, y and z as well as x2, y2, and z2. The first set of variables, x, y and z, are all31 × 31 matrices. When graphed together, they create a locus of 961 (i.e., 31 ∗ 31)points in 3D space described by (x, y, z). This is the first field zone in the graph. Thesecond field zone is created by the second set of variables, x2, y2 and z2, which are all16 × 16 matrices. When graphed together, they create a set of 256 data pointsdescribed by (x2, y2, z2).

a = aconcat(x,y,3);

a = aconcat(a,z,3);

Concatenate x, y and z in the third dimension, in that order, to create a 3 × 31 × 31array, which is laid out as follows:

a[1,.,.] = xa[2,.,.] = ya[3,.,.] = z

It is necessary to concatenate x, y and z into a 3-dimensional array before putting thedata in the gpData structure with a call to gpAddZone because gpAddZone inputs allof the data for one zone as one argument. This gives you the flexibility to create a datafile according to your specifications.

Multiple zone data files must have the same number of variables (with the same variablenames) in each zone. However, the number of variables in a zone may vary betweendata files. Since gpAddZone inputs all of the variables for a zone as a single argument,you may specify the number of variables in the zone by the size of the data argument.

See Table 5.1 for a description of the assumptions that gpAddZone makes about thedata, depending on the type of data argument it receives.

78

Page 87: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Cartesian Plots

5. 2D AND 3D CARTESIAN PLOTS

a2 = aconcat(x2,y2,3);

a2 = aconcat(a2,z2,3);

Concatenate x2, y2 and z2 in the third dimension, in that order, to create a 3 × 16 × 16array, which is laid out as follows:

a2[1,.,.] = x2a2[2,.,.] = y2a2[3,.,.] = z2

string vnames = { "X", "Y", "Z" };

Specify names for the variables.

gdat = gpInitPlotData(vnames);

Initialize the gpData structure and write the variable names to it. The number ofvariables that you input in succeeding calls to gpAddZone must match the number ofnames in vnames.

ret = gpAddZone(&gdat,"Zone One",a);

Add the data for zone one to the data structure.

ret = gpAddZone(&gdat,"Zone Two",a2);

Add the data for zone two to the data structure.

ret = gpWritePlotData(&gdat,"cartesianplot5.plt");

Write the variable names and data in gdat to the file cartesianplot5.plt. See Table5.3 for a description of how the variables are laid out. The ‘Index’ column refers to theindex of the variable in the data file. Each variable name has an associated index in thedata file, so the index does not change from zone to zone. You may use either the nameor index of a variable to specify it in GAUSSplot commands.

5.4.4 Setting Options

gpSetMacroFile(&gp,"cartesianplot5.mcr");

79

Page 88: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

5. 2D AND 3D CARTESIAN PLOTS

GAUSSplot Index GAUSS Field ZoneVariable Name Variable Name

Zone 1X 1 x 1Y 2 y 1Z 3 z 1

Zone 2X 1 x2 2Y 2 y2 2Z 3 z2 2

Table 5.3: Layout of variables in cartesianplot5.e

Specify the name of the macro file to be created. If no call to gpSetMacroFile is made,then gpPlot generates a temporary file, placing it in the GAUSS temporary filedirectory, which is set in gauss.cfg. You are responsible for deleting temporary filescreated in this manner. You may call gpCleanUp after your graph has been created todelete these files.

ret = gpSetDataFile(&gp,0,"cartesianplot5.plt");

Specify the name of the data file to be used. It is necessary to call gpSetDataFile beforethe plotting the graph with gpPlot. gpPlot will error out if no data file is specified.

gpAdd3DCartesianFrame(&gp);

Add the second frame, which will be stacked on top of the first frame.

ret = gpSetActiveFieldZones(&gp,1,1);

Show only the first field zone in the first frame.

ret = gpSetActiveFieldZones(&gp,2,2);

Show only the second field zone in the second frame.

ret = gpSetZAxisRange(&gp,1,minc(vecr(z))-1,maxc(vecr(z))+4);

Set the range of the Z-axis for the first frame. By default, the Z-axis range isdetermined by the minimum and maximum Z values in the data file (i.e., for all zones

80

Page 89: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Cartesian Plots

5. 2D AND 3D CARTESIAN PLOTS

in the data file). In this example, we want the Z-axis range for the first frame to bebased on the minimum and maximum Z values in the first zone of the data file.

The Z-axis minumum is set to z1min − 1 and the maximum to z1max + 4, wherez1min and z1max are the minimum and maximum values in the first zone of the datafile. This extends the range of the Z-axis a little beyond the extrema of the field zonedata so that the field zone does not touch the edge of the Z-axis and places the fieldzone in the lower half of the grid.

ret = gpSetZAxisRange(&gp,2,minc(vecr(z2))-4,maxc(vecr(z2))+1);

Set the range of the Z-axis for the second frame.

The Z-axis minumum is set to z2min − 4 and the maximum to z2max + 1, wherez2min and z2max are the minimum and maximum values in the second zone of thedata file. This places the field zone in the upper half of the grid, so the two field zoneswill not be stacked on top of each other in the grid. It also extends the range of theZ-axis beyond the extrema of the field zone data to ensure that the field zone does nottouch the edge of the Z-axis.

ret = gpSetZAxisTitle(&gp,1,"Z1");

Set the title of the Z-axis in the first frame.

ret = gpSetZAxisTitle(&gp,2,"Z2");

Set the title of the Z-axis in the second frame.

ret = gpShowXAxis(&gp,2,1,0);

Do not display the X-axis in the second frame.

ret = gpShowYAxis(&gp,2,1,0);

Do not display the X-axis in the second frame.

ret = gpShow3DOrientationAxis(&gp,2,0);

Do not display the 3D Orientation axis in the second frame.

81

Page 90: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

5. 2D AND 3D CARTESIAN PLOTS

ret = gpSetFrameStyle(&gp,2,0,0,0);

Do not show the frame header, border or background in the second frame. The secondframe is now essentially invisible. Only the second field zone and the Z-axis aredisplayed in the second frame.

ret = gpSetPlotFit(&gp,1,2);

Fit the entire grid, not just the data points, into the first frame.

ret = gpSetPlotFit(&gp,2,2);

Repeat the above plot fit command for the second frame; otherwise, the Z-axis in thesecond frame will not line up with the grid in the first frame.

ret = gpMakeAxesIndependent(&gp,1);

Make the axes in the first frame independent, so the X, Y and Z axes are scaledseparately.

ret = gpMakeAxesIndependent(&gp,2);

Make the axes in the second frame independent, allowing the axes to be scaledseparately. Since scaling is done automatically, the Z axes in the two frames will eachbe scaled to the same length by default if gpMakeAxesIndependent is called for bothframes.

If gpMakeAxesIndependent were not called for both frames, then the grids in the twoframes would be scaled differently. By default, the X, Y and Z axes in a 3D Cartesianplot are scaled so that one unit on the X-axis is the same length as one unit on theY-axis and one unit on the Z-axis. In this example, the X and Y axes in the two framesare identical (although they are not displayed in the second frame). Thus, since the twoZ axes do not contain the same number of units, the Z axes would be scaled to differentlengths if gpMakeAxesIndependent were not called.

ret = gpRotateAxes(&gp,1,-15,-15,20);

Rotate the plot in the first frame -15 degrees about the X-axis, -15 degrees about theY-axis and then 20 degrees about the Z-axis.

ret = gpRotateAxes(&gp,2,-15,-15,20);

82

Page 91: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Cartesian Plots

5. 2D AND 3D CARTESIAN PLOTS

Repeat the above rotation command for the second frame. If the frames are not rotatedtogether, then the Z-axis in the second frame will not line up with the grid in the firstframe.

gpAddMacroFile(&gp,sysstate(2,0)$+"gaussplot/examples/guiedits.mcr");

Add the macro file guiedits.mcr, which is located in the gaussplot/examples

subdirectory of the GAUSS installation directory, so it will be run when the graph iscreated. The file contains GUI edits that set the two Z axes to be displayed on oppositesides of the grid. To produce the macro file, run the initial program (without the call togpAddMacroFile), and then perform the following steps in the GAUSSplot GUI:

1. Select “Macro”→“Record” from the ‘File’ menu.

2. Type the desired file name (guiedits.mcr) and path into the “Selection”field of the ‘Write Macro File’ dialog box and then select “OK”.

3. Select “Axis” from the ‘Plot’ menu.

4. Click on the ‘Z’ tab at the top of the ‘Axis Details’ dialog box, and thenselect the ‘Line’ tab.

5. Deselect “Auto 3D Edge Assignment”, select “X-Max, Y-Min” and thenclick on the “Close” button.

6. Select “Push Current Frame Back” from the ‘Frame’ menu.

7. Again select “Axis” from the ‘Plot’ menu. This time the ‘Z’ and ‘Line’tabs should already be selected for you.

8. Deselect “Auto 3D Edge Assignment”, and then click on the “Close”button.

9. Select “Push Current Frame Back” from the ‘Frame’ menu.

10. Then click on the “Stop Recording” button on the ‘Macro Record’ dialogbox and click “OK” when you are asked if you are sure that you want tostop recording.

5.4.5 Plotting the Graph

ret = gpPlot(&gp);

Plot the graph using the information contained in gp.

83

Page 92: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

5. 2D AND 3D CARTESIAN PLOTS

XAxis

-1.5

-1

-0.5

0

0.5

1

1.5

Y Axis

-1.5-1

-0.50

0.51

1.5

ZA

xis

0

0.2

0.4

0.6

0.8

XY

ZXYZ - 3D Curves

Frame 001 8 Mar 2005 cartesianplot6.plt

Conical Sin WaveSpherical Sin Wave

Figure 5.5: cartesianplot6.e

5.5 cartesianplot6.e

See Figure 5.5 for the graph produced by this example.

5.5.1 The Code

// Set up library and include file with structure definitions

library gaussplot;

#include gp.sdf

// Create gpPlotControl structure and set members to default values

struct gpPlotControl gp;

gp = gp3DCartesianPlotCreate;

// Create gpData structure

struct gpData gdat;

// Generate data

t = seqa(0,.0157,400);

a=10; b=1; c=.3;

x = 1.5*(b*(1-c^2*cos(a*t)^2)^.5 .* cos(t));

84

Page 93: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Cartesian Plots

5. 2D AND 3D CARTESIAN PLOTS

y = 1.5*(b*(1-c^2*cos(a*t)^2)^.5 .* sin(t));

z = c*cos(a*t) + .5;

a=10; c=.5;

x2 = c*(1+cos(a*t)) .* cos(t) * 1.2;

y2 = c*(1+cos(a*t)) .* sin(t) * 1.2;

z2 = c*(1+cos(a*t)) * .5;

// Put data for each zone into a different array

a = aconcat(x,y,3);

a = aconcat(a,z,3);

a2 = aconcat(x2,y2,3);

a2 = aconcat(a2,z2,3);

// List variable names

string vnames = { "X", "Y", "Z" };

// Set data in gpData structure

gdat = gpInitPlotData(vnames);

ret = gpAddZone(&gdat,"Spherical Sin Wave",a); // field zone one

ret = gpAddZone(&gdat,"Conical Sin Wave",a2); // field zone two

// Write data file

ret = gpWritePlotData(&gdat,"cartesianplot6.plt");

// Specify names for macro file to be created and data file to use

gpSetMacroFile(&gp,"cartesianplot6.mcr");

ret = gpSetDataFile(&gp,0,"cartesianplot6.plt");

// Add title

ret = gpAddTextObject(&gp,1,"title",50,91,1,"XYZ - 3D Curves");

ret = gpSetTextObjectAnchorLocation(&gp,1,"title",2,1);

// Set axes titles

ret = gpSetXAxisTitle(&gp,1,1,"X Axis");

ret = gpSetYAxisTitle(&gp,1,1,"Y Axis");

ret = gpSetZAxisTitle(&gp,1,"Z Axis");

// Set the offset of the Z-axis title from the axis line

ret = gpSetZAxisTitleOffset(&gp,1,12);

// Set XZ dependence ratio

ret = gpMakeAxesXYZDependent(&gp,1,1,0.4);

// Change plot fit type so that you can see the entire grid in the frame

ret = gpSetPlotFit(&gp,1,2);

85

Page 94: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

5. 2D AND 3D CARTESIAN PLOTS

// Do not display gridlines or fill grid area

ret = gpShowXAxisGridLines(&gp,1,1,0);

ret = gpShowYAxisGridLines(&gp,1,1,0);

ret = gpShowZAxisGridLines(&gp,1,0);

ret = gpFillGridArea(&gp,1,0);

// Rotate plot about Y and Z axes

ret = gpRotateZAxis(&gp,1,15);

ret = gpRotateYAxis(&gp,1,5);

// Add field zone legend

ret = gpAddFieldZoneLegendFrame(&gp,1);

ret = gpMoveFieldZoneLegend(&gp,1,99,9);

ret = gpSetFieldZoneLegendFont(&gp,1,"helv",14,2);

ret = gpSetFieldZoneLegendLineSpacing(&gp,1,1.25);

// Plot the graph

ret = gpPlot(&gp);

5.5.2 Setup and Initialization

library gaussplot;

Activate the library containing all of the GAUSSplot commands.

#include gp.sdf

Include the file containing definitions of all GAUSSplot structures.

struct gpPlotControl gp;

Create an instance of a plot control structure.

gp = gp3DCartesianPlotCreate;

Initialize the members of gp to default values for a 3D Cartesian plot.

86

Page 95: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Cartesian Plots

5. 2D AND 3D CARTESIAN PLOTS

5.5.3 Creating Data

struct gpData gdat;

Create an instance of a data structure.

t = seqa(0,.0157,400);

a=10; b=1; c=.3;

x = 1.5*(b*(1-c^2*cos(a*t)^2)^.5 .* cos(t));

y = 1.5*(b*(1-c^2*cos(a*t)^2)^.5 .* sin(t));

z = c*cos(a*t) + .5;

a=10; c=.5;

x2 = c*(1+cos(a*t)) .* cos(t) * 1.2;

y2 = c*(1+cos(a*t)) .* sin(t) * 1.2;

z2 = c*(1+cos(a*t)) * .5;

Generate variables to be associated with the X, Y and Z axes in the graph. Thisexample creates a data file with two zones (i.e., two sets of variables), so here wegenerate x, y and z as well as x2, y2, and z2. All of the variables are 400 × 1 vectors.When graphed together, each set of variables (e.g., x, y and z) creates a locus of 400points in 3D space. The first field zone in the graph is the locus of points described by(x, y, z). The second field zone is the locus of points described by (x2, y2, z2). Since thevariables for both field zones are vectors, the field zones will appear in the graph as 3Dcurves.

a = aconcat(x,y,3);

a = aconcat(a,z,3);

Concatenate x, y and z in the third dimension, in that order, to create a 3 × 400 × 1array, which is laid out as follows:

a[1,.,.] = xa[2,.,.] = ya[3,.,.] = z

It is necessary to concatenate x, y and z into a 3-dimensional array before putting thedata in the gpData structure with a call to gpAddZone because gpAddZone inputs allof the data for one zone as one argument. This gives you the flexibility to create a datafile according to your specifications.

Multiple zone data files must have the same number of variables (with the same variablenames) in each zone. However, the number of variables in a zone may vary between

87

Page 96: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

5. 2D AND 3D CARTESIAN PLOTS

data files. Since gpAddZone inputs all of the variables for a zone as a single argument,you may specify the number of variables in the zone by the size of the data argument.

See Table 5.1 for a description of the assumptions that gpAddZone makes about thedata, depending on the type of data argument it receives.

a2 = aconcat(x2,y2,3);

a2 = aconcat(a2,z2,3);

Concatenate x2, y2 and z2 in the third dimension, in that order, to create a 3 × 400 × 1array, which is laid out as follows:

a2[1,.,.] = x2a2[2,.,.] = y2a2[3,.,.] = z2

string vnames = { "X", "Y", "Z" };

Specify names for the variables.

gdat = gpInitPlotData(vnames);

Initialize the gpData structure and write the variable names to it. The number ofvariables that you input in succeeding calls to gpAddZone must match the number ofnames in vnames.

ret = gpAddZone(&gdat,"Spherical Sin Wave",a);

Add the data for zone one to the data structure.

ret = gpAddZone(&gdat,"Conical Sin Wave",a2);

Add the data for zone two to the data structure.

ret = gpWritePlotData(&gdat,"cartesianplot6.plt");

Write the variable names and data in gdat to the file cartesianplot6.plt. See Table5.4 for a description of how the variables are laid out. The ‘Index’ column refers to theindex of the variable in the data file. Each variable name has an associated index in thedata file, so the index does not change from zone to zone. You may use either the nameor index of a variable to specify it in GAUSSplot commands.

88

Page 97: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Cartesian Plots

5. 2D AND 3D CARTESIAN PLOTS

GAUSSplot Index GAUSS Field ZoneVariable Name Variable Name

Zone 1X 1 x 1Y 2 y 1Z 3 z 1

Zone 2X 1 x2 2Y 2 y2 2Z 3 z2 2

Table 5.4: Layout of variables in cartesianplot6.e

5.5.4 Setting Options

gpSetMacroFile(&gp,"cartesianplot6.mcr");

Specify the name of the macro file to be created. If no call to gpSetMacroFile is made,then gpPlot generates a temporary file, placing it in the GAUSS temporary filedirectory, which is set in gauss.cfg. You are responsible for deleting temporary filescreated in this manner. You may call gpCleanUp after your graph has been created todelete these files.

ret = gpSetDataFile(&gp,0,"cartesianplot6.plt");

Specify the name of the data file to be used. It is necessary to call gpSetDataFile beforethe plotting the graph with gpPlot. gpPlot will error out if no data file is specified.

ret = gpAddTextObject(&gp,1,"title",50,91,1,"XYZ - 3D Curves");

Add text for a title, placing it near the top of the frame and centering it horizontally.

ret = gpSetTextObjectAnchorLocation(&gp,1,"title",2,1);

Set the text object anchor location to the midpoint of the bottom line of the textobject box. By default, the anchor location of a text box is the bottom right-handcorner. This command causes the text object to be horizontally centered on thelocation specified with gpAddTextObject.

ret = gpSetXAxisTitle(&gp,1,1,"X Axis");

89

Page 98: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

5. 2D AND 3D CARTESIAN PLOTS

Specify a title for the X-axis.

ret = gpSetYAxisTitle(&gp,1,1,"Y Axis");

Specify a title for the Y-axis.

ret = gpSetZAxisTitle(&gp,1,"Z Axis");

Specify a title for the Z-axis.

ret = gpSetZAxisTitleOffset(&gp,1,12);

Set the offset of the Z-axis title from the axis line.

ret = gpMakeAxesXYZDependent(&gp,1,1,0.4);

Set 1 unit on the Y-axis and 0.4 units on the Z-axis equal in length to 1 unit on theX-axis.

ret = gpSetPlotFit(&gp,1,2);

Resize the plot to fit all data points, axes and text inside the frame.

ret = gpShowXAxisGridLines(&gp,1,1,0);

Do not display X-axis major gridlines.

ret = gpShowYAxisGridLines(&gp,1,1,0);

Do not display Y-axis major gridlines.

ret = gpShowZAxisGridLines(&gp,1,0);

Do not display Z-axis major gridlines.

ret = gpFillGridArea(&gp,1,0);

90

Page 99: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Cartesian Plots

5. 2D AND 3D CARTESIAN PLOTS

Do not fill grid area.

ret = gpRotateZAxis(&gp,1,15);

Rotate the plot 15 degrees about the Z-axis.

ret = gpRotateYAxis(&gp,1,5);

Rotate the plot 5 degrees about the Y-axis.

ret = gpAddFieldZoneLegendFrame(&gp,1);

Add a field zone legend frame. The frame is positioned as an inset into the first frame,which is the parent frame.

ret = gpMoveFieldZoneLegend(&gp,1,99,9);

Move the field zone legend frame so that its upper right-hand corner is located in theparent frame at the position (99, 9) in parent frame units.

ret = gpSetFieldZoneLegendFont(&gp,1,"helv",14,2);

Use a 14 point helvetica font for the text in the field zone legend.

ret = gpSetFieldZoneLegendLineSpacing(&gp,1,1.25);

Set line spacing in the field zone legend to 1.25.

5.5.5 Plotting the Graph

ret = gpPlot(&gp);

Plot the graph using the information contained in gp.

5.6 volumeplot1.e

See Figure 5.6 for the graph produced by this example.

91

Page 100: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

5. 2D AND 3D CARTESIAN PLOTS

V1

-2

-1

0

1

V2

-2

-1

0

1

V3

1

2

3

4

5

6

X Y

ZFrame 001 26 Jan 2005 volumeplot1.plt

Figure 5.6: volumeplot1.e

5.6.1 The Code

// Set up library and include file with structure definitions

library gaussplot;

#include gp.sdf

// Create gpPlotControl structure and set members to default values

struct gpPlotControl gp;

gp = gp3DCartesianPlotCreate;

// Generate data

a = seqa(0,pi/10,21)’;

r = seqa(.25,0.75,4);

x = r.*cos(a);

x = areshape(x,5|4|21);

y = r.*sin(a);

y = areshape(y,5|4|21);

r = r|(r[rows(r)]+0.75);

z = areshape(2*r[1].*ones(4,21),4|21);

for i(2,5,1);

z = aconcat(z,2*r[i].*ones(4,21),3);

92

Page 101: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Cartesian Plots

5. 2D AND 3D CARTESIAN PLOTS

endfor;

// Show only shade layer and use translucency

ret = gpShowMeshLayer(&gp,1,0);

ret = gpShowBoundaryLayer(&gp,1,0);

ret = gpShowShadeLayer(&gp,1,1);

ret = gpSetShadeColor(&gp,1,1,"blue");

ret = gpUseTranslucencyEffect(&gp,1,1);

ret = gpSetTranslucency(&gp,1,1,30);

// Specify names for macro file to be created and data file to use

gpSetMacroFile(&gp,"volumeplot1.mcr");

ret = gpSetDataFile(&gp,0,"volumeplot1.plt");

// Plot the graph

ret = gpMake3DCartesianPlot(&gp,x,y,z,"");

5.6.2 Setup and Initialization

library gaussplot;

Activate the library containing all of the GAUSSplot commands.

#include gp.sdf

Include the file containing definitions of all GAUSSplot structures.

struct gpPlotControl gp;

Create an instance of a plot control structure.

gp = gp3DCartesianPlotCreate;

Initialize the members of gp to default values for a 3D Cartesian plot.

5.6.3 Creating Data

a = seqa(0,pi/10,21)’;

93

Page 102: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

5. 2D AND 3D CARTESIAN PLOTS

r = seqa(.25,0.75,4);

x = r.*cos(a);

x = areshape(x,5|4|21);

y = r.*sin(a);

y = areshape(y,5|4|21);

r = r|(r[rows(r)]+0.75);

z = areshape(2*r[1].*ones(4,21),4|21);

for i(2,5,1);

z = aconcat(z,2*r[i].*ones(4,21),3);

endfor;

Generate variables to be associated with the X, Y and Z axes in the graph. All threevariables, x, y and z, are 5 × 4 × 21 arrays. Both x and y are created by first generatinga 4× 21 plane (matrix), and then expanding it to 5 identical planes concatenated in thethird dimension. For example, x is first set to r. ∗ cos(a) (which is a 4 × 21 matrix) andthen expanded to a 5 × 4 × 21 array such that

r. ∗ cos(a) = x[1, ., .] = x[2, ., .] = x[3, ., .] = . . . = x[5, ., .]

The variable z is created by generating each of the 5 4 × 21 planes separately andconcatenating them in the third dimension to make a 5 × 4 × 21 array.

When graphed together, x, y and z create a locus of 504 (5 ∗ 4 ∗ 21) points in 3D spacedescribed by (x, y, z). This set of data points appears as a cylindrical solid. SeeFigure 5.7 for an illustration of how the data points are laid out in the graph. In thefigure, the data points are displayed in red, and blue mesh lines connect each datapoint to its neighboring points. Note: to create the plot in this figure, it is necessary tocall gpSetSurfacesToPlot to specify that all surfaces in the volume should be displayed,not only those along the boundary of the data zone.

5.6.4 Setting Options

ret = gpShowMeshLayer(&gp,1,0);

Deactivate the mesh layer in the frame. In 3D Cartesian plots, the mesh and boundarylayers are activated by default.

ret = gpShowBoundaryLayer(&gp,1,0);

Deactivate the boundary layer in the frame.

ret = gpShowShadeLayer(&gp,1,1);

94

Page 103: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Cartesian Plots

5. 2D AND 3D CARTESIAN PLOTS

V1

-2-1

01

2

V2

-2-1

01

2

V3

1

2

3

4

5

6

X Y

Z

Frame 001 26 Jan 2005 volumeplot1.plt

Figure 5.7: Layout of data points in volumeplot1.e

Activate the shade layer in the frame.

ret = gpSetShadeColor(&gp,1,1,"blue");

Set the color of the field zone shading to blue.

ret = gpUseTranslucencyEffect(&gp,1,1);

Activate the translucency effect in the frame. This will cause the shading to appeartranslucent.

Translucency is not used in the graph in Figure 5.6 because of file size considerations.

ret = gpSetTranslucency(&gp,1,1,30);

Set the percentage of translucency to 70%.

gpSetMacroFile(&gp,"volumeplot1.mcr");

95

Page 104: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

5. 2D AND 3D CARTESIAN PLOTS

Specify the name of the macro file to be created. If no call to gpSetMacroFile is made,then gpMake3DCartesianPlot generates a temporary file, placing it in the GAUSS

temporary file directory, which is set in gauss.cfg. You are responsible for deletingtemporary files created in this manner. You may call gpCleanUp after your graph hasbeen created to delete these files.

ret = gpSetDataFile(&gp,0,"volumeplot1.plt");

Specify the name of the data file to be created. If no call to gpSetDataFile is made,then gpMake3DCartesianPlot generates a temporary file. You must either delete thistemporary data file manually or call gpCleanUp after running your program to delete it.

5.6.5 Plotting the Graph

ret = gpMake3DCartesianPlot(&gp,x,y,z,"");

Write the data file and plot the graph, using x as the X-axis variable, y as the Y-axisvariable and z as the Z-axis variable.

5.7 animate2.e

See Figure 5.8 for the graph produced by this example.

5.7.1 The Code

// Set up library and include file with structure definitions

library gaussplot;

#include gp.sdf

// Create gpPlotControl structure and set members to default values

struct gpPlotControl gp;

gp = gp3DCartesianPlotCreate;

// Create data file if it does not already exist

hk = 100;

{ fnames, finfo } = fileinfo("animate2.plt");

if (finfo == 0);

96

Page 105: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Cartesian Plots

5. 2D AND 3D CARTESIAN PLOTS

X

-5

0Y

-5

0

X Y

ZFrame 001 26 Jan 2005 animate2.plt

Figure 5.8: animate2.e

print "Generating data file...";

// Create gpData structure

struct gpData gdat;

// Generate data

xl = -8;

xu = 8;

xk = 41;

x = seqa(xl,(xu-xl)/(xk-1),xk)’;

x1 = x .* ones(xk,xk);

yl = -8;

yu = 8;

yk = 41;

y = seqa(yl,(yu-yl)/(yk-1),yk);

y1 = y .* ones(yk,yk);

z = sin(sqrt(x^2+y^2)) ./ sqrt(x^2+y^2);

a = aconcat(x1,y1,3);

97

Page 106: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

5. 2D AND 3D CARTESIAN PLOTS

// List variable names

string vnames = { "X", "Y", "Z" };

// Set data in gpdata structure

gdat = gpInitPlotData(vnames);

// create zones and add data

hl = 0;

hu = 1;

h = seqa(hl,(hu-hl)/(hk-1),hk);

for i(1,hk,1);

z1 = z .* sin(h[i]*x);

a1 = aconcat(a,z1,3);

ret = gpAddZone(&gdat,"Zone "$+ftos(i,"%*.*lf",1,0),a1);

endfor;

// Write data file

ret = gpWritePlotData(&gdat,"animate2.plt");

endif;

print "Plotting the graph...";

// Specify names for macro file to be created and data file to use

gpSetMacroFile(&gp,"animate2.mcr");

ret = gpSetDataFile(&gp,0,"animate2.plt");

// Set contour color map range for multi-colored mesh

ret = gpSetContourColorMapRange(&gp,1,1,-0.4,0.6);

// Set mesh color to multi and mesh type to hidden-line

ret = gpSetMeshColor(&gp,1,seqa(1,1,hk),"multi");

ret = gpSetMeshType(&gp,1,seqa(1,1,hk),3);

// Set boundary color to red

ret = gpSetBoundaryColor(&gp,1,seqa(1,1,hk),"red");

// Resize and move frame

ret = gpMoveFrame(&gp,1,0.25,0.25,10.5,8);

// Make axes independent of one another

ret = gpMakeAxesIndependent(&gp,1);

// Cycle through field zones forwards and then backwards to produce an animation

98

Page 107: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Cartesian Plots

5. 2D AND 3D CARTESIAN PLOTS

ret = gpAnimateFieldZones(&gp,1,1,1,hk,1);

// Create 3D Cartesian plot

ret = gpPlot(&gp);

5.7.2 Setup and Initialization

library gaussplot;

Activate the library containing all of the GAUSSplot commands.

#include gp.sdf

Include the file containing definitions of all GAUSSplot structures.

struct gpPlotControl gp;

Create an instance of a plot control structure.

gp = gp3DCartesianPlotCreate;

Initialize the members of gp to default values for a 3D Cartesian plot.

5.7.3 Creating Data and Writing the Data File

hk = 100;

Set hk to the number of zones to create.

{ fnames, finfo } = fileinfo("animate2.plt");

Check to see if the data file already exists.

if (finfo == 0);

99

Page 108: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

5. 2D AND 3D CARTESIAN PLOTS

If the data file already exists, pass down to the endif statement to save time. If it doesnot exist, create the data and write the data file.

print "Generating data file...";

Print message to show what the program is doing, since the program takes some timeto run.

struct gpData gdat;

Create an instance of a data structure.

xl = -8;

xu = 8;

xk = 41;

x = seqa(xl,(xu-xl)/(xk-1),xk)’;

x1 = x .* ones(xk,xk);

yl = -8;

yu = 8;

yk = 41;

y = seqa(yl,(yu-yl)/(yk-1),yk);

y1 = y .* ones(yk,yk);

z = sin(sqrt(x^2+y^2)) ./ sqrt(x^2+y^2);

Generate variables to be associated with the X, Y and Z axes in the graph. Thisexample creates a data file with 100 zones (i.e., 100 sets of variables). The variablesassociated with the X and Y axes will be the same for each zone, so we generate themhere (x1 and y1). The Z-axis variables are generated in the for loop below, based onthe variable z, which is defined here.

a = aconcat(x1,y1,3);

Concatenate x1 and y1, in that order, to create a 2 × 41 × 41 array, which is laid out asfollows:

a[1,.,.] = x1a[2,.,.] = y1

The Z-axis variable (z1) for each zone is concatenated to this array before each call togpAddZone. It is necessary to concatenate x1, y1 and z1 into a 3-dimensional arraybefore putting the data in the gpData structure with a call to gpAddZone because

100

Page 109: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Cartesian Plots

5. 2D AND 3D CARTESIAN PLOTS

gpAddZone inputs all of the data for one zone as one argument. This gives you theflexibility to create a data file according to your specifications.

See Table 5.1 for a description of the assumptions that gpAddZone makes about thedata depending on the type of data argument it receives.

string vnames = { "X", "Y", "Z" };

Specify names for the variables.

gdat = gpInitPlotData(vnames);

Initialize the gpData structure and write the variable names to it. The number ofvariables that you input in succeeding calls to gpAddZone must match the number ofnames in vnames.

hl = 0;

hu = 1;

h = seqa(hl,(hu-hl)/(hk-1),hk);

Set up variables needed for calculating the z1 variable for each zone in the for loopbelow.

for i(1,hk,1);

z1 = z .* sin(h[i]*x);

a1 = aconcat(a,z1,3);

ret = gpAddZone(&gdat,"Zone "$+ftos(i,"%*.*lf",1,0),a1);

endfor;

Calculate z1 for each zone, concatenate it to a (which contains x1 and y1) in the thirddimension, and add the data for each zone to the data structure.

ret = gpWritePlotData(&gdat,"animate2.plt");

endif;

Write the variable names and data in gdat to the file animate2.plt, and exit the if

statement.

101

Page 110: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

5. 2D AND 3D CARTESIAN PLOTS

5.7.4 Setting Options

print "Plotting the graph...";

Print message to show what the program is doing, since the program takes some timeto run.

gpSetMacroFile(&gp,"animate2.mcr");

Specify the name of the macro file to be created. If no call to gpSetMacroFile is made,then gpPlot generates a temporary file, placing it in the GAUSS temporary filedirectory, which is set in gauss.cfg. You are responsible for deleting temporary filescreated in this manner. You may call gpCleanUp after your graph has been created todelete these files.

ret = gpSetDataFile(&gp,0,"animate2.plt");

Specify the name of the data file to be used. It is necessary to call gpSetDataFile beforethe plotting the graph with gpPlot. gpPlot will error out if no data file is specified.

Since animate2.plt has 100 zones, the resulting graph will have 100 field zones.

ret = gpSetContourColorMapRange(&gp,1,1,-0.4,0.6);

Set the range of the contour color map for contour mesh (set by the next call). Bydefault, GAUSSplot takes the range of the contour color map from the last variable inthe first field zone. In this example, the first field zone is a flat plane, so the Z-axisvalues (which are taken from the last variable in the zone) are all equal. Thus there isonly one value in the contour color map range, which results in the use of only one color.

Therefore, we must set the range of the contour color map manually. Values near theminimum (−0.4 in this example) will appear as blue or purple (the colors at thebottom of the rainbow color map), while values near the maximum (0.6) will appear asred (which is at the top of the color map).

The range of the contour color map (like other contour options) is set for a particularcontour group. The contour group number is the third argument togpSetContourColorMapRange, and in this example, we are setting the option for thefirst contour group.

ret = gpSetMeshColor(&gp,1,seqa(1,1,hk),"multi");

102

Page 111: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Cartesian Plots

5. 2D AND 3D CARTESIAN PLOTS

Set the color of the mesh for all 100 field zones to ‘multi’, which specifies contourcoloring, using the contour options from the first contour group. To use contourcoloring with contour options from the second, third or fourth contour groups, use thecorresponding ‘multi’ color (i.e. ‘multi2’, ‘multi3’ or ‘multi4’).

ret = gpSetMeshType(&gp,1,seqa(1,1,hk),3);

Set the type of the mesh for all field zones to hidden line. With hidden line mesh, allmesh lines that are underneath another surface are removed. This essentially makes themesh layer opaque.

ret = gpSetBoundaryColor(&gp,1,seqa(1,1,hk),"red");

Set the color of the boundary around each field zone to red.

ret = gpMoveFrame(&gp,1,0.25,0.25,10.5,8);

Resize the frame to fill the workspace.

ret = gpMakeAxesIndependent(&gp,1);

Allow the axes to be sized independently.

ret = gpAnimateFieldZones(&gp,1,1,1,hk,1);

Create an animation loop with 1 iteration, which cycles through each of the 100 fieldzones in the plot, one at a time, beginning with the first field zone and ending with thelast.

The animation will be displayed immediately after the graph has been completed. Ifyou put multiple animation commands in your program, they will run in the order inwhich they appear in your program.

5.7.5 Plotting the Graph

ret = gpPlot(&gp);

Plot the graph using the information contained in gp.

103

Page 112: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

5. 2D AND 3D CARTESIAN PLOTS

104

Page 113: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Contour Plots

6. 2D AND 3D CONTOUR PLOTS

Chapter 6

2D and 3D Contour Plots

6.1 contourplot1.e

See Figure 6.1 for the graph produced by this example.

6.1.1 The Code

// Set up library and include file with structure definitions

library gaussplot;

#include gp.sdf

// Create gpPlotControl structure and set members to default values

struct gpPlotControl gp;

gp = gp3DContourPlotCreate;

// Generate data

xl = 51;

yl = 51;

pix = pi/(xl-1);

piy = pi/(yl-1);

x = seqa(-88,2.5,xl)’*pix;

y = seqa(-88,2.5,yl)*piy;

z = sin(x).*cos(x-y);

cv = cos(x).*sin(x-y);

x = x.*ones(51,51);

y = y.*ones(51,51);

105

Page 114: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

6. 2D AND 3D CONTOUR PLOTS

X

-4

-2

0

2

Y

-4

-2

0

2

X Y

Z3D Contour Plot

Frame 001 26 Jan 2005 contourplot1.plt

Figure 6.1: contourplot1.e

// List variable names

string vnames = { "X", "Y", "Z", "CV" };

// Specify names for macro file to be created and data file to be opened

gpSetMacroFile(&gp,"contourplot1.mcr");

ret = gpSetDataFile(&gp,0,"contourplot1.plt");

// Add title for frame

ret = gpAddTextObject(&gp,1,"",43,93,1,"3D Contour Plot");

// Create contour plot

ret = gpMake3DContourPlot(&gp,x,y,z,cv,vnames);

6.1.2 Setup and Initialization

library gaussplot;

Activate the library containing all of the GAUSSplot commands.

#include gp.sdf

106

Page 115: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Contour Plots

6. 2D AND 3D CONTOUR PLOTS

Include the file containing definitions of all GAUSSplot structures.

struct gpPlotControl gp;

Create an instance of a plot control structure.

gp = gp3DContourPlotCreate;

Initialize the members of gp to default values for a 3D Contour plot.

6.1.3 Creating Data

xl = 51;

yl = 51;

pix = pi/(xl-1);

piy = pi/(yl-1);

x = seqa(-88,2.5,xl)’*pix;

y = seqa(-88,2.5,yl)*piy;

z = sin(x).*cos(x-y);

cv = cos(x).*sin(x-y);

x = x.*ones(51,51);

y = y.*ones(51,51);

Generate variables to be associated with the X, Y and Z axes in the graph, as well as avariable to be used as the contour variable. All four variables, x, y, z and cv, are51 × 51 matrices. When graphed together, they create a locus of points in 3D spacedescribed by (x, y, z) with contour flooding determined by cv.

string vnames = { "X", "Y", "Z", "CV" };

Specify names for all of the variables.

6.1.4 Setting Options

gpSetMacroFile(&gp,"contourplot1.mcr");

Specify the name of the macro file to be created. If no call to gpSetMacroFile is made,then gpMake3DContourPlot generates a temporary file, placing it in the GAUSS

107

Page 116: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

6. 2D AND 3D CONTOUR PLOTS

temporary file directory, which is set in gauss.cfg. You are responsible for deletingtemporary files created in this manner. You may call gpCleanUp after your graph hasbeen created to delete these files.

ret = gpSetDataFile(&gp,0,"contourplot1.plt");

Specify the name of the data file to be created. If no call to gpSetDataFile is made,then gpMakeContourPlot generates a temporary file. You must either delete thistemporary data file manually or call gpCleanUp after running your program to delete it.

ret = gpAddTextObject(&gp,1,"",43,93,1,"3D Contour Plot");

Add a text object to the top of the frame as a title.

6.1.5 Plotting the Graph

ret = gpMake3DContourPlot(&gp,x,y,z,cv,vnames);

Write the data file and plot the graph, using x as the X-axis variable, y as the Y-axisvariable, z as the Z-axis variable and cv as the contour variable.

To use z as the contour variable, use the following command:

ret = gpMake3DContourPlot(&gp,x,y,z,z,vnames);

6.2 contourplot3.e

See Figure 6.2 for the graph produced by this example.

6.2.1 The Code

// Set up library and include file with structure definitions

library gaussplot;

#include gp.sdf

// Create gpPlotControl structure and set members to default values

struct gpPlotControl gp;

gp = gpPlotCreate;

108

Page 117: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Contour Plots

6. 2D AND 3D CONTOUR PLOTS

X

Y

-4 -2 0 2

-4

-2

0

2

-0.9 -0.7 -0.5 -0.3 -0.1 0.1 0.3 0.5 0.7 0.9

2D Contour Plotwith Contour Surface Inset

Frame 001 26 Jan 2005 contourplot3.plt

X Y

Z

Figure 6.2: contourplot3.e

// Create gpData structure

struct gpData gdat;

// Generate data

xl = 51;

yl = 51;

pix = pi/(xl-1);

piy = pi/(yl-1);

x = seqa(-88,2.5,xl)’*pix;

y = seqa(-88,2.5,yl)*piy;

// Z-axis variable

z = sin(x).*cos(x-y);

// X and Y-axis variables

x = x.*ones(51,51);

y = y.*ones(51,51);

// Put data into an array

a = aconcat(x,y,3);

a = aconcat(a,z,3);

109

Page 118: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

6. 2D AND 3D CONTOUR PLOTS

// List variable names

string vnames = { "X", "Y", "Z" };

// Set data in gpData structure

gdat = gpInitPlotData(vnames);

ret = gpAddZone(&gdat,"",a);

// Write data file

ret = gpWritePlotData(&gdat,"contourplot3.plt");

// Specify names for macro file to be created and data file to be opened

gpSetMacroFile(&gp,"contourplot3.mcr");

ret = gpSetDataFile(&gp,0,"contourplot3.plt");

// Add a 2-D contour frame and a 3-D contour frame

gpAdd2DContourFrame(&gp);

gpAdd3DContourFrame(&gp);

// Change color distribution to continuous

ret = gpSetContourColorDistribution(&gp,1,1,2);

ret = gpSetContourColorDistribution(&gp,2,1,2);

// Resize and move frames to show both in window

ret = gpMoveFrame(&gp,1,0.25,0.25,10.5,8);

ret = gpMoveFrame(&gp,2,2,4.6,3.5,2.5);

// Make X and Y axes independent of one another in frame 1

// And make axes XYZ dependent in frame 2

ret = gpMakeAxesIndependent(&gp,1);

ret = gpMakeAxesXYZDependent(&gp,2,1,0.5);

// Add title for frame 1

ret = gpAddTextObject(&gp,1,"",41,91,1,

" 2D Contour Plot"$|"with Contour Surface Inset");

// Add contour legend for contour group 1

ret = gpAddContourLegend(&gp,1,1);

ret = gpSetContourLegendBoxStyle(&gp,1,1,2,0.4,3,10);

ret = gpSetContourLegendSkip(&gp,1,1,2);

ret = gpSetContourLegendView(&gp,1,1,0,0);

ret = gpSetContourLegendOrientation(&gp,1,1,2);

ret = gpMoveContourLegend(&gp,1,1,85,85);

ret = gpSetContourLegendLabelFont(&gp,1,1,"times",14,2);

// Do not show border or axes on frame 2

110

Page 119: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Contour Plots

6. 2D AND 3D CONTOUR PLOTS

ret = gpSetFrameStyle(&gp,2,0,0,1);

ret = gpShowXAxis(&gp,2,0,0);

ret = gpShowYAxis(&gp,2,0,0);

ret = gpShowZAxis(&gp,2,0);

// Create contour plot

ret = gpPlot(&gp);

6.2.2 Setup and Initialization

library gaussplot;

Activate the library containing all of the GAUSSplot commands.

#include gp.sdf

Include the file containing definitions of all GAUSSplot structures.

struct gpPlotControl gp;

Create an instance of a plot control structure.

gp = gpPlotCreate;

Initialize the members of gp to default values for a plot without an associated plot type.This command is used to initialize a plot control structure for a multiple frame graphcontaining plots of different types. Since there is no plot type associated with the plotcontrol structure, the graph contains no frames by default. Frames must be addedusing the various gpAddPlotTypeFrame commands.

6.2.3 Creating Data

struct gpData gdat;

Create an instance of a data structure.

111

Page 120: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

6. 2D AND 3D CONTOUR PLOTS

xl = 51;

yl = 51;

pix = pi/(xl-1);

piy = pi/(yl-1);

x = seqa(-88,2.5,xl)’*pix;

y = seqa(-88,2.5,yl)*piy;

z = sin(x).*cos(x-y);

x = x.*ones(51,51);

y = y.*ones(51,51);

Generate variables to be associated with the X, Y and Z axes in the graph. All threevariables, x, y and z, are 51 × 51 matrices. When graphed together, they create a locusof points in 3D space described by (x, y, z). z is also used as the contour variable.

a = aconcat(x,y,3);

a = aconcat(a,z,3);

Concatenate x, y and z in the third dimension, in that order, to create a 3 × 51 × 51array, which is laid out as follows:

a[1,.,.] = xa[2,.,.] = ya[3,.,.] = z

It is necessary to concatenate x, y and z into a 3-dimensional array before putting thedata in the gpData structure with a call to gpAddZone because gpAddZone inputs allof the data for one zone as one argument. This gives you the flexibility to create a datafile according to your specifications.

See Table 5.1 for a description of the assumptions that gpAddZone makes about thedata depending on the type of data argument it receives.

string vnames = { "X", "Y", "Z" };

Specify names for the variables.

gdat = gpInitPlotData(vnames);

Initialize the gpData structure and write the variable names to it. The number ofvariables that you input in succeeding calls to gpAddZone must match the number ofnames in vnames.

ret = gpAddZone(&gdat,"",a);

112

Page 121: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Contour Plots

6. 2D AND 3D CONTOUR PLOTS

Add the data to the data structure.

ret = gpWritePlotData(&gdat,"contourplot3.plt");

Write the variable names and data in gdat to the file contourplot3.plt.

6.2.4 Setting Options

gpSetMacroFile(&gp,"contourplot3.mcr");

Specify the name of the macro file to be created. If no call to gpSetMacroFile is made,then gpPlot generates a temporary file, placing it in the GAUSS temporary filedirectory, which is set in gauss.cfg. You are responsible for deleting temporary filescreated in this manner. You may call gpCleanUp after your graph has been created todelete these files.

ret = gpSetDataFile(&gp,0,"contourplot3.plt");

Specify the name of the data file to be used. It is necessary to call gpSetDataFile beforethe plotting the graph with gpPlot. gpPlot will error out if no data file is specified.

gpAdd2DContourFrame(&gp);

Add a 2D Contour frame to the graph. This is the first frame in the graph. By default,the last variable in the data file is used as the contour variable. In this case, the lastvariable in the data file is Z.

gpAdd3DContourFrame(&gp);

Add a 3D Contour frame to the graph.

ret = gpSetContourColorDistribution(&gp,1,1,2);

Set the contour color distribution in the first contour group in the first frame tocontinuous. This causes the shade of a color used between contour levels to varydepending on distance from the contour level. By default, contour groups use a solidcolor between contour levels.

113

Page 122: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

6. 2D AND 3D CONTOUR PLOTS

Contour color distribution (like other contour options) is set for a particular contourgroup. The contour group number is the third argument togpSetContourColorDistribution, and in this example, the contour group number is 1.

Continuous color distribution is not reflected in the graph in Figure 6.2 because of filesize considerations.

ret = gpSetContourColorDistribution(&gp,2,1,2);

Set the contour color distribution in the first contour group in the second frame tocontinuous.

ret = gpMoveFrame(&gp,1,0.25,0.25,10.5,8);

Resize the first frame to fill the workspace.

ret = gpMoveFrame(&gp,2,2,4.6,3.5,2.5);

Resize and move the second frame to make it an inset in the first frame.

ret = gpMakeAxesIndependent(&gp,1);

Allow the axes in the first frame to be sized independently.

ret = gpMakeAxesXYZDependent(&gp,2,1,0.5);

Set 1 unit on the Y-axis and 0.5 units on the Z-axis equal in length to 1 unit on theX-axis in the second frame.

ret = gpAddTextObject(&gp,1,"",41,91,1,

" 2D Contour Plot"$|"with Contour Surface Inset");

Add a multi-line text object at the top of the first frame as a title. Inputting an N × 1string array as the last argument to gpAddTextObject creates a text object with N

lines of text. To center one or more lines of text on another line in a multi-line textobject, you may need add spaces manually, as in the above example.

ret = gpAddContourLegend(&gp,1,1);

114

Page 123: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Contour Plots

6. 2D AND 3D CONTOUR PLOTS

Add a contour legend for contour group one in frame one. All field zones use the firstcontour group in a frame by default. To use a different contour group, callgpSetContourFloodGroup or gpSetContourLineGroup.

ret = gpSetContourLegendBoxStyle(&gp,1,1,2,0.4,3,10);

Enclose the contour legend in a hollow box (i.e., a box with no background). Set thethickness of the box outline to 0.4% of the frame height, and use red as the box outlinecolor and ‘custom2’ as the box fill color.

See the global variable gp colors in gp.dec for the list of color names. This call togpSetContourLegendBoxStyle uses indices into gp colors to specify colors in the lasttwo arguments.

ret = gpSetContourLegendSkip(&gp,1,1,2);

Display only one in every two contour levels in the legend.

ret = gpSetContourLegendView(&gp,1,1,0,0);

Do not display the contour legend header or black lines separating the contour colorbands.

ret = gpSetContourLegendOrientation(&gp,1,1,2);

Display the contour legend horizontally.

ret = gpMoveContourLegend(&gp,1,1,85,85);

Move the contour legend to a specified position in frame units (0 − 100).

ret = gpSetContourLegendLabelFont(&gp,1,1,"times",14,2);

Use a 14pt ‘times’ font for the labels in the contour legend. CallgpSetContourLegendHeaderFont to set the font for the contour legend header (ifdisplayed).

ret = gpSetFrameStyle(&gp,2,0,0,1);

115

Page 124: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

6. 2D AND 3D CONTOUR PLOTS

Do not display frame header or border for the second frame.

ret = gpShowXAxis(&gp,2,0,0);

Do not display the X-axis in the second frame.

ret = gpShowYAxis(&gp,2,0,0);

Do not display the Y-axis in the second frame.

ret = gpShowZAxis(&gp,2,0);

Do not display the Z-axis in the second frame.

6.2.5 Plotting the Graph

ret = gpPlot(&gp);

116

Page 125: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Index

INDEX

Index

2D Cartesian plot, 532D Contour plot, 105

3D Cartesian plot, 533D Contour plot, 1053D rotation, 56, 74

A

animation, 56, 96

B

Bar plot, 27

G

gp3DCartesianPlotCreate, 55, 59, 77,86, 93, 99

gp3DContourPlotCreate, 107gpAdd2DCartesianFrame, 71gpAdd2DContourFrame, 113gpAdd3DCartesianFrame, 72, 80gpAdd3DContourFrame, 113gpAddArrow, 39gpAddContourLegend, 115gpAddFieldzoneLegendFrame, 91gpAddLineLegend, 10, 42, 51gpAddMacroFile, 83gpAddTextObject, 21, 22, 38, 56, 74,

89, 108, 114gpAddZone, 61, 69, 71, 79, 88, 101, 113gpAnimateFieldZones, 103gpAnimateXAxisRotation, 64gpAnimateYAxisRotation, 64gpAnimateZAxisRotation, 64gpBarPlotCreate, 28, 34

gpFillGridArea, 91gpFramePause, 23gpGetErrorMessage, 16, 70, 71gpInitPlotData, 61, 69, 71, 79, 88, 101,

112gpMake3DCartesianPlot, 56, 96gpMake3DContourPlot, 108gpMakeAxesIndependent, 64, 73, 82,

103, 114gpMakeAxesXYDependent, 41gpMakeAxesXYZDependent, 90, 114gpMakeBarPlot, 29gpMakePolarLinePlot, 45gpMakeVectorsTangent, 64gpMakeXYLinePlot, 7, 10, 26gpMoveContourLegend, 115gpMoveFieldZoneLegend, 91gpMoveFrame, 20, 21, 37, 62, 72, 103,

114gpMoveLineLegend, 10, 42, 52gpPlot, 23, 42, 52, 65, 74, 83, 91, 103,

116gpPlotCreate, 68, 111gpPolarLinePlotCreate, 44, 48gpRotateAxes, 82, 83gpRotateTextObject, 22gpRotateYAxis, 91gpRotateZAxis, 91gpSetActiveFieldZones, 80gpSetArrowColor, 39, 40gpSetArrowHeadAttachment, 39gpSetArrowHeadStyle, 40gpSetArrowHeadType, 39gpSetArrowLineThickness, 39, 40gpSetBarColor, 37

117

Page 126: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

INDEX

gpSetBarWidth, 36, 37gpSetBoundaryColor, 63, 72, 103gpSetContourColorDistribution, 113,

114gpSetContourColorMapRange, 102gpSetContourLegendBoxStyle, 115gpSetContourLegendLabelFont, 115gpSetContourLegendOrientation, 115gpSetContourLegendSkip, 115gpSetContourLegendView, 115gpSetDataFile, 7, 10, 16, 25, 29, 36, 45,

49, 56, 62, 72, 80, 89, 96, 102,108, 113

gpSetErrorLevel, 16, 71gpSetFieldZoneLegendFont, 91gpSetFieldZoneLegendLineSpacing, 91gpSetFrameStyle, 42, 73, 82, 116gpSetLineColor, 20gpSetLineLegendBoxType, 42, 52gpSetLineLegendFont, 52gpSetLineLegendLineSpacing, 42gpSetLineLegendMargin, 42, 52gpSetLineMapNames, 41, 51gpSetLineMaps, 17, 36, 50gpSetLinePattern, 20gpSetLinePatternLength, 20gpSetLineThickness, 20, 50gpSetMacroFile, 7, 10, 16, 25, 29, 36,

45, 49, 55, 62, 72, 80, 89, 96,102, 107, 113

gpSetMagnification, 52gpSetMeshColor, 63, 72, 103gpSetMeshType, 103gpSetPlotData, 15, 35, 49gpSetPlotFit, 64, 82, 90gpSetPolarAxesTitles, 52gpSetShadeColor, 63, 73, 95gpSetSymbolColor, 19gpSetSymbolFillMode, 20, 50gpSetSymbolLineThickness, 19gpSetSymbolShape, 18, 19, 50, 51gpSetSymbolShapeASCII, 19gpSetSymbolSize, 18, 50gpSetSymbolSkip, 17, 18, 51gpSetTextObjectAnchorLocation, 89gpSetTextObjectBoxColor, 22

gpSetTextObjectBoxStyle, 39gpSetTextObjectBoxType, 22gpSetTextObjectColor, 22, 38gpSetTextObjectFont, 22, 38gpSetTextObjectLineSpacing, 39gpSetTextObjectMargin, 22, 39gpSetThetaMode, 52gpSetTranslation, 52gpSetTranslucency, 63, 73, 95gpSetVectorArrowHeadType, 64gpSetVectorColor, 64gpSetVectorType, 64gpSetXAxisColor, 41gpSetXAxisLabelColor, 40gpXAxisLabelFont, 40gpSetXAxisLabelSkip, 40gpSetXAxisThickness, 41gpSetXAxisTitle, 10, 21, 25, 37, 38, 90gpSetXAxisTitleColor, 41gpSetXAxisTitleFont, 41gpSetYAxisLabelFont, 40gpSetYAxisLabelOffset, 40gpSetYAxisTitle, 10, 21, 25, 37, 38, 90gpSetYAxisTitleFont, 41gpSetYAxisTitleOffset, 41gpSetZAxisRange, 80, 81gpSetZAxisTitle, 81, 90gpSetZAxisTitleOffset, 90gpShow3DOrientationAxis, 81gpShowBoundaryLayer, 94gpShowDrawing, 22gpShowFieldZoneMeshLayer, 62gpShowFieldZoneShadeLayer, 63gpShowFieldZoneVectorLayer, 63gpShowMeshLayer, 94gpShowShadeLayer, 73, 95gpShowSymbolLayer, 17, 50gpShowXAxis, 73, 81, 116gpShowXAxisGridLines, 90gpShowYAxis, 74, 81, 116gpShowYAxisGridLines, 90gpShowZAxis, 74, 116gpShowZAxisGridLines, 90gpUseTranslucencyEffect, 63, 73, 95gpWritePlotData, 15, 35, 49, 61, 70, 71,

79, 88, 101, 113

118

Page 127: Professional Graphics Cookbookfaculty.ses.wsu.edu/LaFrance/Linux-Server/Gauss-Plot-Cookbook.pdf · Professional Graphics Cookbook Aptech Systems, Inc. Powered by Tecplotr 1. Information

Index

INDEX

gpXYLinePlotCreate, 7, 9, 14, 25

P

Polar Line plot, 43

R

rotation, 56, 74

S

structure pointers, 2

V

volume plots, 91

X

XY Line plot, 5

119