From octave-sources-request at bevo dot che dot wisc dot edu Wed Jan 20 09:36:22 1999 Subject: octave and xfig From: "S.Hefti" To: octave-sources at bevo dot che dot wisc dot edu Date: Wed, 20 Jan 1999 10:36:21 -0500 README.hgi/hefti/19-Jan-1999 hgi --- Hefti's Graphic Interface (for Octave) This is to announce a prototype of the hgi. It is in early development stage and definitively not productive. Nonetheless, I would like to outline the idea. Motivation: I am not satisfied with the plot capabilities of Octave. I have been searching the public-domain market for quite some time to find a plotting package that suits me, but without luck. In particular, I think there is no means in Octave to overlay images and 2D-plots. This is where hgi might help. Idea: Instead of producing a half-finished plot in Octave (using gnuplot) and post-processing it with xfig, I thought it would be nice to directly produce xfig files from within Octave. That way, figures are already in the "correct" format from the beginning and are easy to edit within xfig, if needed. There is no need for "pstoedit", for example. This also provides a natural way of combining different plots on one page, or of overlaying images and plots. To obtain a postscript file, the .fig file simply has to be processed with fig2dev which is part of the xfig package. The .fig format is very well documented and easy to implement. Example: A figure created with hgi can be seen at: http://pooh.engin.umich.edu/mqh98050.jpg The example below illustrates how the figure is produced. As mentioned before, this is an early development announcement. Therefore, almost all parameters have to be set manually. It will be easy, however, to write routines which do this work. ## read data mmq = read_gen("file.dat",10,1); ## read map map = transpose(read_gen("/some_path/olh/setup/m3.dat",10,3)); colormap(map); ## write image to file saveimage("test.ppm",imgscl(log(mmq+1)),"ppm",map); ## use ImageMagic to convert file system("convert test.ppm test.jpg"); ## write xfig file hgi = hgiopen("test.fig"); ## open a new file, set defaults hgi.p.xpos = [0.4,0.8] ## where to place plot (normalized coordinates) hgi.x.islog = 1; ## define x-axis (is logarithmic) hgi.x.tickv = [1,2,3,4,5,10,15,20]; ## where to draw tick-marks hgi.x.tickt = [1,0,0,0,1,1, 0, 1]; ## define major ticks (1) hgi.x.title = "m/q"; hgi = hgixax(hgi,[1,20]); ## draw axis hgi.y.islog = 1; ## same for y-axis hgi.y.tickv = [1,5,10,20,30,40,50,100]; hgi.y.tickt = [1,0,1, 1, 1, 1, 1, 1]; hgi.y.title = "mass"; hgi = hgiyax(hgi,[1,100]); ## overlay .jpg file hgi_posjpg(hgi,"test.jpg",1,1,20,100,0); hgi.t.angle = 0.0; ## define text-object properties hgi.t.align = 0; ## 0 -> left 1 -> center 2 -> right hgi.t.size = 1.5; ## normalized units [tmx,tmy] = hgia2d(hgi,4.0,3.0); ## from data->normalized coordinates hgitext(hgi,tmx,tmy,"SWICS/ACE",0.0); ## print text [tmx,tmy] = hgia2d(hgi,4.0,2.0); hgi.t.size = 1.0; hgitext(hgi,tmx,tmy,yyddd,0.0); [tmx,tmy] = hgia2d(hgi,4.0,1.3); hgi.t.size = 0.7; hgitext(hgi,tmx,tmy,"1999 by Hefti, University of Michigan",0.0); hgiclose(hgi); ## done FTP archive: The current snapshot of the development tree is available at: ftp://pooh.engin.umich.edu/pub/Octave/ The hgi is embedded in olh (Hefti's library for Octave), which provides a couple of utility functions. Therefore, look out for olh.tar.gz. Design: Let me quickly outline the design idea: all information about a page is stored in a structure that is created with hgiopen() (hgi in the example above). One page can hold more than one plot, and several pages or hgi-structures can be maintained at the same time. Almost each function call takes as first argument the hgi-structure, and returns the modified structure. The structure defines two major items: the device (hgi.d), and the page (hgi.p). The device describes the paper to be used (letter page etc). The page is defined in normalized coordinates ranging from 0..1 in both x- and y-direction: y ^ 1 | | | 0 +--------> x 0 1 no matter what device has been chosen. For plotting, two steps are needed: conversion from data (a) coordinates to normalized (n) coordinates, and conversion from normalized to device (d) coordinates for output. The idea of normalized units is also used for graphic objects: line thickness, font size and so on have a default of 1.0, which is globally defined, and can be adjusted as shown in the example above. Concerns: I am dealing with two problems right now: first, the xfig file might eventually grow too big when written with hgi. I would be interested in a "compressed" xfig format. For example, not all attributes a line like thikness, color etc need to be defined every single time a line is drawn. It would be more efficient to store a couple of "prototypes" first and refer to these definitions when a line is drawn. This is a xfig question, however. Second, it would be very nice if Octave routines could handle optional arguments that are specified as keywords, as in the hypothetical call hgi = hgixax(hgi,[1,20], title="m/q", ticks= [1,2,3,4,5,10,15,20], is_major=[1,0,0,0,1,1, 0, 1]); where all the tag=value arguments, if omitted, would be replaced by default values, and the order of the arguments would not matter. Author: hefti at umich dot edu I hope you like the idea of hgi. Thanks for your interest. ------------------------------------------------------------------------------ $Id: README.hgi,v 1.1 1999/01/19 17:03:17 hefti Exp hefti $ ------------------------------------------------------------------------------ -- --------------------------------------------------------------------- Simon Hefti, Ph D hefti at umich dot edu ---------------------------------------------------------------------