Module: GR

Extended by:
GRCommons::GRCommonUtils, GRCommons::JupyterSupport
Defined in:
lib/gr.rb,
lib/gr/ffi.rb,
lib/gr/plot.rb,
lib/gr/grbase.rb,
lib/gr/version.rb

Overview

OverView of GR.rb

+--------------------+  +--------------------+
| GR module          |  | GR3 module         |
| +----------------+ |  | +----------------+ |
| | GR::FFI        | |  | | GR3::FFI       | |
| | +   libGR.so   | |  | | +    libGR3.so | |
| +----------------+ |  | +----------------+ |
|   | define_method  |  |   | define_method  |
| +----------------+ |  | +----------------+ |
| | | GR::GRBase   | |  | | | GR3::GR3Base | |
| | v  (Pri^ate)   | |  | | v  (Pri^ate)   | |
| +++--------------+ |  | +++--------------+ |
|  | Extend          |  |  | Extend          |
|  v                 |  |  v       +-------+ |
|      +-----------+ |  |          | Check | |
|      | GR::Plot  | |  |       <--+ Error | |
|      +-----------+ |  |          +-------+ |
+--------------------+  +----------+---------+
          ^                        ^
          |  +------------------+  |
   Extend |  | GRCommons module |  | Extend
          |  | +--------------+ |  |
          |  | |    Fiddley   | |  |
          |  | +--------------+ |  |
          |  | +--------------+ |  |
          +----+ CommonUtils  +----+
          |  | +--------------+ |  |
          |  | +--------------+ |  |
          +----+    Version   +----+
          |  | +--------------+ |
          |  | +--------------+ |
          +----+JupyterSupport| |
             | +--------------+ |
             +------------------+

(You can edit the above AA diagram with asciiflow.com/))

Fiddley is Ruby-FFI compatible API layer for Fiddle.

The GR module works without Numo::Narrray. GR3 and GR::Plot depends on numo-narray.

This is a procedural interface to the GR plotting library, github.com/sciapp/gr

Defined Under Namespace

Modules: FFI Classes: Error, Plot

Constant Summary collapse

ASF_BUNDLED =
0
ASF_INDIVIDUAL =
1
NOCLIP =
0
CLIP =
1
COORDINATES_WC =
0
COORDINATES_NDC =
1
INTSTYLE_HOLLOW =
0
INTSTYLE_SOLID =
1
INTSTYLE_PATTERN =
2
INTSTYLE_HATCH =
3
TEXT_HALIGN_NORMAL =
0
TEXT_HALIGN_LEFT =
1
TEXT_HALIGN_CENTER =
2
TEXT_HALIGN_RIGHT =
3
TEXT_VALIGN_NORMAL =
0
TEXT_VALIGN_TOP =
1
TEXT_VALIGN_CAP =
2
TEXT_VALIGN_HALF =
3
TEXT_VALIGN_BASE =
4
TEXT_VALIGN_BOTTOM =
5
TEXT_PATH_RIGHT =
0
TEXT_PATH_LEFT =
1
TEXT_PATH_UP =
2
TEXT_PATH_DOWN =
3
TEXT_PRECISION_STRING =
0
TEXT_PRECISION_CHAR =
1
TEXT_PRECISION_STROKE =
2
LINETYPE_SOLID =
1
LINETYPE_DASHED =
2
LINETYPE_DOTTED =
3
LINETYPE_DASHED_DOTTED =
4
LINETYPE_DASH_2_DOT =
-1
LINETYPE_DASH_3_DOT =
-2
LINETYPE_LONG_DASH =
-3
LINETYPE_LONG_SHORT_DASH =
-4
LINETYPE_SPACED_DASH =
-5
LINETYPE_SPACED_DOT =
-6
LINETYPE_DOUBLE_DOT =
-7
LINETYPE_TRIPLE_DOT =
-8
MARKERTYPE_DOT =
1
MARKERTYPE_PLUS =
2
MARKERTYPE_ASTERISK =
3
MARKERTYPE_CIRCLE =
4
MARKERTYPE_DIAGONAL_CROSS =
5
MARKERTYPE_SOLID_CIRCLE =
-1
MARKERTYPE_TRIANGLE_UP =
-2
MARKERTYPE_SOLID_TRI_UP =
-3
MARKERTYPE_TRIANGLE_DOWN =
-4
MARKERTYPE_SOLID_TRI_DOWN =
-5
MARKERTYPE_SQUARE =
-6
MARKERTYPE_SOLID_SQUARE =
-7
MARKERTYPE_BOWTIE =
-8
MARKERTYPE_SOLID_BOWTIE =
-9
MARKERTYPE_HOURGLASS =
-10
MARKERTYPE_SOLID_HGLASS =
-11
MARKERTYPE_DIAMOND =
-12
MARKERTYPE_SOLID_DIAMOND =
-13
MARKERTYPE_STAR =
-14
MARKERTYPE_SOLID_STAR =
-15
MARKERTYPE_TRI_UP_DOWN =
-16
MARKERTYPE_SOLID_TRI_RIGHT =
-17
MARKERTYPE_SOLID_TRI_LEFT =
-18
MARKERTYPE_HOLLOW_PLUS =
-19
MARKERTYPE_SOLID_PLUS =
-20
MARKERTYPE_PENTAGON =
-21
MARKERTYPE_HEXAGON =
-22
MARKERTYPE_HEPTAGON =
-23
MARKERTYPE_OCTAGON =
-24
MARKERTYPE_STAR_4 =
-25
MARKERTYPE_STAR_5 =
-26
MARKERTYPE_STAR_6 =
-27
MARKERTYPE_STAR_7 =
-28
MARKERTYPE_STAR_8 =
-29
MARKERTYPE_VLINE =
-30
MARKERTYPE_HLINE =
-31
MARKERTYPE_OMARK =
-32
OPTION_X_LOG =
1
OPTION_Y_LOG =
2
OPTION_Z_LOG =
4
OPTION_FLIP_X =
8
OPTION_FLIP_Y =
16
OPTION_FLIP_Z =
32
OPTION_LINES =
0
OPTION_MESH =
1
OPTION_FILLED_MESH =
2
OPTION_Z_SHADED_MESH =
3
OPTION_COLORED_MESH =
4
OPTION_CELL_ARRAY =
5
OPTION_SHADED_MESH =
6
MODEL_RGB =
0
MODEL_HSV =
1
COLORMAP_UNIFORM =
0
COLORMAP_TEMPERATURE =
1
COLORMAP_GRAYSCALE =
2
COLORMAP_GLOWING =
3
COLORMAP_RAINBOWLIKE =
4
COLORMAP_GEOLOGIC =
5
COLORMAP_GREENSCALE =
6
COLORMAP_CYANSCALE =
7
COLORMAP_BLUESCALE =
8
COLORMAP_MAGENTASCALE =
9
COLORMAP_REDSCALE =
10
COLORMAP_FLAME =
11
COLORMAP_BROWNSCALE =
12
COLORMAP_PILATUS =
13
COLORMAP_AUTUMN =
14
COLORMAP_BONE =
15
COLORMAP_COOL =
16
COLORMAP_COPPER =
17
COLORMAP_GRAY =
18
COLORMAP_HOT =
19
COLORMAP_HSV =
20
COLORMAP_JET =
21
COLORMAP_PINK =
22
COLORMAP_SPECTRAL =
23
COLORMAP_SPRING =
24
COLORMAP_SUMMER =
25
COLORMAP_WINTER =
26
COLORMAP_GIST_EARTH =
27
COLORMAP_GIST_HEAT =
28
COLORMAP_GIST_NCAR =
29
COLORMAP_GIST_RAINBOW =
30
COLORMAP_GIST_STERN =
31
COLORMAP_AFMHOT =
32
COLORMAP_BRG =
33
COLORMAP_BWR =
34
COLORMAP_COOLWARM =
35
COLORMAP_CMRMAP =
36
COLORMAP_CUBEHELIX =
37
COLORMAP_GNUPLOT =
38
COLORMAP_GNUPLOT2 =
39
COLORMAP_OCEAN =
40
COLORMAP_RAINBOW =
41
COLORMAP_SEISMIC =
42
COLORMAP_TERRAIN =
43
COLORMAP_VIRIDIS =
44
COLORMAP_INFERNO =
45
COLORMAP_PLASMA =
46
COLORMAP_MAGMA =
47
FONT_TIMES_ROMAN =
101
FONT_TIMES_ITALIC =
102
FONT_TIMES_BOLD =
103
FONT_TIMES_BOLDITALIC =
104
FONT_HELVETICA =
105
FONT_HELVETICA_OBLIQUE =
106
FONT_HELVETICA_BOLD =
107
FONT_HELVETICA_BOLDOBLIQUE =
108
FONT_COURIER =
109
FONT_COURIER_OBLIQUE =
110
FONT_COURIER_BOLD =
111
FONT_COURIER_BOLDOBLIQUE =
112
FONT_SYMBOL =
113
FONT_BOOKMAN_LIGHT =
114
FONT_BOOKMAN_LIGHTITALIC =
115
FONT_BOOKMAN_DEMI =
116
FONT_BOOKMAN_DEMIITALIC =
117
FONT_NEWCENTURYSCHLBK_ROMAN =
118
FONT_NEWCENTURYSCHLBK_ITALIC =
119
FONT_NEWCENTURYSCHLBK_BOLD =
120
FONT_NEWCENTURYSCHLBK_BOLDITALIC =
121
FONT_AVANTGARDE_BOOK =
122
FONT_AVANTGARDE_BOOKOBLIQUE =
123
FONT_AVANTGARDE_DEMI =
124
FONT_AVANTGARDE_DEMIOBLIQUE =
125
FONT_PALATINO_ROMAN =
126
FONT_PALATINO_ITALIC =
127
FONT_PALATINO_BOLD =
128
FONT_PALATINO_BOLDITALIC =
129
FONT_ZAPFCHANCERY_MEDIUMITALIC =
130
FONT_ZAPFDINGBATS =
131
'ps'
'eps'
'pdf'
'pgf'
'bmp'
'jpeg'
'jpg'
'png'
'tiff'
'tif'
'fig'
'svg'
'wmf'
PATH_STOP =
0x00
PATH_MOVETO =
0x01
PATH_LINETO =
0x02
PATH_CURVE3 =
0x03
PATH_CURVE4 =
0x04
PATH_CLOSEPOLY =
0x4f
MPL_SUPPRESS_CLEAR =
1
MPL_POSTPONE_UPDATE =
2
XFORM_BOOLEAN =
0
XFORM_LINEAR =
1
XFORM_LOG =
2
XFORM_LOGLOG =
3
XFORM_CUBIC =
4
XFORM_EQUALIZED =
5
ENCODING_LATIN1 =
300
ENCODING_UTF8 =
301
UPSAMPLE_VERTICAL_DEFAULT =
0x00000000
UPSAMPLE_HORIZONTAL_DEFAULT =
0x00000000
DOWNSAMPLE_VERTICAL_DEFAULT =
0x00000000
DOWNSAMPLE_HORIZONTAL_DEFAULT =
0x00000000
UPSAMPLE_VERTICAL_NEAREST =
0x00000001
UPSAMPLE_HORIZONTAL_NEAREST =
0x00000100
DOWNSAMPLE_VERTICAL_NEAREST =
0x00010000
DOWNSAMPLE_HORIZONTAL_NEAREST =
0x01000000
UPSAMPLE_VERTICAL_LINEAR =
0x00000002
UPSAMPLE_HORIZONTAL_LINEAR =
0x00000200
DOWNSAMPLE_VERTICAL_LINEAR =
0x00020000
DOWNSAMPLE_HORIZONTAL_LINEAR =
0x02000000
UPSAMPLE_VERTICAL_LANCZOS =
0x00000003
UPSAMPLE_HORIZONTAL_LANCZOS =
0x00000300
DOWNSAMPLE_VERTICAL_LANCZOS =
0x00030000
DOWNSAMPLE_HORIZONTAL_LANCZOS =
0x03000000
RESAMPLE_DEFAULT =
(UPSAMPLE_VERTICAL_DEFAULT | UPSAMPLE_HORIZONTAL_DEFAULT |
DOWNSAMPLE_VERTICAL_DEFAULT | DOWNSAMPLE_HORIZONTAL_DEFAULT)
RESAMPLE_NEAREST =
(UPSAMPLE_VERTICAL_NEAREST | UPSAMPLE_HORIZONTAL_NEAREST |
DOWNSAMPLE_VERTICAL_NEAREST | DOWNSAMPLE_HORIZONTAL_NEAREST)
RESAMPLE_LINEAR =
(UPSAMPLE_VERTICAL_LINEAR | UPSAMPLE_HORIZONTAL_LINEAR |
DOWNSAMPLE_VERTICAL_LINEAR | DOWNSAMPLE_HORIZONTAL_LINEAR)
RESAMPLE_LANCZOS =
(UPSAMPLE_VERTICAL_LANCZOS | UPSAMPLE_HORIZONTAL_LANCZOS |
DOWNSAMPLE_VERTICAL_LANCZOS | DOWNSAMPLE_HORIZONTAL_LANCZOS)
PROJECTION_DEFAULT =
0
PROJECTION_ORTHOGRAPHIC =
1
PROJECTION_PERSPECTIVE =
2
VERSION =
GRCommons::VERSION

Constants included from GRCommons::GRCommonUtils

GRCommons::GRCommonUtils::SUPPORTED_TYPES

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from GRCommons::GRCommonUtils

create_ffi_pointer, double, equal_length, float, inquiry, inquiry_double, inquiry_int, inquiry_uint, int, narray?, read_ffi_pointer, uint, uint16, uint8

Methods included from GRCommons::JupyterSupport

extended, show

Class Attribute Details

.ffi_libObject

Returns the value of attribute ffi_lib.



52
53
54
# File 'lib/gr.rb', line 52

def ffi_lib
  @ffi_lib
end

Class Method Details

._contour_Object

Draw contours of a three-dimensional data set whose values are specified over a rectangular mesh. Contour lines may optionally be labeled.



1213
1214
1215
1216
1217
1218
1219
# File 'lib/gr/plot.rb', line 1213

def contour(x, y, h, z, major_h)
  # TODO: check: Arrays have incorrect length or dimension.
  nx = x.length
  ny = y.length
  nh = h.length
  super(nx, ny, nh, x, y, h, z, major_h)
end

._contourf_Object

Draw filled contours of a three-dimensional data set whose values are specified over a rectangular mesh.



1219
1220
1221
1222
1223
1224
1225
# File 'lib/gr/plot.rb', line 1219

def contourf(x, y, h, z, major_h)
  # TODO: check: Arrays have incorrect length or dimension.
  nx = x.length
  ny = y.length
  nh = h.length
  super(nx, ny, nh, x, y, h, z, major_h)
end

._hexbin_Integer



1225
1226
1227
1228
# File 'lib/gr/plot.rb', line 1225

def hexbin(x, y, nbins)
  n = x.length
  super(n, x, y, nbins)
end

._shade_Object



1267
1268
1269
# File 'lib/gr/plot.rb', line 1267

def shade(*)
  super
end

._surface_Object

Draw a three-dimensional surface plot for the given data points. x and y define a grid. z is a singly dimensioned array containing at least nx * ny data points. Z describes the surface height at each point on the grid. Data is ordered as shown in the table: (Plot) Draw a three-dimensional surface plot.



1242
1243
1244
1245
1246
1247
# File 'lib/gr/plot.rb', line 1242

def surface(x, y, z, option)
  # TODO: check: Arrays have incorrect length or dimension.
  nx = x.length
  ny = y.length
  super(nx, ny, x, y, z, option)
end

.activatewsObject

Activate the specified workstation.



154
155
156
# File 'lib/gr.rb', line 154

def activatews(*)
  super
end

.adjustlimits(amin, amax) ⇒ Object



1213
1214
1215
1216
1217
1218
1219
# File 'lib/gr.rb', line 1213

def adjustlimits(amin, amax)
  inquiry %i[double double] do |pamin, pamax|
    pamin.write_double amin
    pamax.write_double amax
    super(pamin, pamax)
  end
end

.adjustrange(amin, amax) ⇒ Object



1221
1222
1223
1224
1225
1226
1227
# File 'lib/gr.rb', line 1221

def adjustrange(amin, amax)
  inquiry %i[double double] do |pamin, pamax|
    pamin.write_double amin
    pamax.write_double amax
    super(pamin, pamax)
  end
end

.axesObject Also known as: axes2d

Draw X and Y coordinate axes with linearly and/or logarithmically spaced tick marks.



935
936
937
# File 'lib/gr.rb', line 935

def axes(*)
  super
end

.axes3dObject

Draw X, Y and Z coordinate axes with linearly and/or logarithmically spaced tick marks. Tick marks are positioned along each axis so that major tick marks fall on the axes origin (whether visible or not). Major tick marks are labeled with the corresponding data values. Axes are drawn according to the scale of the window. Axes and tick marks are drawn using solid lines; line color and width can be modified using the setlinetype and setlinewidth functions. Axes are drawn according to the linear or logarithmic transformation established by the setscale function.



1064
1065
1066
# File 'lib/gr.rb', line 1064

def axes3d(*)
  super
end

.axeslblObject



941
942
943
# File 'lib/gr.rb', line 941

def axeslbl(*)
  super
end

.barplot(labels, heights, kv = {}) ⇒ Object

(Plot) Draw a bar plot.



1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
# File 'lib/gr/plot.rb', line 1281

def barplot(labels, heights, kv = {})
  labels = labels.map(&:to_s)
  wc, hc = barcoordinates(heights)
  horizontal = kv[:horizontal] || false
  create_plot(:bar, labels, heights, kv) do |plt|
    if horizontal
      plt.args = [[hc, wc, nil, nil, '']]
      plt.kvs[:yticks] = [1, 1]
      plt.kvs[:yticklabels] = labels
    else
      plt.args = [[wc, hc, nil, nil, '']]
      plt.kvs[:xticks] = [1, 1]
      plt.kvs[:xticklabels] = labels
    end
  end
end

.begingraphicsObject

Open a file for graphics output. begingraphics allows to write all graphics output into a XML-formatted file until the endgraphics functions is called. The resulting file may later be imported with the importgraphics function.



1497
1498
1499
# File 'lib/gr.rb', line 1497

def begingraphics(*)
  super
end

.beginprintObject

Open and activate a print device. beginprint opens an additional graphics output device. The device type is obtained from the given file extension.



1243
1244
1245
# File 'lib/gr.rb', line 1243

def beginprint(*)
  super
end

.beginprintextObject

Open and activate a print device with the given layout attributes.



1283
1284
1285
# File 'lib/gr.rb', line 1283

def beginprintext(*)
  super
end

.beginselectionObject



1531
1532
1533
# File 'lib/gr.rb', line 1531

def beginselection(*)
  super
end

.camerainteractionObject

Interface for interaction with the rotation of the model. For this a virtual Arcball is used.



1941
1942
1943
# File 'lib/gr.rb', line 1941

def camerainteraction(*)
  super
end

.cellarray(xmin, xmax, ymin, ymax, dimx, dimy, color) ⇒ Object

Display rasterlike images in a device-independent manner. The cell array function partitions a rectangle given by two corner points into DIMX X DIMY cells, each of them colored individually by the corresponding color index of the given cell array. The values for xmin, xmax, ymin and ymax are in world coordinates.



236
237
238
# File 'lib/gr.rb', line 236

def cellarray(xmin, xmax, ymin, ymax, dimx, dimy, color)
  super(xmin, xmax, ymin, ymax, dimx, dimy, 1, 1, dimx, dimy, int(color))
end

.clearwsObject



168
169
170
# File 'lib/gr.rb', line 168

def clearws(*)
  super
end

.closegksObject



102
103
104
# File 'lib/gr.rb', line 102

def closegks(*)
  super
end

.closesegObject



786
787
788
# File 'lib/gr.rb', line 786

def closeseg(*)
  super
end

.closewsObject

Close the specified workstation.



148
149
150
# File 'lib/gr.rb', line 148

def closews(*)
  super
end

.colorbarObject



1182
1183
1184
# File 'lib/gr.rb', line 1182

def colorbar(*)
  super
end

.configurewsObject



164
165
166
# File 'lib/gr.rb', line 164

def configurews(*)
  super
end

.contour(*args) ⇒ Object

(Plot) Draw a contour plot.



1122
1123
1124
1125
1126
1127
1128
# File 'lib/gr.rb', line 1122

def contour(x, y, h, z, major_h)
  # TODO: check: Arrays have incorrect length or dimension.
  nx = x.length
  ny = y.length
  nh = h.length
  super(nx, ny, nh, x, y, h, z, major_h)
end

.contourf(*args) ⇒ Object

(Plot) Draw a filled contour plot.



1141
1142
1143
1144
1145
1146
1147
# File 'lib/gr.rb', line 1141

def contourf(x, y, h, z, major_h)
  # TODO: check: Arrays have incorrect length or dimension.
  nx = x.length
  ny = y.length
  nh = h.length
  super(nx, ny, nh, x, y, h, z, major_h)
end

.copysegwsObject



774
775
776
# File 'lib/gr.rb', line 774

def copysegws(*)
  super
end

.createsegObject



770
771
772
# File 'lib/gr.rb', line 770

def createseg(*)
  super
end

.deactivatewsObject

Deactivate the specified workstation.



160
161
162
# File 'lib/gr.rb', line 160

def deactivatews(*)
  super
end

.delaunay(x, y) ⇒ Object



1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
# File 'lib/gr.rb', line 1588

def delaunay(x, y)
  # Feel free to make a pull request if you catch a mistake
  # or you have an idea to improve it.
  npoints = equal_length(x, y)
  triangles = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INTPTR_T)
  dim = 3
  n_tri = inquiry_int do |ntri|
    super(npoints, x, y, ntri, triangles.ref)
  end
  if n_tri > 0
    tri = triangles.to_str(3 * n_tri * Fiddle::SIZEOF_INT).unpack('l*') # Int32
    # Ruby  : 0-based indexing
    # Julia : 1-based indexing
    tri = tri.each_slice(3).to_a
    [n_tri, tri]
  else
    0
  end
end

.destroycontextObject



1579
1580
1581
# File 'lib/gr.rb', line 1579

def destroycontext(*)
  super
end

.drawarcObject

Draw a circular or elliptical arc covering the specified rectangle. The resulting arc begins at a1 and ends at a2 degrees. Angles are interpreted such that 0 degrees is at the 3 o’clock position. The center of the arc is the center of the given rectangle.



1344
1345
1346
# File 'lib/gr.rb', line 1344

def drawarc(*)
  super
end

.drawarrowObject

Draw an arrow between two points. Different arrow styles (angles between arrow tail and wing, optionally filled heads, double headed arrows) are available and can be set with the setarrowstyle function.



1419
1420
1421
# File 'lib/gr.rb', line 1419

def drawarrow(*)
  super
end

.drawgraphicsInteger



1511
1512
1513
# File 'lib/gr.rb', line 1511

def drawgraphics(*)
  super
end

.drawimage(xmin, xmax, ymin, ymax, width, height, data, model = 0) ⇒ Object

Draw an image into a given rectangular area. The points (xmin, ymin) and (xmax, ymax) are world coordinates defining diagonally opposite corner points of a rectangle. This rectangle is divided into width by height cells. The two-dimensional array data specifies colors for each cell.



1454
1455
1456
# File 'lib/gr.rb', line 1454

def drawimage(xmin, xmax, ymin, ymax, width, height, data, model = 0)
  super(xmin, xmax, ymin, ymax, width, height, uint(data), model)
end

.drawpath(points, codes, fill) ⇒ Object

Draw simple and compound outlines consisting of line segments and bezier curves.



1372
1373
1374
1375
# File 'lib/gr.rb', line 1372

def drawpath(points, codes, fill)
  len = codes.length
  super(len, points, uint8(codes), fill)
end

.drawrectObject

Draw a rectangle using the current line attributes.



1321
1322
1323
# File 'lib/gr.rb', line 1321

def drawrect(*)
  super
end

.emergencyclosegksObject



790
791
792
# File 'lib/gr.rb', line 790

def emergencyclosegks(*)
  super
end

.endgraphicsObject



1501
1502
1503
# File 'lib/gr.rb', line 1501

def endgraphics(*)
  super
end

.endprintObject



1287
1288
1289
# File 'lib/gr.rb', line 1287

def endprint(*)
  super
end

.endselectionObject



1535
1536
1537
# File 'lib/gr.rb', line 1535

def endselection(*)
  super
end

.fillarcObject

Fill a circular or elliptical arc covering the specified rectangle. The resulting arc begins at a1 and ends at a2 degrees. Angles are interpreted such that 0 degrees is at the 3 o’clock position. The center of the arc is the center of the given rectangle.



1358
1359
1360
# File 'lib/gr.rb', line 1358

def fillarc(*)
  super
end

.fillarea(x, y) ⇒ Object

Allows you to specify a polygonal shape of an area to be filled. The attributes that control the appearance of fill areas are fill area interior style, fill area style index and fill area color index.



218
219
220
221
# File 'lib/gr.rb', line 218

def fillarea(x, y)
  n = equal_length(x, y)
  super(n, x, y)
end

.fillrectObject

Draw a filled rectangle using the current fill attributes.



1330
1331
1332
# File 'lib/gr.rb', line 1330

def fillrect(*)
  super
end

.gdp(x, y, primid, datrec) ⇒ Object

Generates a generalized drawing primitive (GDP) of the type you specify, using specified points and any additional information contained in a data record.



282
283
284
285
286
# File 'lib/gr.rb', line 282

def gdp(x, y, primid, datrec)
  n = equal_length(x, y)
  ldr = datrec.length
  super(n, x, y, primid, ldr, datrec)
end

.getgraphicsString



1506
1507
1508
# File 'lib/gr.rb', line 1506

def getgraphics(*)
  super.to_s
end

.gradient(x, y, z) ⇒ Object

Deprecated.


1627
1628
1629
1630
1631
1632
1633
1634
# File 'lib/gr.rb', line 1627

def gradient(x, y, z)
  # TODO: check: Arrays have incorrect length or dimension.
  nx = x.length
  ny = y.length
  inquiry [{ double: nx * ny }, { double: nx * ny }] do |pu, pv|
    super(nx, ny, x, y, z, pu, pv)
  end
end

.gridObject

Draw a linear and/or logarithmic grid. Major grid lines correspond to the axes origin and major tick marks whether visible or not. Minor grid lines are drawn at points equal to minor tick marks. Major grid lines are drawn using black lines and minor grid lines are drawn using gray lines.



960
961
962
# File 'lib/gr.rb', line 960

def grid(*)
  super
end

.grid3dObject

Draw a linear and/or logarithmic grid. Major grid lines correspond to the axes origin and major tick marks whether visible or not. Minor grid lines are drawn at points equal to minor tick marks. Major grid lines are drawn using black lines and minor grid lines are drawn using gray lines.



984
985
986
# File 'lib/gr.rb', line 984

def grid3d(*)
  super
end

.gridit(xd, yd, zd, nx, ny) ⇒ Object



305
306
307
308
309
310
# File 'lib/gr.rb', line 305

def gridit(xd, yd, zd, nx, ny)
  nd = equal_length(xd, yd, zd)
  inquiry [{ double: nx }, { double: ny }, { double: nx * ny }] do |px, py, pz|
    super(nd, xd, yd, zd, nx, ny, px, py, pz)
  end
end

.heatmap(*args) ⇒ Object

(Plot) Draw a heatmap.



1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
# File 'lib/gr/plot.rb', line 1185

def heatmap(*args)
  # FIXME
  args, kv = format_xyzc(*args)
  _x, _y, z = args
  ysize, xsize = z.shape
  z = z.reshape(xsize, ysize)
  create_plot(:heatmap, kv) do |plt|
    plt.kvs[:xlim] ||= [0.5, xsize + 0.5]
    plt.kvs[:ylim] ||= [0.5, ysize + 0.5]
    plt.args = [[(1..xsize).to_a, (1..ysize).to_a, z, nil, '']]
  end
end

.herrorbars(x, y, e1, e2) ⇒ Object

Draw a standard horizontal error bar graph.



1003
1004
1005
1006
# File 'lib/gr.rb', line 1003

def herrorbars(x, y, e1, e2)
  n = equal_length(x, y, e1, e2)
  super(n, x, y, e1, e2)
end

.hexbin(*args) ⇒ Object

(Plot) Draw a hexagon binning plot.



1157
1158
1159
1160
# File 'lib/gr.rb', line 1157

def hexbin(x, y, nbins)
  n = x.length
  super(n, x, y, nbins)
end

.histogram(x, kv = {}) ⇒ Object

(Plot) Draw a histogram.



1299
1300
1301
1302
1303
1304
1305
# File 'lib/gr/plot.rb', line 1299

def histogram(x, kv = {})
  create_plot(:hist, x, kv) do |plt|
    nbins = plt.kvs[:nbins] || 0
    x, y = hist(x, nbins)
    plt.args = [[x, y, nil, nil, '']]
  end
end

.hold(flag = true) ⇒ Object



1323
1324
1325
1326
# File 'lib/gr/plot.rb', line 1323

def hold(flag = true)
  plt = GR::Plot.last_plot
  plt.kvs.slice(:window, :scale, :xaxis, :yaxis, :zaxis).merge({ ax: flag, clear: !flag })
end

.hsvtorgb(h, s, v) ⇒ Object



1197
1198
1199
1200
1201
# File 'lib/gr.rb', line 1197

def hsvtorgb(h, s, v)
  inquiry %i[double double double] do |r, g, b|
    super(h, s, v, r, g, b)
  end
end

.importgraphicsInteger



1459
1460
1461
# File 'lib/gr.rb', line 1459

def importgraphics(*)
  super
end

.imshow(img, kv = {}) ⇒ Object

(Plot) Draw an image.



1308
1309
1310
1311
1312
1313
# File 'lib/gr/plot.rb', line 1308

def imshow(img, kv = {})
  img = Numo::DFloat.cast(img) # Umm...
  create_plot(:imshow, img, kv) do |plt|
    plt.args = [[nil, nil, img, nil, '']]
  end
end

.initgrObject



94
95
96
# File 'lib/gr.rb', line 94

def initgr(*)
  super
end

.inqbboxObject



1547
1548
1549
1550
1551
# File 'lib/gr.rb', line 1547

def inqbbox
  inquiry %i[double double double double] do |*pts|
    super(*pts)
  end
end

.inqbordercolorindObject



1855
1856
1857
# File 'lib/gr.rb', line 1855

def inqbordercolorind
  inquiry_int { |pt| super(pt) }
end

.inqborderwidthObject



1845
1846
1847
# File 'lib/gr.rb', line 1845

def inqborderwidth
  inquiry_double { |pt| super(pt) }
end

.inqcolor(color) ⇒ Object



1186
1187
1188
1189
1190
# File 'lib/gr.rb', line 1186

def inqcolor(color)
  inquiry_int do |rgb|
    super(color, rgb)
  end
end

.inqcolorfromrgbInteger



1193
1194
1195
# File 'lib/gr.rb', line 1193

def inqcolorfromrgb(*)
  super
end

.inqcolormapObject

inqcolormap



1167
1168
1169
# File 'lib/gr.rb', line 1167

def inqcolormap
  inquiry_int { |pt| super(pt) }
end

.inqdspsizeObject

inqdspsize



107
108
109
110
111
# File 'lib/gr.rb', line 107

def inqdspsize
  inquiry %i[double double int int] do |*pts|
    super(*pts)
  end
end

.inqfillcolorindObject

Returns the current fill area color index.



661
662
663
# File 'lib/gr.rb', line 661

def inqfillcolorind
  inquiry_int { |pt| super(pt) }
end

.inqfillintstyleObject

Returns the fill area interior style to be used for fill areas.



632
633
634
# File 'lib/gr.rb', line 632

def inqfillintstyle
  inquiry_int { |pt| super(pt) }
end

.inqfillstyleObject

Returns the current fill area color index.



648
649
650
# File 'lib/gr.rb', line 648

def inqfillstyle
  inquiry_int { |pt| super(pt) }
end

.inqlinecolorindObject

inqlinecolorind



367
368
369
# File 'lib/gr.rb', line 367

def inqlinecolorind
  inquiry_int { |pt| super(pt) }
end

.inqlinetypeObject



342
343
344
# File 'lib/gr.rb', line 342

def inqlinetype
  inquiry_int { |pt| super(pt) }
end

.inqlinewidthObject



356
357
358
# File 'lib/gr.rb', line 356

def inqlinewidth
  inquiry_double { |pt| super(pt) }
end

.inqmarkercolorindObject



475
476
477
# File 'lib/gr.rb', line 475

def inqmarkercolorind
  inquiry_int { |pt| super(pt) }
end

.inqmarkersizeObject

Inquire the marker size for polymarkers.



465
466
467
# File 'lib/gr.rb', line 465

def inqmarkersize
  inquiry_double { |pt| super(pt) }
end

.inqmarkertypeObject



452
453
454
# File 'lib/gr.rb', line 452

def inqmarkertype
  inquiry_int { |pt| super(pt) }
end

.inqmathtex(x, y, string) ⇒ Object

inqmathtex



1525
1526
1527
1528
1529
# File 'lib/gr.rb', line 1525

def inqmathtex(x, y, string)
  inquiry [{ double: 4 }, { double: 4 }] do |tbx, tby|
    super(x, y, string, tbx, tby)
  end
end

.inqorthographicprojectionObject

Return the camera position, up vector and focus point.



1929
1930
1931
1932
1933
# File 'lib/gr.rb', line 1929

def inqorthographicprojection
  inquiry([:double] * 6) do |*pts|
    super(*pts)
  end
end

.inqperspectiveprojectionObject

Return the parameters for the perspective projection.



1910
1911
1912
1913
1914
# File 'lib/gr.rb', line 1910

def inqperspectiveprojection
  inquiry %i[double double double] do |*pts|
    super(*pts)
  end
end

.inqprojectiontypeObject

Return the projection type.



1873
1874
1875
# File 'lib/gr.rb', line 1873

def inqprojectiontype
  inquiry_int { |pt| super(pt) }
end

.inqregenflagsInteger



1563
1564
1565
# File 'lib/gr.rb', line 1563

def inqregenflags(*)
  super
end

.inqresamplemethodObject

Inquire the resample method used for gr.drawimage().



1802
1803
1804
1805
1806
# File 'lib/gr.rb', line 1802

def inqresamplemethod
  inquiry_uint do |resample_method|
    super(resample_method)
  end
end

.inqscaleObject

inqscale



850
851
852
# File 'lib/gr.rb', line 850

def inqscale
  inquiry_int { |pt| super(pt) }
end

.inqscalefactors3dObject

Returns the scale factors for each axis.



1973
1974
1975
1976
1977
# File 'lib/gr.rb', line 1973

def inqscalefactors3d
  inquiry %i[double double double] do |*opts|
    super(*opts)
  end
end

.inqspaceObject



815
816
817
818
819
# File 'lib/gr.rb', line 815

def inqspace
  inquiry %i[double double int int] do |*pts|
    super(*pts)
  end
end

.inqtext(x, y, string) ⇒ Object



206
207
208
209
210
# File 'lib/gr.rb', line 206

def inqtext(x, y, string)
  inquiry [{ double: 4 }, { double: 4 }] do |tbx, tby|
    super(x, y, string, tbx, tby)
  end
end

.inqtext3d(x, y, z, string, axis) ⇒ Object



1999
2000
2001
2002
2003
# File 'lib/gr.rb', line 1999

def inqtext3d(x, y, z, string, axis)
  inquiry [{ double: 16 }, { double: 16 }] do |tbx, tby|
    super(x, y, z, string, axis, tbx, tby)
  end
end

.inqtextcolorindInteger

Gets the current text color index. This function gets the color of text output primitives.



551
552
553
# File 'lib/gr.rb', line 551

def inqtextcolorind
  inquiry_int { |pt| super(pt) }
end

.inqtextencodingObject



2009
2010
2011
2012
2013
# File 'lib/gr.rb', line 2009

def inqtextencoding
  inquiry_int do |encoding|
    super(encoding)
  end
end

.inqtextext(x, y, string) ⇒ Object

inqtextext



911
912
913
914
915
# File 'lib/gr.rb', line 911

def inqtextext(x, y, string)
  inquiry [{ double: 4 }, { double: 4 }] do |tbx, tby|
    super(x, y, string, tbx, tby)
  end
end

.inqtransformationparametersObject

Return the camera position, up vector and focus point.



1893
1894
1895
1896
1897
# File 'lib/gr.rb', line 1893

def inqtransformationparameters
  inquiry([:double] * 9) do |*pts|
    super(*pts)
  end
end

.inqviewportObject

inqviewport



715
716
717
718
719
# File 'lib/gr.rb', line 715

def inqviewport
  inquiry %i[double double double double] do |*pts|
    super(*pts)
  end
end

.inqwindowObject

inqwindow



693
694
695
696
697
# File 'lib/gr.rb', line 693

def inqwindow
  inquiry %i[double double double double] do |*pts|
    super(*pts)
  end
end

.inqwindow3dObject

Return the three dimensional window.



1957
1958
1959
1960
1961
# File 'lib/gr.rb', line 1957

def inqwindow3d
  inquiry([:double] * 6) do |*pts|
    super(*pts)
  end
end

.interp2(x, y, z, xq, yq, method, extrapval) ⇒ Object

Interpolation in two dimensions using one of four different methods. The input points are located on a grid, described by x, y and z. The target grid ist described by xq and yq. Returns an array containing the resulting z-values.



1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
# File 'lib/gr.rb', line 1674

def interp2(x, y, z, xq, yq, method, extrapval) # flatten
  nx = x.length
  ny = y.length
  # nz = z.length
  nxq = xq.length
  nyq = yq.length
  inquiry(double: nxq * nyq) do |zq|
    super(nx, ny, x, y, z, nxq, nyq, xq, yq, zq, method, extrapval)
  end
end

.isosurface(v, kv = {}) ⇒ Object

(Plot) Draw an isosurface.



1316
1317
1318
1319
1320
1321
# File 'lib/gr/plot.rb', line 1316

def isosurface(v, kv = {})
  v = Numo::DFloat.cast(v) # Umm...
  create_plot(:isosurface, v, kv) do |plt|
    plt.args = [[nil, nil, v, nil, '']]
  end
end

.mathtexObject

Generate a character string starting at the given location. Strings can be defined to create mathematical symbols and Greek letters using LaTeX syntax.



1520
1521
1522
# File 'lib/gr.rb', line 1520

def mathtex(*)
  super
end

.moveselectionObject



1539
1540
1541
# File 'lib/gr.rb', line 1539

def moveselection(*)
  super
end

.ndctowc(x, y) ⇒ Object



1291
1292
1293
1294
1295
1296
1297
# File 'lib/gr.rb', line 1291

def ndctowc(x, y)
  inquiry %i[double double] do |px, py|
    px.write_double x
    py.write_double y
    super(px, py)
  end
end

.nonuniformcellarray(x, y, dimx, dimy, color) ⇒ Object

Display a two dimensional color index array with nonuniform cell sizes. The values for x and y are in world coordinates. x must contain dimx + 1 elements and y must contain dimy + 1 elements. The elements i and i+1 are respectively the edges of the i-th cell in X and Y direction.

Raises:

  • (ArgumentError)


249
250
251
252
253
# File 'lib/gr.rb', line 249

def nonuniformcellarray(x, y, dimx, dimy, color)
  raise ArgumentError unless x.length == dimx + 1 && y.length == dimy + 1

  super(x, y, dimx, dimy, 1, 1, dimx, dimy, int(color))
end

.opengksObject



98
99
100
# File 'lib/gr.rb', line 98

def opengks(*)
  super
end

.openwsObject

Open a graphical workstation.



142
143
144
# File 'lib/gr.rb', line 142

def openws(*)
  super
end

.panzoom(x, y, zoom) ⇒ Object

panzoom



1747
1748
1749
1750
1751
# File 'lib/gr.rb', line 1747

def panzoom(x, y, zoom)
  inquiry %i[double double double double] do |xmin, xmax, ymin, ymax|
    super(x, y, zoom, zoom, xmin, xmax, ymin, ymax)
  end
end

.path(x, y, codes) ⇒ Object

Draw paths using the given vertices and path codes. See gr-framework.org/python-gr.html#gr.path for more details.



1834
1835
1836
1837
# File 'lib/gr.rb', line 1834

def path(x, y, codes)
  n = equal_length(x, y)
  super(n, x, y, codes)
end

.plot(*args) ⇒ Object

(Plot) Draw one or more line plots.



1155
1156
1157
# File 'lib/gr/plot.rb', line 1155

def plot(*args)
  create_plot(:line, *args)
end

.plot3(*args) ⇒ Object

(Plot) Draw one or more three-dimensional line plots.



1258
1259
1260
# File 'lib/gr/plot.rb', line 1258

def plot3(*args)
  create_plot(:plot3, *args)
end

.polar(*args) ⇒ Object

(Plot)



1248
1249
1250
# File 'lib/gr/plot.rb', line 1248

def polar(*args)
  create_plot(:polar, *args)
end

.polarcellarray(x_org, y_org, phimin, phimax, rmin, rmax, dimphi, dimr, color) ⇒ Object

Display a two dimensional color index array mapped to a disk using polar coordinates. The two dimensional color index array is mapped to the resulting image by interpreting the X-axis of the array as the angle and the Y-axis as the raidus. The center point of the resulting disk is located at xorg, yorg and the radius of the disk is rmax.



271
272
273
# File 'lib/gr.rb', line 271

def polarcellarray(x_org, y_org, phimin, phimax, rmin, rmax, dimphi, dimr, color)
  super(x_org, y_org, phimin, phimax, rmin, rmax, dimphi, dimr, 1, 1, dimphi, dimr, int(color))
end

.polarheatmap(*args) ⇒ Object

(Plot) Draw a polarheatmap.



1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
# File 'lib/gr/plot.rb', line 1199

def polarheatmap(*args)
  d = args.shift
  # FIXME
  z = Numo::DFloat.cast(d)
  raise 'expected 2-D array' unless z.ndim == 2

  create_plot(:polarheatmap, z, *args) do |plt|
    width, height = z.shape
    plt.kvs[:xlim] ||= [0.5, width + 0.5]
    plt.kvs[:ylim] ||= [0.5, height + 0.5]
    plt.args = [[(1..width).to_a, (1..height).to_a, z, nil, '']]
  end
end

.polarhistogram(x, kv = {}) ⇒ Object

(Plot)



1175
1176
1177
1178
1179
1180
1181
1182
# File 'lib/gr/plot.rb', line 1175

def polarhistogram(x, kv = {})
  plt = GR::Plot.new(x, kv)
  plt.kvs[:kind] = :polarhist
  nbins = plt.kvs[:nbins] || 0
  x, y = hist(x, nbins)
  plt.args = [[x, y, nil, nil, '']]
  plt.plot_data
end

.polyline(x, y) ⇒ Object

Draw a polyline using the current line attributes, starting from the first data point and ending at the last data point.



180
181
182
183
# File 'lib/gr.rb', line 180

def polyline(x, y)
  n = equal_length(x, y)
  super(n, x, y)
end

.polyline3d(x, y, z) ⇒ Object

Draw a 3D curve using the current line attributes, starting from the first data point and ending at the last data point. The values for x, y and z are in world coordinates. The attributes that control the appearance of a polyline are linetype, linewidth and color index.



1016
1017
1018
1019
# File 'lib/gr.rb', line 1016

def polyline3d(x, y, z)
  n = equal_length(x, y, z)
  super(n, x, y, z)
end

.polymarker(x, y) ⇒ Object

Draw marker symbols centered at the given data points.



188
189
190
191
# File 'lib/gr.rb', line 188

def polymarker(x, y)
  n = equal_length(x, y)
  super(n, x, y)
end

.polymarker3d(x, y, z) ⇒ Object

Draw marker symbols centered at the given 3D data points. The values for x, y and z are in world coordinates. The attributes that control the appearance of a polymarker are marker type, marker size scale factor and color index.



1028
1029
1030
1031
# File 'lib/gr.rb', line 1028

def polymarker3d(x, y, z)
  n = equal_length(x, y, z)
  super(n, x, y, z)
end

.precisionNumeric



1554
1555
1556
# File 'lib/gr.rb', line 1554

def precision(*)
  super
end

.quiver(x, y, u, v, color) ⇒ Object

Draw a quiver plot on a grid of nx*ny points. The values for x and y are in world coordinates.



1647
1648
1649
1650
1651
1652
# File 'lib/gr.rb', line 1647

def quiver(x, y, u, v, color)
  # TODO: check: Arrays have incorrect length or dimension.
  nx = x.length
  ny = y.length
  super(nx, ny, x, y, u, v, (color ? 1 : 0))
end

.readimage(path) ⇒ Integer



1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
# File 'lib/gr.rb', line 1424

def readimage(path)
  # Feel free to make a pull request if you catch a mistake
  # or you have an idea to improve it.
  data = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INTPTR_T)
  w, h = inquiry [:int, :int] do |width, height|
    # data is a pointer of a pointer
    super(path, width, height, data.ref)
  end
  d = data.to_str(w * h * Fiddle::SIZEOF_INT).unpack('L*') # UInt32
  [w, h, d]
end

.redrawsegwsObject



778
779
780
# File 'lib/gr.rb', line 778

def redrawsegws(*)
  super
end

.reducepoints(xd, yd, n) ⇒ Object

Reduces the number of points of the x and y array.



1609
1610
1611
1612
1613
1614
1615
# File 'lib/gr.rb', line 1609

def reducepoints(xd, yd, n)
  nd = equal_length(xd, yd)
  inquiry [{ double: n }, { double: n }] do |x, y|
    # Different from Julia. x, y are initialized zero.
    super(nd, xd, yd, n, x, y)
  end
end

.resizeselectionObject



1543
1544
1545
# File 'lib/gr.rb', line 1543

def resizeselection(*)
  super
end

.restorestateObject



1571
1572
1573
# File 'lib/gr.rb', line 1571

def restorestate(*)
  super
end

.savefig(filename, kv = {}) ⇒ Object

(Plot) Save the current figure to a file.



1351
1352
1353
1354
1355
1356
1357
# File 'lib/gr/plot.rb', line 1351

def savefig(filename, kv = {})
  GR.beginprint(filename)
  plt = GR::Plot.last_plot
  plt.kvs.merge!(kv)
  plt.plot_data(false)
  GR.endprint
end

.savestateObject



1567
1568
1569
# File 'lib/gr.rb', line 1567

def savestate(*)
  super
end

.scatter(*args) ⇒ Object

(Plot) Draw one or more scatter plots.



1165
1166
1167
# File 'lib/gr/plot.rb', line 1165

def scatter(*args)
  create_plot(:scatter, *args)
end

.scatter3(*args) ⇒ Object

(Plot) Draw one or more three-dimensional scatter plots.



1263
1264
1265
# File 'lib/gr/plot.rb', line 1263

def scatter3(*args)
  create_plot(:scatter3, *args)
end

.selectcontextObject



1575
1576
1577
# File 'lib/gr.rb', line 1575

def selectcontext(*)
  super
end

.selntranObject

selntran selects a predefined transformation from world coordinates to normalized device coordinates.



726
727
728
# File 'lib/gr.rb', line 726

def selntran(*)
  super
end

.setarrowsizeObject

Set the arrow size to be used for subsequent arrow commands. setarrowsize defines the arrow size for subsequent arrow primitives. The default arrow size is 1.



1407
1408
1409
# File 'lib/gr.rb', line 1407

def setarrowsize(*)
  super
end

.setarrowstyleObject

Set the arrow style to be used for subsequent arrow commands. setarrowstyle defines the arrow style for subsequent arrow primitives.



1399
1400
1401
# File 'lib/gr.rb', line 1399

def setarrowstyle(*)
  super
end

.setbordercolorindObject

Define the color of subsequent path output primitives.



1851
1852
1853
# File 'lib/gr.rb', line 1851

def setbordercolorind(*)
  super
end

.setborderwidthObject

Define the border width of subsequent path output primitives.



1841
1842
1843
# File 'lib/gr.rb', line 1841

def setborderwidth(*)
  super
end

.setcharexpanObject

Set the current character expansion factor (width to height ratio). setcharexpan defines the width of subsequent text output primitives. The expansion factor alters the width of the generated characters, but not their height. The default text expansion factor is 1, or one times the normal width-to-height ratio of the text.



532
533
534
# File 'lib/gr.rb', line 532

def setcharexpan(*)
  super
end

.setcharheightObject

Set the current character height. setcharheight defines the height of subsequent text output primitives. Text height is defined as a percentage of the default window. GR uses the default text height of 0.027 (2.7% of the height of the default window).



560
561
562
# File 'lib/gr.rb', line 560

def setcharheight(*)
  super
end

.setcharspaceObject



536
537
538
# File 'lib/gr.rb', line 536

def setcharspace(*)
  super
end

.setcharupObject

Set the current character text angle up vector. setcharup defines the vertical rotation of subsequent text output primitives. The text up vector is initially set to (0, 1), horizontal to the baseline.



569
570
571
# File 'lib/gr.rb', line 569

def setcharup(*)
  super
end

.setclipObject

Set the clipping indicator.

  • 0 : Clipping is off. Data outside of the window will be drawn.

  • 1 : Clipping is on. Data outside of the window will not be drawn.

setclip enables or disables clipping of the image drawn in the current window. Clipping is defined as the removal of those portions of the graph that lie outside of the defined viewport. If clipping is on, GR does not draw generated output primitives past the viewport boundaries. If clipping is off, primitives may exceed the viewport boundaries, and they will be drawn to the edge of the workstation window. By default, clipping is on.



740
741
742
# File 'lib/gr.rb', line 740

def setclip(*)
  super
end

.setcolormapObject



1162
1163
1164
# File 'lib/gr.rb', line 1162

def setcolormap(*)
  super
end

.setcolormapfromrgb(r, g, b, positions: nil) ⇒ Object

TODO: GR.jl python-gr different API



1172
1173
1174
1175
1176
1177
1178
1179
1180
# File 'lib/gr.rb', line 1172

def setcolormapfromrgb(r, g, b, positions: nil)
  n = equal_length(r, g, b)
  if positions.nil?
    positions = Fiddle::NULL
  elsif positions.length != n
    raise
  end
  super(n, r, g, b, positions)
end

.setcolorrepObject

setcolorrep allows to redefine an existing color index representation by specifying an RGB color triplet.



671
672
673
# File 'lib/gr.rb', line 671

def setcolorrep(*)
  super
end

.setcoordxform(mat) ⇒ Object

Change the coordinate transformation according to the given matrix.



1486
1487
1488
1489
1490
# File 'lib/gr.rb', line 1486

def setcoordxform(mat)
  raise if mat.size != 6

  super(mat)
end

.setfillcolorindObject

Sets the current fill area color index. setfillcolorind defines the color of subsequent fill area output primitives. GR uses the default foreground color (black=1) for the default fill area color index.



656
657
658
# File 'lib/gr.rb', line 656

def setfillcolorind(*)
  super
end

.setfillintstyleObject

Set the fill area interior style to be used for fill areas. setfillintstyle defines the interior style for subsequent fill area output primitives. The default interior style is HOLLOW.



627
628
629
# File 'lib/gr.rb', line 627

def setfillintstyle(*)
  super
end

.setfillstyleObject

Sets the fill style to be used for subsequent fill areas. setfillstyle specifies an index when PATTERN fill or HATCH fill is requested by the setfillintstyle function. If the interior style is set to PATTERN, the fill style index points to a device-independent pattern table. If interior style is set to HATCH the fill style index indicates different hatch styles. If HOLLOW or SOLID is specified for the interior style, the fill style index is unused.



643
644
645
# File 'lib/gr.rb', line 643

def setfillstyle(*)
  super
end

.setlinecolorindObject

Define the color of subsequent polyline output primitives.



362
363
364
# File 'lib/gr.rb', line 362

def setlinecolorind(*)
  super
end

.setlinetypeObject

Specify the line style for polylines.



338
339
340
# File 'lib/gr.rb', line 338

def setlinetype(*)
  super
end

.setlinewidthObject

Define the line width of subsequent polyline output primitives. The line width is calculated as the nominal line width generated on the workstation multiplied by the line width scale factor. This value is mapped by the workstation to the nearest available line width. The default line width is 1.0, or 1 times the line width generated on the graphics device.



352
353
354
# File 'lib/gr.rb', line 352

def setlinewidth(*)
  super
end

.setmarkercolorindObject

Define the color of subsequent polymarker output primitives.



471
472
473
# File 'lib/gr.rb', line 471

def setmarkercolorind(*)
  super
end

.setmarkersizeObject

Specify the marker size for polymarkers. The polymarker size is calculated as the nominal size generated on the graphics device multiplied by the marker size scale factor.



460
461
462
# File 'lib/gr.rb', line 460

def setmarkersize(*)
  super
end

.setmarkertypeObject

Specifiy the marker type for polymarkers. Polymarkers appear centered over their specified coordinates.



448
449
450
# File 'lib/gr.rb', line 448

def setmarkertype(*)
  super
end

.setorthographicprojectionObject

Set parameters for orthographic transformation. Switches projection type to orthographic.



1924
1925
1926
# File 'lib/gr.rb', line 1924

def setorthographicprojection(*)
  super
end

.setperspectiveprojectionObject

Set the far and near clipping plane for perspective projection and the vertical field ov view. Switches projection type to perspective.



1905
1906
1907
# File 'lib/gr.rb', line 1905

def setperspectiveprojection(*)
  super
end

.setprojectiontypeObject

Set the projection type with this flag.



1868
1869
1870
# File 'lib/gr.rb', line 1868

def setprojectiontype(*)
  super
end

.setregenflagsObject



1558
1559
1560
# File 'lib/gr.rb', line 1558

def setregenflags(*)
  super
end

.setresamplemethodObject

Set the resample method used for gr.drawimage().



1797
1798
1799
# File 'lib/gr.rb', line 1797

def setresamplemethod(*)
  super
end

.setscaleInteger

setscale sets the type of transformation to be used for subsequent GR output primitives. setscale defines the current transformation according to the given scale specification which may be or’ed together using any of the above options. GR uses these options for all subsequent output primitives until another value is provided. The scale options are used to transform points from an abstract logarithmic or semi-logarithmic coordinate system, which may be flipped along each axis, into the world coordinate system. Note: When applying a logarithmic transformation to a specific axis, the system assumes that the axes limits are greater than zero.



845
846
847
# File 'lib/gr.rb', line 845

def setscale(*)
  super
end

.setscalefactors3dObject

Set the scale factor for each axis. A one means no scale. All factor have to be != 0.



1968
1969
1970
# File 'lib/gr.rb', line 1968

def setscalefactors3d(*)
  super
end

.setsegtranObject



782
783
784
# File 'lib/gr.rb', line 782

def setsegtran(*)
  super
end

.setshadowObject

setshadow allows drawing of shadows, realized by images painted underneath, and offset from, graphics objects such that the shadow mimics the effect of a light source cast on the graphics objects.



1474
1475
1476
# File 'lib/gr.rb', line 1474

def setshadow(*)
  super
end

.setspaceInteger

Set the abstract Z-space used for mapping three-dimensional output primitives into the current world coordinate space. setspace establishes the limits of an abstract Z-axis and defines the angles for rotation and for the viewing angle (tilt) of a simulated three-dimensional graph, used for mapping corresponding output primitives into the current window. These settings are used for all subsequent three-dimensional output primitives until other values are specified. Angles of rotation and viewing angle must be specified between 0° and 90°.



811
812
813
# File 'lib/gr.rb', line 811

def setspace(*)
  super
end

.setspace3dObject

Set the camera for orthographic or perspective projection. The center of the 3d window is used as the focus point and the camera is positioned relative to it, using camera distance, rotation and tilt similar to gr_setspace. This function can be used if the user prefers spherical coordinates to setting the camera position directly, but has reduced functionality in comparison to GR.settransformationparameters, GR.setperspectiveprojection and GR.setorthographicprojection.



1991
1992
1993
# File 'lib/gr.rb', line 1991

def setspace3d(*)
  super
end

.settextalignObject

Set the current horizontal and vertical alignment for text. settextalign specifies how the characters in a text primitive will be aligned in horizontal and vertical space. The default text alignment indicates horizontal left alignment and vertical baseline alignment.



611
612
613
# File 'lib/gr.rb', line 611

def settextalign(*)
  super
end

.settextcolorindObject

Sets the current text color index. settextcolorind defines the color of subsequent text output primitives. GR uses the default foreground color (black=1) for the default text color index.



544
545
546
# File 'lib/gr.rb', line 544

def settextcolorind(*)
  super
end

.settextencodingObject



2005
2006
2007
# File 'lib/gr.rb', line 2005

def settextencoding(*)
  super
end

.settextfontprecObject

Specify the text font and precision for subsequent text output primitives. The appearance of a font depends on the text precision value specified. STRING, CHARACTER or STROKE precision allows for a greater or lesser realization of the text primitives, for efficiency. STRING is the default precision for GR and produces the highest quality output.



523
524
525
# File 'lib/gr.rb', line 523

def settextfontprec(*)
  super
end

.settextpathObject

Define the current direction in which subsequent text will be drawn.



583
584
585
# File 'lib/gr.rb', line 583

def settextpath(*)
  super
end

.settransformationparametersObject

Method to set the camera position, the upward facing direction and the focus point of the shown volume.



1888
1889
1890
# File 'lib/gr.rb', line 1888

def settransformationparameters(*)
  super
end

.settransparencyObject

Set the value of the alpha component associated with GR colors.



1480
1481
1482
# File 'lib/gr.rb', line 1480

def settransparency(*)
  super
end

.setviewportObject

setviewport establishes a rectangular subspace of normalized device coordinates. setviewport defines the rectangular portion of the Normalized Device Coordinate (NDC) space to be associated with the specified normalization transformation. The NDC viewport and World Coordinate (WC) window define the normalization transformation through which all output primitives pass. The WC window is mapped onto the rectangular NDC viewport which is, in turn, mapped onto the display surface of the open and active workstation, in device coordinates.



710
711
712
# File 'lib/gr.rb', line 710

def setviewport(*)
  super
end

.setwindowObject

setwindow establishes a window, or rectangular subspace, of world coordinates to be plotted. If you desire log scaling or mirror-imaging of axes, use the SETSCALE function. setwindow defines the rectangular portion of the World Coordinate space (WC) to be associated with the specified normalization transformation. The WC window and the Normalized Device Coordinates (NDC) viewport define the normalization transformation through which all output primitives are mapped. The WC window is mapped onto the rectangular NDC viewport which is, in turn, mapped onto the display surface of the open and active workstation, in device coordinates. By default, GR uses the range [0,1] x [0,1], in world coordinates, as the normalization transformation window.



688
689
690
# File 'lib/gr.rb', line 688

def setwindow(*)
  super
end

.setwindow3dObject

Set the three dimensional window. Only used for perspective and orthographic projection.



1952
1953
1954
# File 'lib/gr.rb', line 1952

def setwindow3d(*)
  super
end

.setwsviewportObject

Define the size of the workstation graphics window in meters. setwsviewport places a workstation window on the display of the specified size in meters. This command allows the workstation window to be accurately sized for a display or hardcopy device, and is often useful for sizing graphs for desktop publishing applications.



766
767
768
# File 'lib/gr.rb', line 766

def setwsviewport(*)
  super
end

.setwswindowObject

Set the area of the NDC viewport that is to be drawn in the workstation window. setwswindow defines the rectangular area of the Normalized Device Coordinate space to be output to the device. By default, the workstation transformation will map the range [0,1] x [0,1] in NDC onto the largest square on the workstation’s display surface. The aspect ratio of the workstation window is maintained at 1 to 1.



753
754
755
# File 'lib/gr.rb', line 753

def setwswindow(*)
  super
end

.shade(*args) ⇒ Object

(Plot)



1269
1270
1271
# File 'lib/gr/plot.rb', line 1269

def shade(*)
  super
end

.shadelines(x, y, dims: [1200, 1200], xform: 1) ⇒ Object

Display a line set as an aggregated and rasterized image. The values for x and y are in world coordinates. NaN values can be used to separate the point set into line segments.



1740
1741
1742
1743
1744
# File 'lib/gr.rb', line 1740

def shadelines(x, y, dims: [1200, 1200], xform: 1)
  n = x.length
  w, h = dims
  super(n, x, y, xform, w, h)
end

.shadepoints(x, y, dims: [1200, 1200], xform: 1) ⇒ Object

Display a point set as a aggregated and rasterized image. The values for x and y are in world coordinates.



1714
1715
1716
1717
1718
# File 'lib/gr.rb', line 1714

def shadepoints(x, y, dims: [1200, 1200], xform: 1)
  n = x.length
  w, h = dims
  super(n, x, y, xform, w, h)
end

.spline(x, y, m, method) ⇒ Object

Generate a cubic spline-fit, starting from the first data point and ending at the last data point. The values for x and y are in world coordinates. The attributes that control the appearance of a spline-fit are linetype, linewidth and color index.



300
301
302
303
# File 'lib/gr.rb', line 300

def spline(x, y, m, method)
  n = equal_length(x, y)
  super(n, x, y, m, method)
end

.stem(*args) ⇒ Object

(Plot) Draw a stem plot.



1170
1171
1172
# File 'lib/gr/plot.rb', line 1170

def stem(*args)
  create_plot(:stem, *args)
end

.step(*args) ⇒ Object

(Plot) Draw one or more step or staircase plots.



1160
1161
1162
# File 'lib/gr/plot.rb', line 1160

def step(*args)
  create_plot(:step, *args)
end

.subplot(nr, nc, p) ⇒ Object

Set current subplot index.



1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
# File 'lib/gr/plot.rb', line 1329

def subplot(nr, nc, p)
  xmin = 1
  xmax = 0
  ymin = 1
  ymax = 0
  p = [p] if p.is_a? Integer
  p.each do |i|
    r = (nr - (i - 1) / nc).to_f
    c = ((i - 1) % nc + 1).to_f
    xmin = [xmin, (c - 1) / nc].min
    xmax = [xmax, c / nc].max
    ymin = [ymin, (r - 1) / nr].min
    ymax = [ymax, r / nr].max
  end
  {
    subplot: [xmin, xmax, ymin, ymax],
    clear: p[0] == 1,
    update: p[-1] == nr * nc
  }
end

.surface(*args) ⇒ Object

Draw a three-dimensional surface plot for the given data points. x and y define a grid. z is a singly dimensioned array containing at least nx * ny data points. Z describes the surface height at each point on the grid. Data is ordered as shown in the table:



1100
1101
1102
1103
1104
1105
# File 'lib/gr.rb', line 1100

def surface(x, y, z, option)
  # TODO: check: Arrays have incorrect length or dimension.
  nx = x.length
  ny = y.length
  super(nx, ny, x, y, z, option)
end

.textObject

Draw a text at position x, y using the current text attributes. The values for x and y are in normalized device coordinates. The attributes that control the appearance of text are text font and precision, character expansion factor, character spacing, text color index, character height, character up vector, text path and text alignment.



202
203
204
# File 'lib/gr.rb', line 202

def text(*)
  super
end

.text3dObject



1995
1996
1997
# File 'lib/gr.rb', line 1995

def text3d(*)
  super
end

.textextInteger

Draw a text at position x, y using the current text attributes. Strings can be defined to create basic mathematical expressions and Greek letters. The values for X and Y are in normalized device coordinates. The attributes that control the appearance of text are text font and precision, character expansion factor, character spacing, text color index, character height, character up vector, text path and text alignment.

The character string is interpreted to be a simple mathematical formula. The following notations apply:

Subscripts and superscripts: These are indicated by carets (‘^’) and underscores (‘_’). If the sub/superscript contains more than one character, it must be enclosed in curly braces (‘{}’).

Fractions are typeset with A ‘/’ B, where A stands for the numerator and B for the denominator.

To include a Greek letter you must specify the corresponding keyword after a backslash (‘') character. The text translator produces uppercase or lowercase Greek letters depending on the case of the keyword.

* Α α - alpha
* Β β - beta
* Γ γ - gamma
* Δ δ - delta
* Ε ε - epsilon
* Ζ ζ - zeta
* Η η - eta
* Θ θ - theta
* Ι ι - iota
* Κ κ - kappa
* Λ λ - lambda
* Μ μ - mu
* Ν ν - Nu / v
* Ξ ξ - xi
* Ο ο - omicron
* Π π - pi
* Ρ ρ - rho
* Σ σ - sigma
* Τ τ - tau
* Υ υ - upsilon
* Φ φ - phi
* Χ χ - chi
* Ψ ψ - psi
* Ω ω - omega

Note: \v is a replacement for \nu which would conflict with \n (newline) For more sophisticated mathematical formulas, you should use the gr.mathtex function.



906
907
908
# File 'lib/gr.rb', line 906

def textext(*)
  super
end

.tickNumeric



1204
1205
1206
# File 'lib/gr.rb', line 1204

def tick(*)
  super
end

.titles3dObject

Display axis titles just outside of their respective axes.



1072
1073
1074
# File 'lib/gr.rb', line 1072

def titles3d(*)
  super
end

.tricont(*args) ⇒ Object

(Plot) Draw a triangular contour plot.



1232
1233
1234
# File 'lib/gr/plot.rb', line 1232

def tricont(*args)
  create_plot(:tricont, *format_xyzc(*args))
end

.tricontour(x, y, z, levels) ⇒ Object

Draw a contour plot for the given triangle mesh.



1150
1151
1152
1153
1154
# File 'lib/gr.rb', line 1150

def tricontour(x, y, z, levels)
  npoints = x.length # equal_length ?
  nlevels = levels.length
  super(npoints, x, y, z, nlevels, levels)
end

.trisurf(*args) ⇒ Object

(Plot) Draw a triangular surface plot.



1253
1254
1255
# File 'lib/gr/plot.rb', line 1253

def trisurf(*args)
  create_plot(:trisurf, *format_xyzc(*args))
end

.trisurface(x, y, z) ⇒ Object

Draw a triangular surface plot for the given data points.



1621
1622
1623
1624
# File 'lib/gr.rb', line 1621

def trisurface(x, y, z)
  n = [x, y, z].map(&:length).min
  super(n, x, y, z)
end

.updategksObject



794
795
796
# File 'lib/gr.rb', line 794

def updategks(*)
  super
end

.updatewsObject



172
173
174
# File 'lib/gr.rb', line 172

def updatews(*)
  super
end

.uselinespecInteger



1584
1585
1586
# File 'lib/gr.rb', line 1584

def uselinespec(*)
  super
end

.validaterangeInteger



1209
1210
1211
# File 'lib/gr.rb', line 1209

def validaterange(*)
  super
end

.verrorbars(x, y, e1, e2) ⇒ Object

Draw a standard vertical error bar graph.



993
994
995
996
# File 'lib/gr.rb', line 993

def verrorbars(x, y, e1, e2)
  n = equal_length(x, y, e1, e2)
  super(n, x, y, e1, e2)
end

.versionString

Returns the combined version strings of the GR runtime.



1687
1688
1689
# File 'lib/gr.rb', line 1687

def version
  super.to_s
end

.volume(v, kv = {}) ⇒ Object

(Plot)



1274
1275
1276
1277
1278
# File 'lib/gr/plot.rb', line 1274

def volume(v, kv = {})
  create_plot(:volume, v, kv) do |plt|
    plt.args = [[nil, nil, v, nil, '']]
  end
end

.wc3towc(x, y, z) ⇒ Object



1307
1308
1309
1310
1311
1312
1313
1314
# File 'lib/gr.rb', line 1307

def wc3towc(x, y, z)
  inquiry %i[double double double] do |px, py, pz|
    px.write_double x
    py.write_double y
    pz.write_double z
    super(px, py, pz)
  end
end

.wctondc(x, y) ⇒ Object



1299
1300
1301
1302
1303
1304
1305
# File 'lib/gr.rb', line 1299

def wctondc(x, y)
  inquiry %i[double double] do |px, py|
    px.write_double x
    py.write_double y
    super(px, py)
  end
end

.wireframe(*args) ⇒ Object

(Plot) Draw a three-dimensional wireframe plot.



1237
1238
1239
# File 'lib/gr/plot.rb', line 1237

def wireframe(*args)
  create_plot(:wireframe, *format_xyzc(*args))
end