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,
lib/gr_commons/gr_logger.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, GRAxis, GRTick, GRTickLabel, NotFoundError, 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
AXES_SIMPLE_AXES =
1
AXES_TWIN_AXES =
2
AXES_WITH_GRID =
4
REGION_RECTANGLE =
0
REGION_ELLIPSE =
1
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_X_LOG2 =
64
OPTION_Y_LOG2 =
128
OPTION_Z_LOG2 =
256
OPTION_X_LN =
512
OPTION_Y_LN =
1024
OPTION_Z_LN =
2048
SPEC_LINE =
1
SPEC_MARKER =
2
SPEC_COLOR =
4
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
OPTION_3D_MESH =
7
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
GDP_DRAW_PATH =
1
GDP_DRAW_LINES =
2
GDP_DRAW_MARKERS =
3
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
VOLUME_WITHOUT_BORDER =
0
VOLUME_WITH_BORDER =
1
VOLUME_EMISSION =
0
VOLUME_ABSORPTION =
1
VOLUME_MIP =
2
TEXT_USE_WC =
(1 << 0)
TEXT_ENABLE_INLINE_MATH =
(1 << 1)
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.



54
55
56
# File 'lib/gr.rb', line 54

def ffi_lib
  @ffi_lib
end

Class Method Details

._contour_Object

Note:

‘contour` is overwritten by `require gr/plot`. The original method is moved to the underscored name. The yard document will show the method name after evacuation.

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

Parameters:

  • x (Array, NArray)

    A list containing the X coordinates

  • y (Array, NArray)

    A list containing the Y coordinates

  • h (Array, NArray)

    A list containing the Z coordinate for the height values

  • z (Array, NArray)

    A list containing the Z coordinate for the height values A list of length ‘len(x)` * `len(y)` or an appropriately dimensioned array containing the Z coordinates

  • major_h (Integer)

    Directs GR to label contour lines. For example, a value of 3 would label every third line. A value of 1 will label every line. A value of 0 produces no labels. To produce colored contour lines, add an offset of 1000 to ‘major_h`.

Raises:

  • (ArgumentError)


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

def contour(x, y, h, z, major_h)
  nx = x.length
  ny = y.length
  nh = h.length
  raise ArgumentError, "z must have length nx * ny (expected #{nx * ny}, got #{z.length})" if z.length != nx * ny

  super(nx, ny, nh, x, y, h, z, major_h)
end

._contourf_Object

Note:

‘contourf` is overwritten by `require gr/plot`. The original method is moved to the underscored name. The yard document will show the method name after evacuation.

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

Parameters:

  • x (Array, NArray)

    A list containing the X coordinates

  • y (Array, NArray)

    A list containing the Y coordinates

  • h (Array, NArray)

    A list containing the Z coordinate for the height values or the number of contour lines which will be evenly distributed between minimum and maximum Z value

  • z (Array, NArray)

    A list of length ‘len(x)` * `len(y)` or an appropriately dimensioned array containing the Z coordinates

Raises:

  • (ArgumentError)


1680
1681
1682
1683
1684
1685
1686
1687
# File 'lib/gr/plot.rb', line 1680

def contourf(x, y, h, z, major_h)
  nx = x.length
  ny = y.length
  nh = h.length
  raise ArgumentError, "z must have length nx * ny (expected #{nx * ny}, got #{z.length})" if z.length != nx * ny

  super(nx, ny, nh, x, y, h, z, major_h)
end

._hexbin_Integer

Note:

‘hexbin` is overwritten by `require gr/plot`. The original method is moved to the underscored name. The yard document will show the method name after evacuation.

Returns:

  • (Integer)


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

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

._shade_Object

Note:

‘hexbin` is overwritten by `require gr/plot`. The original method is moved to the underscored name. The yard document will show the method name after evacuation.



# File 'lib/gr/plot.rb', line 1728

._surface_Object

Note:

‘surface` is overwritten by `require gr/plot`. The original method is moved to the underscored name. The yard document will show the method name after evacuation.

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.

Parameters:

  • x (Array, NArray)

    A list containing the X coordinates

  • y (Array, NArray)

    A list containing the Y coordinates

  • z (Array, NArray)

    A list of length ‘len(x)` * `len(y)` or an appropriately dimensioned array containing the Z coordinates

  • option (Integer)

    Surface display option

    • 0 LINES - Use X Y polylines to denote the surface

    • 1 MESH - Use a wire grid to denote the surface

    • 2 FILLED_MESH - Applies an opaque grid to the surface

    • 3 Z_SHADED_MESH - Applies Z-value shading to the surface

    • 4 COLORED_MESH - Applies a colored grid to the surface

    • 5 CELL_ARRAY - Applies a grid of individually-colored cells to the surface

    • 6 SHADED_MESH - Applies light source shading to the 3-D surface

Raises:

  • (ArgumentError)


1703
1704
1705
1706
1707
1708
1709
# File 'lib/gr/plot.rb', line 1703

def surface(x, y, z, option)
  nx = x.length
  ny = y.length
  raise ArgumentError, "z must have length nx * ny (expected #{nx * ny}, got #{z.length})" if z.length != nx * ny

  super(nx, ny, x, y, z, option)
end

.activatewsObject

Activate the specified workstation.

Parameters:

  • workstation_id (Integer)

    A workstation identifier.



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

.adjustlimits(amin, amax) ⇒ Integer

Returns:

  • (Integer)


1590
1591
1592
1593
1594
1595
1596
# File 'lib/gr.rb', line 1590

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



1598
1599
1600
1601
1602
1603
1604
# File 'lib/gr.rb', line 1598

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.

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 gr_setlinetype and gr_setlinewidth functions. Axes are drawn according to the linear or logarithmic transformation established by the gr_setscale function.

Parameters:

  • x_tick (Numeric)

    The interval between minor tick marks on the X axis.

  • y_tick (Numeric)

    The interval between minor tick marks on the Y axis.

  • x_org (Numeric)

    The world coordinates of the origin (point of intersection) of the X axis.

  • y_org (Numeric)

    The world coordinates of the origin (point of intersection) of the Y axis.

  • major_x (Integer)

    Unitless integer values specifying the number of minor tick intervals between major tick marks. Values of 0 or 1 imply no minor ticks. Negative values specify no labels will be drawn for the associated axis.

  • major_y (Integer)

    Unitless integer values specifying the number of minor tick intervals between major tick marks. Values of 0 or 1 imply no minor ticks. Negative values specify no labels will be drawn for the associated axis.

  • tick_size (Numeric)

    The length of minor tick marks specified in a normalized device coordinate unit. Major tick marks are twice as long as minor tick marks. A negative value reverses the tick marks on the axes from inward facing to outward facing (or vice versa).



1165
# File 'lib/gr.rb', line 1165

alias axes2d axes

.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.

Parameters:

  • x_tick (Numeric)

    The interval between minor tick marks on the X axis.

  • y_tick (Numeric)

    The interval between minor tick marks on the Y axis.

  • z_tick (Numeric)

    The interval between minor tick marks on the Z axis.

  • x_org (Numeric)

    The world coordinates of the origin (point of intersection) of the X axes.

  • y_org (Numeric)

    The world coordinates of the origin (point of intersection) of the Y axes.

  • z_org (Numeric)

    The world coordinates of the origin (point of intersection) of the Z axes.

  • major_x (Integer)

    Unitless integer values specifying the number of minor tick intervals between major tick marks. Values of 0 or 1 imply no minor ticks. Negative values specify no labels will be drawn for the associated axis.

  • major_y (Integer)

    Unitless integer values specifying the number of minor tick intervals between major tick marks. Values of 0 or 1 imply no minor ticks. Negative values specify no labels will be drawn for the associated axis.

  • major_z (Integer)

    Unitless integer values specifying the number of minor tick intervals between major tick marks. Values of 0 or 1 imply no minor ticks. Negative values specify no labels will be drawn for the associated axis.

  • tick_size (Numeric)

    The length of minor tick marks specified in a normalized device coordinate unit. Major tick marks are twice as long as minor tick marks. A negative value reverses the tick marks on the axes from inward facing to outward facing (or vice versa).



# File 'lib/gr.rb', line 1357

.axeslblObject

Note:

This method uses GRCommons::Fiddley::Function as a callback function. Please read the source code If you have to use it. There are some examples of the use of this function in the Plot class..

Create axes in the current workspace and supply a custom function for changing the behaviour of the tick labels.

Similar to gr_axes() but allows more fine-grained control over tick labels and text positioning by supplying callback functions. Within the callback function you can use normal GR text primitives for performing any manipulations on the label text. See gr_axes() for more details on drawing axes.

  • fpx/fpy

    • param x [Numeric] NDC of the label in X direction.

    • param y [Numeric] NDC of the label in Y direction.

    • param svalue [String] Internal string representation of the text drawn by GR at (x,y).

    • param value [Numeric] Floating point representation of the label drawn at (x,y).

Parameters:

  • x_tick (Numeric)

    The interval between minor tick marks on the X axis.

  • y_tick (Numeric)

    The interval between minor tick marks on the Y axis.

  • x_org (Numeric)

    The world coordinate of the origin (point of intersection) of the X axis.

  • y_org (Numeric)

    The world coordinate of the origin (point of intersection) of the Y axis.

  • major_x (Integer)

    Unitless integer value specifying the number of minor tick intervals between major tick marks on the X axis. Values of 0 or 1 imply no minor ticks. Negative values specify no labels will be drawn for the associated axis.

  • major_y (Integer)

    Unitless integer value specifying the number of minor tick intervals between major tick marks on the Y axis. Values of 0 or 1 imply no minor ticks. Negative values specify no labels will be drawn for the associated axis.

  • tick_size (Numeric)

    The length of minor tick marks specified in a normalized device coordinate unit. Major tick marks are twice as long as minor tick marks. A negative value reverses the tick marks on the axes from inward facing to outward facing (or vice versa).

  • fpx (Pointer)

    Function pointer to a function that returns a label for a given tick on the X axis. The callback function should have the following arguments.

  • fpy (Pointer)

    Exactly same as the fpx above, but for the the Y axis.



# File 'lib/gr.rb', line 1198

.axis(option, **opts) ⇒ Object

Raises:

  • (ArgumentError)


1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
# File 'lib/gr.rb', line 1167

def axis(option, **opts)
  axis = GRAxis.new
  opts.each do |k, v|
    setter = "#{k}="
    axis.public_send(setter, v) if axis.respond_to?(setter)
  end

  c_axis = __axis_to_c_axis(axis)

  str = option.to_s
  raise ArgumentError, "axis option must be a single character, got #{str.inspect}" unless str.length == 1

  FFI.gr_axis(str.ord, c_axis)
  __axis_from_c_axis(c_axis)
end

.barplot(*args) ⇒ Object

(Plot) Draw a bar plot.



1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
# File 'lib/gr/plot.rb', line 1742

def barplot(*args)
  kv = args.last.is_a?(Hash) ? args.pop : {}
  if args.length == 2
    labels, heights = args
  elsif args.length == 1
    heights = args[0]
    labels = (1..heights.length).map(&:to_s)
  else
    raise ArgumentError
  end

  wc, hc = barcoordinates(heights, kv)
  horizontal = kv.delete(:horizontal)

  create_plot(:bar, kv) do |plt|
    if horizontal
      plt.args = [[hc, wc, nil, nil, '']]
      plt.kvs[:yticks] = [1, 1]
      plt.kvs[:yticklabels] = labels.map(&:to_s)
    else
      plt.args = [[wc, hc, nil, nil, '']]
      plt.kvs[:xticks] = [1, 1]
      plt.kvs[:xticklabels] = labels.map(&:to_s)
    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.

Parameters:

  • path (String)

    Filename for the graphics file.



# File 'lib/gr.rb', line 1887

.beginprint(file_path) ⇒ Object

Note:

Ruby feature - you can use block to call endprint automatically.

Open and activate a print device.

‘beginprint` opens an additional graphics output device. The device type is obtained from the given file extension

Parameters:

  • pathname (String)

    Filename for the print device. The following file types are supported:

    • .ps, .eps : PostScript

    • .pdf : Portable Document Format

    • .bmp : Windows Bitmap (BMP)

    • .jpeg, .jpg : JPEG image file

    • .png : Portable Network Graphics file (PNG)

    • .tiff, .tif : Tagged Image File Format (TIFF)

    • .svg : Scalable Vector Graphics

    • .wmf : Windows Metafile

    • .mp4 : MPEG-4 video file

    • .webm : WebM video file

    • .ogg : Ogg video file



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

def beginprint(file_path)
  super(file_path)
  return unless block_given?

  yield
  endprint
end

.beginprintextObject

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

Parameters:

  • pathname (String)

    Filename for the print device.

  • mode (String)

    Output mode (Color, GrayScale)

  • fmt (String)

    Output format The available formats are:

    • A4 : 0.210 x 0.297

    • B5 : 0.176 x 0.250

    • Letter : 0.216 x 0.279

    • Legal : 0.216 x 0.356

    • Executive : 0.191 x 0.254

    • A0 : 0.841 x 1.189

    • A1 : 0.594 x 0.841

    • A2 : 0.420 x 0.594

    • A3 : 0.297 x 0.420

    • A5 : 0.148 x 0.210

    • A6 : 0.105 x 0.148

    • A7 : 0.074 x 0.105

    • A8 : 0.052 x 0.074

    • A9 : 0.037 x 0.052

    • B0 : 1.000 x 1.414

    • B1 : 0.500 x 0.707

    • B10 : 0.031 x 0.044

    • B2 : 0.500 x 0.707

    • B3 : 0.353 x 0.500

    • B4 : 0.250 x 0.353

    • B6 : 0.125 x 0.176

    • B7 : 0.088 x 0.125

    • B8 : 0.062 x 0.088

    • B9 : 0.044 x 0.062

    • C5E : 0.163 x 0.229

    • Comm10E : 0.105 x 0.241

    • DLE : 0.110 x 0.220

    • Folio : 0.210 x 0.330

    • Ledger : 0.432 x 0.279

    • Tabloid : 0.279 x 0.432

  • orientation (String)

    Page orientation (Landscape, Portrait)



# File 'lib/gr.rb', line 1635

.beginselectionObject



# File 'lib/gr.rb', line 1922

.camerainteractionObject

Rotate the current scene according to a virtual arcball.

This function requires values between 0 (left side or bottom of the drawing area) and 1 (right side or top of the drawing area).

Parameters:

  • start_mouse_pos_x (Numeric)

    x component of the start mouse position

  • start_mouse_pos_y (Numeric)

    y component of the start mouse position

  • end_mouse_pos_x (Numeric)

    x component of the end mouse position

  • end_mouse_pos_y (Numeric)

    y component of the end mouse position



# File 'lib/gr.rb', line 2344

.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.

Parameters:

  • xmin (Numeric)

    Lower left point of the rectangle

  • ymin (Numeric)

    Lower left point of the rectangle

  • xmax (Numeric)

    Upper right point of the rectangle

  • ymax (Numeric)

    Upper right point of the rectangle

  • dimx (Integer)

    X dimension of the color index array

  • dimy (Integer)

    Y dimension of the color index array

  • color (Array, NArray)

    Color index array



379
380
381
# File 'lib/gr.rb', line 379

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

.clearwsObject

Clear the specified workstation.



# File 'lib/gr.rb', line 219

.closegksObject



# File 'lib/gr.rb', line 151

.closesegObject



# File 'lib/gr.rb', line 1005

.closewsObject

Close the specified workstation.

Parameters:

  • workstation_id (Integer)

    A workstation identifier.



# File 'lib/gr.rb', line 197

.colorbarObject



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

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

.configurewsObject

Configure the specified workstation.



# File 'lib/gr.rb', line 215

.contour(*args) ⇒ Object

(Plot) Draw a contour plot.



1458
1459
1460
1461
1462
1463
1464
1465
# File 'lib/gr.rb', line 1458

def contour(x, y, h, z, major_h)
  nx = x.length
  ny = y.length
  nh = h.length
  raise ArgumentError, "z must have length nx * ny (expected #{nx * ny}, got #{z.length})" if z.length != nx * ny

  super(nx, ny, nh, x, y, h, z, major_h)
end

.contourf(*args) ⇒ Object

(Plot) Draw a filled contour plot.



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

def contourf(x, y, h, z, major_h)
  nx = x.length
  ny = y.length
  nh = h.length
  raise ArgumentError, "z must have length nx * ny (expected #{nx * ny}, got #{z.length})" if z.length != nx * ny

  super(nx, ny, nh, x, y, h, z, major_h)
end

.copysegwsObject



# File 'lib/gr.rb', line 999

.cpubasedvolumeObject

FIXME! (#61)



2497
2498
2499
2500
2501
# File 'lib/gr.rb', line 2497

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

.createsegObject



# File 'lib/gr.rb', line 997

.deactivatewsObject

Deactivate the specified workstation.

Parameters:

  • workstation_id (Integer)

    A workstation identifier.



# File 'lib/gr.rb', line 209

.delaunay(x, y) ⇒ Integer

Returns:

  • (Integer)


1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
# File 'lib/gr.rb', line 1957

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, Fiddle::RUBY_FREE)
  dim = 3
  n_tri = inquiry_int do |ntri|
    super(npoints, x, y, ntri, triangles.ref)
  end
  if n_tri > 0
    tri = triangles.to_str(dim * n_tri * Fiddle::SIZEOF_INT).unpack('l*') # Int32
    # Ruby  : 0-based indexing
    # Julia : 1-based indexing
    tri = tri.each_slice(dim).to_a
    [n_tri, tri]
  else
    0
  end
end

.destroycontextObject



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

.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.

Parameters:

  • xmin (Numeric)

    Lower left edge of the rectangle

  • xmax (Numeric)

    Lower right edge of the rectangle

  • ymin (Numeric)

    Upper left edge of the rectangle

  • ymax (Numeric)

    Upper right edge of the rectangle

  • a1 (Numeric)

    The start angle

  • a2 (Numeric)

    The end angle



# File 'lib/gr.rb', line 1720

.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.

Parameters:

  • x1 (Numeric)

    Starting point of the arrow (tail)

  • y1 (Numeric)

    Starting point of the arrow (tail)

  • x2 (Numeric)

    Head of the arrow

  • y2 (Numeric)

    Head of the arrow



# File 'lib/gr.rb', line 1804

.drawaxes(x_axis = nil, y_axis = nil, option = 1) ⇒ Object



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

def drawaxes(x_axis = nil, y_axis = nil, option = 1)
  c_x = x_axis && __axis_to_c_axis(x_axis)
  c_y = y_axis && __axis_to_c_axis(y_axis)
  FFI.gr_drawaxes(c_x&.to_ptr, c_y&.to_ptr, option)
end

.drawaxis(option, axis) ⇒ Object

Raises:

  • (ArgumentError)


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

def drawaxis(option, axis)
  c_axis = __axis_to_c_axis(axis)

  str = option.to_s
  raise ArgumentError, "axis option must be a single character, got #{str.inspect}" unless str.length == 1

  FFI.gr_drawaxis(str.ord, c_axis)
end

.drawgraphicsInteger

Returns:

  • (Integer)


# File 'lib/gr.rb', line 1903

.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.

Parameters:

  • xmin (Numeric)

    First corner point of the rectangle

  • ymin (Numeric)

    First corner point of the rectangle

  • xmax (Numeric)

    Second corner point of the rectangle

  • ymax (Numeric)

    Second corner point of the rectangle

  • width (Integer)

    The width and the height of the image

  • height (Integer)

    The width and the height of the image

  • data (Array, NArray)

    An array of color values dimensioned ‘width` by `height`

  • model (Integer) (defaults to: 0)

    Color model ( default = 0 ) The available color models are:

    • 0 : MODEL_RGB - AABBGGRR

    • 1 : MODEL_HSV - AAVVSSHH



1849
1850
1851
# File 'lib/gr.rb', line 1849

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.

Parameters:

  • points (Array, NArray)

    (N, 2) array of (x, y) vertices

  • codes (Array, NArray)

    N-length array of path codes

    • STOP : end the entire path

    • MOVETO : move to the given vertex

    • LINETO : draw a line from the current position to the given vertex

    • CURVE3 : draw a quadratic Bézier curve

    • CURVE4 : draw a cubic Bézier curve

    • CLOSEPOLY : draw a line segment to the start point of the current path

  • fill (Integer)

    A flag indication whether resulting path is to be filled or not



1764
1765
1766
1767
# File 'lib/gr.rb', line 1764

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

.drawrectObject

Draw a rectangle using the current line attributes.

Parameters:

  • xmin (Numeric)

    Lower left edge of the rectangle

  • xmax (Numeric)

    Lower right edge of the rectangle

  • ymin (Numeric)

    Upper left edge of the rectangle

  • ymax (Numeric)

    Upper right edge of the rectangle



# File 'lib/gr.rb', line 1702

.emergencyclosegksObject



# File 'lib/gr.rb', line 1007

.endgraphicsObject



# File 'lib/gr.rb', line 1896

.endprintObject



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

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

.endselectionObject



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

.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.

Parameters:

  • xmin (Numeric)

    Lower left edge of the rectangle

  • xmax (Numeric)

    Lower right edge of the rectangle

  • ymin (Numeric)

    Upper left edge of the rectangle

  • ymax (Numeric)

    Upper right edge of the rectangle

  • a1 (Numeric)

    The start angle

  • a2 (Numeric)

    The end angle



# File 'lib/gr.rb', line 1735

.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.

Parameters:

  • x (Array, NArray)

    A list containing the X coordinates

  • y (Array, NArray)

    A list containing the Y coordinates



359
360
361
362
# File 'lib/gr.rb', line 359

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

.fillrectObject

Draw a filled rectangle using the current fill attributes.

Parameters:

  • xmin (Numeric)

    Lower left edge of the rectangle

  • xmax (Numeric)

    Lower right edge of the rectangle

  • ymin (Numeric)

    Upper left edge of the rectangle

  • ymax (Numeric)

    Upper right edge of the rectangle



# File 'lib/gr.rb', line 1711

.findboundaryObject

Note:

This method uses GRCommons::Fiddley::Function as a callback function. Please read the source code If you have to use it. This method is not sure if it works properly.



# File 'lib/gr.rb', line 2125

.ftoa(value, format_ref) ⇒ Object



2542
2543
2544
2545
2546
# File 'lib/gr.rb', line 2542

def ftoa(value, format_ref)
  string = Fiddle::Pointer.malloc(256)
  super(string, value, format_ref)
  string.to_s
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.

Parameters:

  • x (Array, NArray)

    A list containing the X coordinates

  • y (Array, NArray)

    A list containing the Y coordinates

  • primid (Integer)

    Primitive identifier

  • datrec (Array, NArray)

    Primitive data record



479
480
481
482
483
# File 'lib/gr.rb', line 479

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

.getformat(origin, min, max, tick_width, major) ⇒ Object



2536
2537
2538
2539
2540
# File 'lib/gr.rb', line 2536

def getformat(origin, min, max, tick_width, major)
  ref = FFI::FormatReference.malloc
  super(ref, origin, min, max, tick_width, major)
  ref
end

.getgraphicsString

Returns:

  • (String)


1899
1900
1901
# File 'lib/gr.rb', line 1899

def getgraphics(*)
  super.to_s
end

.gr_setresizebehaviourObject



862
863
864
# File 'lib/gr.rb', line 862

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

.gradient(x, y, z) ⇒ Object

Deprecated.

Raises:

  • (ArgumentError)


2003
2004
2005
2006
2007
2008
2009
2010
2011
# File 'lib/gr.rb', line 2003

def gradient(x, y, z)
  nx = x.length
  ny = y.length
  raise ArgumentError, "z must have length nx * ny (expected #{nx * ny}, got #{z.length})" if z.length != nx * ny

  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.

Parameters:

  • x_tick (Numeric)

    The length in world coordinates of the interval between minor grid lines.

  • y_tick (Numeric)

    The length in world coordinates of the interval between minor grid lines.

  • x_org (Numeric)

    The world coordinates of the origin (point of intersection) of the grid.

  • y_org (Numeric)

    The world coordinates of the origin (point of intersection) of the grid.

  • major_x (Integer)

    Unitless integer values specifying the number of minor grid lines between major grid lines. Values of 0 or 1 imply no grid lines.

  • major_y (Integer)

    Unitless integer values specifying the number of minor grid lines between major grid lines. Values of 0 or 1 imply no grid lines.



# File 'lib/gr.rb', line 1247

.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.

Parameters:

  • x_tick (Numeric)

    The length in world coordinates of the interval between minor grid lines.

  • y_tick (Numeric)

    The length in world coordinates of the interval between minor grid lines.

  • z_tick (Numeric)

    The length in world coordinates of the interval between minor grid lines.

  • x_org (Numeric)

    The world coordinates of the origin (point of intersection) of the grid.

  • y_org (Numeric)

    The world coordinates of the origin (point of intersection) of the grid.

  • z_org (Numeric)

    The world coordinates of the origin (point of intersection) of the grid.

  • major_x (Integer)

    Unitless integer values specifying the number of minor grid lines between major grid lines. Values of 0 or 1 imply no grid lines.

  • major_y (Integer)

    Unitless integer values specifying the number of minor grid lines between major grid lines. Values of 0 or 1 imply no grid lines.

  • major_z (Integer)

    Unitless integer values specifying the number of minor grid lines between major grid lines. Values of 0 or 1 imply no grid lines.



# File 'lib/gr.rb', line 1271

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

Interpolate data from arbitrary points at points on a rectangular grid.

Parameters:

  • xd (Array, NArray)

    X coordinates of the input points

  • yd (Array, NArray)

    Y coordinates of the input points

  • zd (Array, NArray)

    values of the points

  • nx (Array, NArray)

    The number of points in X direction for the output grid

  • ny (Array, NArray)

    The number of points in Y direction for the output grid



516
517
518
519
520
521
# File 'lib/gr.rb', line 516

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. (Plot) Draw a heatmap.



1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
# File 'lib/gr/plot.rb', line 1591

def heatmap(*args)
  kv = args.last.is_a?(Hash) ? args.pop : {}
  if args.length == 1
    z = args[0]
    z = Numo::DFloat.cast(z) if z.is_a?(Array)
    ysize, xsize = z.shape
    z = z.reshape(xsize, ysize)
    x = (1..xsize).to_a
    y = (1..ysize).to_a
  elsif args.length == 3
    x, y, z = args
    z = Numo::DFloat.cast(z) if z.is_a?(Array)
  else
    raise ArgumentError
  end
  create_plot(:heatmap, kv) do |plt|
    plt.args = [[x, y, z, nil, '']]
  end
end

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

Draw a standard horizontal error bar graph.

Parameters:

  • x (Array, NArray)

    A list of length N containing the X coordinates

  • y (Array, NArray)

    A list of length N containing the Y coordinates

  • e1 (Array, NArray)

    The absolute values of the lower error bar data

  • e2 (Array, NArray)

    The absolute values of the lower error bar data



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

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.



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

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

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

(Plot) Draw a histogram.



1770
1771
1772
1773
1774
1775
1776
# File 'lib/gr/plot.rb', line 1770

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

.hold(flag = true) ⇒ Object



1794
1795
1796
1797
# File 'lib/gr/plot.rb', line 1794

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) ⇒ Integer

Returns:

  • (Integer)


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

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

.importgraphicsInteger

Returns:

  • (Integer)


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

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

(Plot) Draw an image.



1779
1780
1781
1782
1783
1784
# File 'lib/gr/plot.rb', line 1779

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



# File 'lib/gr.rb', line 147

.inqbboxObject



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

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

.inqbordercolorindObject

Define the color of subsequent path output primitives.

Parameters:

  • color (Integer)

    The border color index (COLOR < 1256)



2258
2259
2260
# File 'lib/gr.rb', line 2258

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

.inqborderwidthObject

Define the border width of subsequent path output primitives.

Parameters:

  • width (Numeric)

    The border width scale factor



2248
2249
2250
# File 'lib/gr.rb', line 2248

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

.inqcharheightNumeric

Gets the current character height.

This function gets the height of 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).

Returns:

  • (Numeric)

    Text height value



748
749
750
# File 'lib/gr.rb', line 748

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

.inqclipregionObject



2524
2525
2526
# File 'lib/gr.rb', line 2524

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

.inqclipsectorObject



2530
2531
2532
2533
2534
# File 'lib/gr.rb', line 2530

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

.inqclipxformObject



2264
2265
2266
# File 'lib/gr.rb', line 2264

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

.inqcolor(color) ⇒ Object



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

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

.inqcolorfromrgbInteger

Returns:

  • (Integer)


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

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

.inqcolormapObject

inqcolormap



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

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

.inqcolormapindsArray

Inquire the color index range of the current colormap.

Returns:

  • (Array)

    first_color_ind The color index of the first color, last_color_ind The color index of the last color



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

def inqcolormapinds
  inquiry %i[int int] do |first_color_ind, last_color_ind|
    super(first_color_ind, last_color_ind)
  end
end

.inqdspsizeArray

Get the current display size.

Depending on the current workstation type, the current display might be the primary screen (e.g. when using gksqt or GKSTerm) or a purely virtual display (e.g. when using Cairo). When a high DPI screen is used as the current display, width and height will be in logical pixels.

Returns:

  • (Array)

    meter_width, meter_height, width, height



161
162
163
164
165
# File 'lib/gr.rb', line 161

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

.inqfillcolorindInteger

Returns the current fill area color index.

This function gets the color of fill area output primitives.

Returns:

  • (Integer)

    The text color index (COLOR < 1256)



856
857
858
# File 'lib/gr.rb', line 856

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

.inqfillintstyleInteger

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

This function gets the currently set fill style.

Returns:

  • (Integer)

    The currently set fill style



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

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

.inqfillstyleInteger

Returns the current fill area color index.

This function gets the color index for PATTERN and HATCH fills.

Returns:

  • (Integer)

    The currently set fill style color index



837
838
839
# File 'lib/gr.rb', line 837

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

.inqlinecolorindObject

Define the color of subsequent polyline output primitives.

Parameters:

  • color (Integer)

    The polyline color index (COLOR < 1256)



566
567
568
# File 'lib/gr.rb', line 566

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

.inqlinetypeObject

Specify the line style for polylines.

Parameters:

  • style (Integer)

    The polyline line style

    • 1 : LINETYPE_SOLID - Solid line

    • 2 : LINETYPE_DASHED - Dashed line

    • 3 : LINETYPE_DOTTED - Dotted line

    • 4 : LINETYPE_DASHED_DOTTED - Dashed-dotted line

    • -1 : LINETYPE_DASH_2_DOT - Sequence of one dash followed by two dots

    • -2 : LINETYPE_DASH_3_DOT - Sequence of one dash followed by three dots

    • -3 : LINETYPE_LONG_DASH - Sequence of long dashes

    • -4 : LINETYPE_LONG_SHORT_DASH - Sequence of a long dash followed by a short dash

    • -5 : LINETYPE_SPACED_DASH - Sequence of dashes double spaced

    • -6 : LINETYPE_SPACED_DOT - Sequence of dots double spaced

    • -7 : LINETYPE_DOUBLE_DOT - Sequence of pairs of dots

    • -8 : LINETYPE_TRIPLE_DOT - Sequence of groups of three dots



541
542
543
# File 'lib/gr.rb', line 541

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

.inqlinewidthObject

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.

Parameters:

  • width (Numeric)

    The polyline line width scale factor



556
557
558
# File 'lib/gr.rb', line 556

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

.inqmarkercolorindObject

Define the color of subsequent polymarker output primitives.

Parameters:

  • color (Integer)

    The polymarker color index (COLOR < 1256)



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

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

.inqmarkersizeNumeric

Inquire the marker size for polymarkers.

Returns:

  • (Numeric)

    Scale factor applied to the nominal marker size



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

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

.inqmarkertypeObject

Specify the marker type for polymarkers.

Polymarkers appear centered over their specified coordinates.

Parameters:

  • style (Integer)

    The polymarker marker type

    • 1 : MARKERTYPE_DOT - Smallest displayable dot

    • 2 : MARKERTYPE_PLUS - Plus sign

    • 3 : MARKERTYPE_ASTERISK - Asterisk

    • 4 : MARKERTYPE_CIRCLE - Hollow circle

    • 5 : MARKERTYPE_DIAGONAL_CROSS - Diagonal cross

    • -1 : MARKERTYPE_SOLID_CIRCLE - Filled circle

    • -2 : MARKERTYPE_TRIANGLE_UP - Hollow triangle pointing upward

    • -3 : MARKERTYPE_SOLID_TRI_UP - Filled triangle pointing upward

    • -4 : MARKERTYPE_TRIANGLE_DOWN - Hollow triangle pointing downward

    • -5 : MARKERTYPE_SOLID_TRI_DOWN - Filled triangle pointing downward

    • -6 : MARKERTYPE_SQUARE - Hollow square

    • -7 : MARKERTYPE_SOLID_SQUARE - Filled square

    • -8 : MARKERTYPE_BOWTIE - Hollow bowtie

    • -9 : MARKERTYPE_SOLID_BOWTIE - Filled bowtie

    • -10 : MARKERTYPE_HGLASS - Hollow hourglass

    • -11 : MARKERTYPE_SOLID_HGLASS - Filled hourglass

    • -12 : MARKERTYPE_DIAMOND - Hollow diamond

    • -13 : MARKERTYPE_SOLID_DIAMOND - Filled Diamond

    • -14 : MARKERTYPE_STAR - Hollow star

    • -15 : MARKERTYPE_SOLID_STAR - Filled Star

    • -16 : MARKERTYPE_TRI_UP_DOWN - Hollow triangles pointing up and down overlaid

    • -17 : MARKERTYPE_SOLID_TRI_RIGHT - Filled triangle point right

    • -18 : MARKERTYPE_SOLID_TRI_LEFT - Filled triangle pointing left

    • -19 : MARKERTYPE_HOLLOW PLUS - Hollow plus sign

    • -20 : MARKERTYPE_SOLID PLUS - Solid plus sign

    • -21 : MARKERTYPE_PENTAGON - Pentagon

    • -22 : MARKERTYPE_HEXAGON - Hexagon

    • -23 : MARKERTYPE_HEPTAGON - Heptagon

    • -24 : MARKERTYPE_OCTAGON - Octagon

    • -25 : MARKERTYPE_STAR_4 - 4-pointed star

    • -26 : MARKERTYPE_STAR_5 - 5-pointed star (pentagram)

    • -27 : MARKERTYPE_STAR_6 - 6-pointed star (hexagram)

    • -28 : MARKERTYPE_STAR_7 - 7-pointed star (heptagram)

    • -29 : MARKERTYPE_STAR_8 - 8-pointed star (octagram)

    • -30 : MARKERTYPE_VLINE - vertical line

    • -31 : MARKERTYPE_HLINE - horizontal line

    • -32 : MARKERTYPE_OMARK - o-mark



615
616
617
# File 'lib/gr.rb', line 615

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

.inqmathfontObject



2518
2519
2520
# File 'lib/gr.rb', line 2518

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

.inqmathtex(x, y, string) ⇒ Object

inqmathtex



1916
1917
1918
1919
1920
# File 'lib/gr.rb', line 1916

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.



2338
2339
2340
2341
2342
# File 'lib/gr.rb', line 2338

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

.inqperspectiveprojectionObject

Return the parameters for the perspective projection.



2295
2296
2297
2298
2299
# File 'lib/gr.rb', line 2295

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

.inqprojectiontypeObject

Return the projection type.



2279
2280
2281
# File 'lib/gr.rb', line 2279

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

.inqregenflagsInteger

Returns:

  • (Integer)


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

.inqresamplemethodInteger

Inquire the resample method used for ‘drawimage`

Returns:

  • (Integer)

    Resample flag



2190
2191
2192
2193
2194
# File 'lib/gr.rb', line 2190

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

.inqresizebehaviourObject



862
863
864
# File 'lib/gr.rb', line 862

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

.inqscaleObject

inqscale



1062
1063
1064
# File 'lib/gr.rb', line 1062

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

.inqscalefactors3dObject

Returns the scale factors for each axis.



2386
2387
2388
2389
2390
# File 'lib/gr.rb', line 2386

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

.inqspaceInteger

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°.

Parameters:

  • zmin (Numeric)

    Minimum value for the Z-axis.

  • zmax (Numeric)

    Maximum value for the Z-axis.

  • rotation (Integer)

    Angle for the rotation of the X axis, in degrees.

  • tilt (integer)

    Viewing angle of the Z axis in degrees.

Returns:

  • (Integer)


1030
1031
1032
1033
1034
# File 'lib/gr.rb', line 1030

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

.inqtext(x, y, string) ⇒ Object

Draw a text at position ‘x`, `y` using the given options and current text attributes.

GR_TEXT_ENABLE_INLINE_MATH)

The values for ‘x` and `y` specify the text position. If the GR_TEXT_USE_WC option is set, they are interpreted as world coordinates, otherwise as normalized device coordinates. The string may contain new line characters and inline math expressions ($…$). The latter are only taken into account, if the GR_TEXT_ENABLE_INLINE_MATH option is set. 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.

Parameters:

  • x (Numeric)

    The X coordinate of the starting position of the text string

  • y (Numeric)

    The Y coordinate of the starting position of the text string

  • string (String)

    The text to be drawn

  • opts (Integer)

    Bit mask including text options (GR_TEXT_USE_WC,



339
340
341
342
343
# File 'lib/gr.rb', line 339

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



2411
2412
2413
2414
2415
# File 'lib/gr.rb', line 2411

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.

Returns:

  • (Integer)

    color The text color index (COLOR < 1256)



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

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

.inqtextencodingObject



2419
2420
2421
2422
2423
# File 'lib/gr.rb', line 2419

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

.inqtextext(x, y, string) ⇒ Object

inqtextext



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

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

.inqtextx(x, y, string, opts) ⇒ Object



345
346
347
348
349
# File 'lib/gr.rb', line 345

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

.inqtransformationparametersObject

Return the camera position, up vector and focus point.



2318
2319
2320
2321
2322
# File 'lib/gr.rb', line 2318

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

.inqviewportObject

inqviewport



926
927
928
929
930
# File 'lib/gr.rb', line 926

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

.inqvolumeflagsArray

Inquire the parameters which can be set for cpubasedvolume. The size of the resulting image, the way the volumeborder is calculated and the amount of threads which are used.

Returns:

  • (Array)
    • border - flag which tells how the border is calculated

    • max_threads - number of threads

    • picture_width - width of the resulting image

    • picture_height - height of the resulting image

    • approximative_calculation - exact or approximative calculation of gr_cpubasedvolume



2488
2489
2490
2491
2492
# File 'lib/gr.rb', line 2488

def inqvolumeflags
  inquiry([:int] * 5) do |*pts|
    super(*pts)
  end
end

.inqvpsizeObject

FIXME! (#61)



2497
2498
2499
2500
2501
# File 'lib/gr.rb', line 2497

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

.inqwindowObject

inqwindow



899
900
901
902
903
# File 'lib/gr.rb', line 899

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

.inqwindow3dObject

Return the three dimensional window.



2369
2370
2371
2372
2373
# File 'lib/gr.rb', line 2369

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.

flatten

Parameters:

  • x (Array, NArray)

    Array containing the input grid’s x-values

  • y (Array, NArray)

    Array containing the input grid’s y-values

  • z (Array, NArray)

    Array containing the input grid’s z-values (number of values: nx * ny)

  • xq (Array, NArray)

    Array containing the target grid’s x-values

  • yq (Array, NArray)

    Array containing the target grid’s y-values

  • method (Integer)

    Used method for interpolation The available methods for interpolation are the following:

    • 0 : INTERP2_NEAREST - Nearest neighbour interpolation

    • 1 : INTERP2_LINEAR - Linear interpolation

    • 2 : INTERP_2_SPLINE - Interpolation using natural cubic splines

    • 3 : INTERP2_CUBIC - Cubic interpolation

  • extrapval (Numeric)

    The extrapolation value



2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
# File 'lib/gr.rb', line 2056

def interp2(x, y, z, xq, yq, method, extrapval)
  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.



1787
1788
1789
1790
1791
1792
# File 'lib/gr/plot.rb', line 1787

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

.loadfont(str) ⇒ Object

Load a font file from a given filename.

This function loads a font from a given absolute filename and assigns a font index to it. To use the loaded font call ‘gr_settextfontprec` using the resulting font index and precision 3.

Parameters:

  • filename (String)

    The absolute filename of the font



2433
2434
2435
2436
2437
# File 'lib/gr.rb', line 2433

def loadfont(str)
  inquiry_int do |font|
    super(str, font)
  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.

Parameters:

  • x (Numeric)

    X coordinate of the starting position of the text string

  • y (Numeric)

    Y coordinate of the starting position of the text string

  • string (String)

    The text string to be drawn



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

.moveselectionObject



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

.ndctowc(x, y) ⇒ Object



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

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.

Parameters:

  • x (Array, NArray)

    X coordinates of the cell edges

  • y (Array, NArray)

    Y coordinates of the cell edges

  • dimx (Integer)

    X dimension of the color index array

  • dimy (Integer)

    Y dimension of the color index array

  • color (Array, NArray)

    Color index array

Raises:

  • (ArgumentError)


395
396
397
398
399
400
401
# File 'lib/gr.rb', line 395

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

  nx = dimx == x.length ? -dimx : dimx
  ny = dimy == y.length ? -dimy : dimy
  super(x, y, nx, ny, 1, 1, dimx, dimy, int(color))
end

.nonuniformheatmap(*args) ⇒ Object

(Plot) Draw a nonuniformheatmap.



1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
# File 'lib/gr/plot.rb', line 1612

def nonuniformheatmap(*args)
  kv = args.last.is_a?(Hash) ? args.pop : {}
  if args.length == 1
    z = args[0]
    z = Numo::DFloat.cast(z) if z.is_a?(Array)
    ysize, xsize = z.shape
    z = z.reshape(xsize, ysize)
    x = (1..xsize).to_a
    y = (1..ysize).to_a
  elsif args.length == 3
    x, y, z = args
    z = Numo::DFloat.cast(z) if z.is_a?(Array)
  else
    raise ArgumentError
  end
  create_plot(:nonuniformheatmap, kv) do |plt|
    plt.args = [[x, y, z, nil, '']]
  end
end

.nonuniformpolarcellarray(phi, r, ncol, nrow, color) ⇒ Object

Display a two dimensional color index array mapped to a disk using polar coordinates with nonuniform cell sizes.

The mapping of the polar coordinates and the drawing is performed similar to ‘gr_polarcellarray` with the difference that the individual cell sizes are specified allowing nonuniform sized cells.

Parameters:

  • phi (Array, NArray)

    array with the angles of the disk sector in degrees

  • r (Array, NArray)

    array with the radii of the disk in world coordinates

  • ncol (Integer)

    total number of columns in the color index array and the angle array

  • nrow (Integer)

    total number of rows in the color index array and the radii array

  • color (Integer)

    color index array

Raises:

  • (ArgumentError)


462
463
464
465
466
467
468
# File 'lib/gr.rb', line 462

def nonuniformpolarcellarray(phi, r, ncol, nrow, color)
  raise ArgumentError unless (ncol..(ncol + 1)).include?(phi.length) && (nrow..(nrow + 1)).include?(r.length)

  dimphi = ncol == phi.length ? -ncol : ncol
  dimr = nrow == r.length ? -nrow : nrow
  super(0, 0, phi, r, dimphi, dimr, 1, 1, ncol, nrow, int(color))
end

.nonuniformpolarheatmap(*args) ⇒ Object

(Plot) Draw a nonuniformpolarheatmap.



1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
# File 'lib/gr/plot.rb', line 1654

def nonuniformpolarheatmap(*args)
  kv = args.last.is_a?(Hash) ? args.pop : {}
  if args.length == 1
    z = args[0]
    z = Numo::DFloat.cast(z) if z.is_a?(Array)
    ysize, xsize = z.shape
    z = z.reshape(xsize, ysize)
    x = (1..xsize).to_a
    y = (1..ysize).to_a
  elsif args.length == 3
    x, y, z = args
    z = Numo::DFloat.cast(z) if z.is_a?(Array)
  else
    raise ArgumentError
  end
  create_plot(:nonuniformpolarheatmap, kv) do |plt|
    plt.args = [[x, y, z, nil, '']]
  end
end

.opengksObject



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

.openwsObject

Open a graphical workstation.

Parameters:

  • workstation_id (Integer)

    A workstation identifier.

  • connection (String)

    A connection identifier.

  • workstation_type (Integer)

    The desired workstation type.

    • 5 : Workstation Independent Segment Storage

    • 41 : Windows GDI

    • 61 - 64 : PostScript (b/w, color)

    • 101, 102 : Portable Document Format (plain, compressed)

    • 210 - 213 : X Windows

    • 214 : Sun Raster file (RF)

    • 215, 218 : Graphics Interchange Format (GIF87, GIF89)

    • 216 : Motif User Interface Language (UIL)

    • 320 : Windows Bitmap (BMP)

    • 321 : JPEG image file

    • 322 : Portable Network Graphics file (PNG)

    • 323 : Tagged Image File Format (TIFF)

    • 370 : Xfig vector graphics file

    • 371 : Gtk

    • 380 : wxWidgets

    • 381 : Qt4

    • 382 : Scalable Vector Graphics (SVG)

    • 390 : Windows Metafile

    • 400 : Quartz

    • 410 : Socket driver

    • 415 : 0MQ driver

    • 420 : OpenGL



# File 'lib/gr.rb', line 167

.panzoom(x, y, zoom) ⇒ Object

panzoom



2132
2133
2134
2135
2136
# File 'lib/gr.rb', line 2132

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.

Parameters:

  • x (Array, NArray)

    A list containing the X coordinates

  • y (Array, NArray)

    A list containing the Y coordinates

  • codes (String)

    A list containing the path codes The following path codes are recognized:

    • M, m

      • moveto x, y

    • L, l

      • lineto x, y

    • Q, q

      • quadratic Bézier x1, x2 y1, y2

    • C, c

      • cubic Bézier x1, x2, x3 y1, y2, y3

    • A, a

      • arc rx, a1, reserved ry, a2, reserved

    • Z

      • close path -

    • s

      • stroke -

    • s

      • close path and stroke -

    • f

      • close path and fill -

    • F

      • close path, fill and stroke -



2225
2226
2227
2228
# File 'lib/gr.rb', line 2225

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.



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

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

.plot3(*args) ⇒ Object

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



1719
1720
1721
# File 'lib/gr/plot.rb', line 1719

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

.polar(*args) ⇒ Object

(Plot)



1709
1710
1711
# File 'lib/gr/plot.rb', line 1709

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`.

The additional parameters to the function can be used to further control the mapping from polar to cartesian coordinates.

If ‘rmin` is greater than 0 the input data is mapped to a punctured disk (or annulus) with an inner radius of `rmin` and an outer radius `rmax`. If `rmin` is greater than `rmax` the Y-axis of the array is reversed.

The parameter ‘phimin` and `phimax` can be used to map the data to a sector of the (punctured) disk starting at `phimin` and ending at `phimax`. If `phimin` is greater than `phimax` the X-axis is reversed. The visible sector is the one starting in mathematically positive direction (counterclockwise) at the smaller angle and ending at the larger angle. An example of the four possible options can be found below:

  • phimin phimax Result

  • 90 270 Left half visible, mapped counterclockwise

  • 270 90 Left half visible, mapped clockwise

  • -90 90 Right half visible, mapped counterclockwise

  • 90 -90 Right half visible, mapped clockwise

Parameters:

  • x_org (Numeric)

    X coordinate of the disk center in world coordinates

  • y_org (Numeric)

    Y coordinate of the disk center in world coordinates

  • phimin (Numeric)

    start angle of the disk sector in degrees

  • phimax (Numeric)

    end angle of the disk sector in degrees

  • rmin (Numeric)

    inner radius of the punctured disk in world coordinates

  • rmax (Numeric)

    outer radius of the punctured disk in world coordinates

  • dimphi (Integer)

    Phi (X) dimension of the color index array

  • dimr (Integer)

    iR (Y) dimension of the color index array

  • color (Array, NArray)

    Color index array



445
446
447
# File 'lib/gr.rb', line 445

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.



1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
# File 'lib/gr/plot.rb', line 1633

def polarheatmap(*args)
  kv = args.last.is_a?(Hash) ? args.pop : {}
  if args.length == 1
    z = args[0]
    z = Numo::DFloat.cast(z) if z.is_a?(Array)
    ysize, xsize = z.shape
    z = z.reshape(xsize, ysize)
    x = (1..xsize).to_a
    y = (1..ysize).to_a
  elsif args.length == 3
    x, y, z = args
    z = Numo::DFloat.cast(z) if z.is_a?(Array)
  else
    raise ArgumentError
  end
  create_plot(:polarheatmap, kv) do |plt|
    plt.args = [[x, y, z, nil, '']]
  end
end

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

(Plot)



1580
1581
1582
1583
1584
1585
1586
1587
# File 'lib/gr/plot.rb', line 1580

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

.polygonmesh3d(px, py, pz, connections, colors) ⇒ Object



2503
2504
2505
2506
2507
# File 'lib/gr.rb', line 2503

def polygonmesh3d(px, py, pz, connections, colors)
  n_points = equal_length(px, py, pz)
  n_connections = colors.length
  super(n_points, px, py, pz, n_connections, int(connections), int(colors))
end

.polyline(x, y, linewidth = nil, line_z = nil) ⇒ Object

Draw a polyline using the current line attributes, 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 polyline are linetype, linewidth and color index.

Parameters:

  • x (Array, NArray)

    A list containing the X coordinates

  • y (Array, NArray)

    A list containing the Y coordinates

  • linewidth (Array, NArray, Numeric) (defaults to: nil)

    A list containing the line widths

  • line_z (Array, NArray, Numeric) (defaults to: nil)

    A list to be converted to colors



239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
# File 'lib/gr.rb', line 239

def polyline(x, y, linewidth = nil, line_z = nil)
  # GR.jl - Multiple dispatch
  n = equal_length(x, y)
  if linewidth.nil? && line_z.nil?
    super(n, x, y)
  else
    linewidth ||= GR.inqlinewidth
    linewidth = if linewidth.is_a?(Numeric)
                  Array.new(n, linewidth * 100)
                else
                  raise ArgumentError if n != linewidth.length

                  linewidth.map { |i| (100 * i).round }
                end
    line_z ||= GR.inqcolor(989) # FIXME
    color = if line_z.is_a?(Numeric)
              Array.new(n, line_z)
            else
              raise ArgumentError if n != line_z.length

              to_rgb_color(line_z)
            end
    z = linewidth.to_a.zip(color).flatten # to_a : NArray
    gdp(x, y, GDP_DRAW_LINES, z)
  end
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.

Parameters:

  • x (Array, NArray)

    A list of length N containing the X coordinates

  • y (Array, NArray)

    A list of length N containing the Y coordinates

  • z (Array, NArray)

    A list of length N containing the Z coordinates



1337
1338
1339
1340
# File 'lib/gr.rb', line 1337

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

.polymarker(x, y, markersize = nil, marker_z = nil) ⇒ Object

Draw marker symbols centered at the given data points.

The values for x and y are in world coordinates. The attributes that control the appearance of a polymarker are marker type, marker size scale factor and color index.

Parameters:

  • x (Array, NArray)

    A list containing the X coordinates

  • y (Array, NArray)

    A list containing the Y coordinates

  • markersize (Array, NArray, Numeric) (defaults to: nil)

    A list containing the marker sizes

  • marker_z (Array, NArray, Numeric) (defaults to: nil)

    A list to be converted to colors



277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
# File 'lib/gr.rb', line 277

def polymarker(x, y, markersize = nil, marker_z = nil)
  # GR.jl - Multiple dispatch
  n = equal_length(x, y)
  if markersize.nil? && marker_z.nil?
    super(n, x, y)
  else
    markersize ||= GR.inqmarkersize
    markersize = if markersize.is_a?(Numeric)
                   Array.new(n, markersize * 100)
                 else
                   raise ArgumentError if n != markersize.length

                   markersize.map { |i| (100 * i).round }
                 end
    marker_z ||= GR.inqcolor(989) # FIXME
    color = if marker_z.is_a?(Numeric)
              Array.new(n, marker_z)
            else
              raise ArgumentError if n != marker_z.length

              to_rgb_color(marker_z)
            end
    z = markersize.to_a.zip(color).flatten # to_a : NArray
    gdp(x, y, GDP_DRAW_MARKERS, z)
  end
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.

Parameters:

  • x (Array, NArray)

    A list of length N containing the X coordinates

  • y (Array, NArray)

    A list of length N containing the Y coordinates

  • z (Array, NArray)

    A list of length N containing the Z coordinates



1352
1353
1354
1355
# File 'lib/gr.rb', line 1352

def polymarker3d(x, y, z)
  n = equal_length(x, y, z)
  super(n, x, y, z)
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.

Parameters:

  • nx (Integer)

    The number of points along the x-axis of the grid

  • ny (Integer)

    The number of points along the y-axis of the grid

  • x (Array, NArray)

    A list containing the X coordinates

  • y (Array, NArray)

    A list containing the Y coordinates

  • u (Array, NArray)

    A list containing the U component for each point on the grid

  • v (Array, NArray)

    A list containing the V component for each point on the grid

  • color (Integer)

    A bool to indicate whether or not the arrows should be colored using the current colormap



2027
2028
2029
2030
2031
2032
2033
2034
2035
# File 'lib/gr.rb', line 2027

def quiver(x, y, u, v, color)
  nx = x.length
  ny = y.length
  if u.length != nx * ny || v.length != nx * ny
    raise ArgumentError, "u and v must have length nx * ny (expected #{nx * ny}, got u: #{u.length}, v: #{v.length})"
  end

  super(nx, ny, x, y, u, v, (color ? 1 : 0))
end

.readimage(path) ⇒ Integer

Returns:

  • (Integer)


1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
# File 'lib/gr.rb', line 1818

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, Fiddle::RUBY_FREE)
  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



# File 'lib/gr.rb', line 1001

.reducepoints(xd, yd, n) ⇒ Object

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

Parameters:

  • n (Integer)

    The requested number of points

  • x (Array, NArray)

    The x value array

  • y (Array, NArray)

    The y value array



1983
1984
1985
1986
1987
1988
1989
# File 'lib/gr.rb', line 1983

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



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

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

.restorestateObject



# File 'lib/gr.rb', line 1948

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

(Plot) Save the current figure to a file.



1823
1824
1825
1826
1827
1828
1829
# File 'lib/gr/plot.rb', line 1823

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

.savestateObject



# File 'lib/gr.rb', line 1946

.scatter(*args) ⇒ Object

(Plot) Draw one or more scatter plots.



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

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

.scatter3(*args) ⇒ Object

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



1724
1725
1726
# File 'lib/gr/plot.rb', line 1724

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

.selectclipxformObject



2264
2265
2266
# File 'lib/gr.rb', line 2264

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

.selectcontextObject



# File 'lib/gr.rb', line 1950

.selntranObject

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

Parameters:

  • transform (Integer)

    A normalization transformation number.

    • 0 : Selects the identity transformation in which both the window and

      viewport have the range of 0 to 1
      
    • >= 1 : Selects a normalization transformation as defined by ‘setwindow`

      and `setviewport`
      


# File 'lib/gr.rb', line 932

.setapproximativecalculationObject

Set if gr_cpubasedvolume is calculated approximative or exact. To use the exact calculation set approximative_calculation to 0. The default value is the approximative version, which can be set with the number 1.

Parameters:

  • approximative_calculation (Integer)

    exact or approximative calculation of the volume



# File 'lib/gr.rb', line 2467

.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.

Parameters:

  • size (Numeric)

    The arrow size to be used



# File 'lib/gr.rb', line 1795

.setarrowstyleObject

Set the arrow style to be used for subsequent arrow commands.

‘setarrowstyle` defines the arrow style for subsequent arrow primitives.

Parameters:

  • style (Integer)

    The arrow style to be used The default arrow style is 1.

    • 1 : simple, single-ended

    • 2 : simple, single-ended, acute head

    • 3 : hollow, single-ended

    • 4 : filled, single-ended

    • 5 : triangle, single-ended

    • 6 : filled triangle, single-ended

    • 7 : kite, single-ended

    • 8 : filled kite, single-ended

    • 9 : simple, double-ended

    • 10 : simple, double-ended, acute head

    • 11 : hollow, double-ended

    • 12 : filled, double-ended

    • 13 : triangle, double-ended

    • 14 : filled triangle, double-ended

    • 15 : kite, double-ended

    • 16 : filled kite, double-ended

    • 17 : double line, single-ended

    • 18 : double line, double-ended



# File 'lib/gr.rb', line 1769

.setbordercolorindObject

Define the color of subsequent path output primitives.

Parameters:

  • color (Integer)

    The border color index (COLOR < 1256)



2258
2259
2260
# File 'lib/gr.rb', line 2258

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

.setborderwidthObject

Define the border width of subsequent path output primitives.

Parameters:

  • width (Numeric)

    The border width scale factor



2248
2249
2250
# File 'lib/gr.rb', line 2248

def inqborderwidth
  inquiry_double { |pt| super(pt) }
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.

Parameters:

  • factor (Numeric)

    Text expansion factor applied to the nominal text width-to-height ratio



# File 'lib/gr.rb', line 698

.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).

Parameters:

  • height (Numeric)

    Text height value



# File 'lib/gr.rb', line 731

.setcharspaceObject



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

.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.

Parameters:

  • ux (Numeric)

    X coordinate of the text up vector

  • uy (Numeric)

    Y coordinate of the text up vector



# File 'lib/gr.rb', line 752

.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.

Parameters:

  • indicator (Integer)

    An indicator specifying whether clipping is on or off.



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

.setclipregionObject



2524
2525
2526
# File 'lib/gr.rb', line 2524

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

.setclipsectorObject



2530
2531
2532
2533
2534
# File 'lib/gr.rb', line 2530

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

.setcolormapObject

Set the currently used colormap.

Using a negative index will use the reverse of the selected colormap.

Parameters:

  • index (Integer)

    Colormap index



# File 'lib/gr.rb', line 1516

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

Note:

GR.jl and python-gr have different APIsI

Define a colormap by a list of RGB colors. This function defines a colormap using the n given color intensities. If less than 256 colors are provided the colors intensities are linear interpolated. If x is NULL the given color values are evenly distributed in the colormap. Otherwise the normalized value of x defines the position of the color in the colormap.

Parameters:

  • r (Array, NArray)

    The red intensities in range 0.0 to 1.0

  • g (Array, NArray)

    The green intensities in range 0.0 to 1.0

  • b (Array, NArray)

    The blue intensities in range 0.0 to 1.0

  • positions (Array, NArray) (defaults to: nil)

    The positions of the corresponding color in the resulting colormap or nil. The values of positions must increase monotonically from 0.0 to 1.0. If positions is nil the given colors are evenly distributed in the colormap.



1547
1548
1549
1550
1551
1552
1553
1554
1555
# File 'lib/gr.rb', line 1547

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

Redefine an existing color index representation by specifying an RGB color triplet.

Parameters:

  • index (Integer)

    Color index in the range 0 to 1256

  • red (Numeric)

    Red intensity in the range 0.0 to 1.0

  • green (Numeric)

    Green intensity in the range 0.0 to 1.0

  • blue (Numeric)

    Blue intensity in the range 0.0 to 1.0



# File 'lib/gr.rb', line 866

.setcoordxform(mat) ⇒ Object

Change the coordinate transformation according to the given matrix.

Parameters:

  • mat (Array, NArray)

    2D transformation matrix



1881
1882
1883
1884
1885
# File 'lib/gr.rb', line 1881

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.

Parameters:

  • color (Integer)

    The text color index (COLOR < 1256)



# File 'lib/gr.rb', line 841

.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.

Parameters:

  • style (Integer)

    The style of fill to be used

    • 0 : HOLLOW - No filling. Just draw the bounding polyline

    • 1 : SOLID - Fill the interior of the polygon using the fill color index

    • 2 : PATTERN - Fill the interior of the polygon using the style index as a pattern index

    • 3 : HATCH - Fill the interior of the polygon using the style index as a cross-hatched style

    • 4 : SOLID_WITH_BORDER - Fill the interior of the polygon using the fill color index and draw the bounding polyline



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

.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.

Parameters:

  • index (Integer)

    The fill style index to be used



# File 'lib/gr.rb', line 819

.setlinecolorindObject

Define the color of subsequent polyline output primitives.

Parameters:

  • color (Integer)

    The polyline color index (COLOR < 1256)



566
567
568
# File 'lib/gr.rb', line 566

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

.setlinetypeObject

Specify the line style for polylines.

Parameters:

  • style (Integer)

    The polyline line style

    • 1 : LINETYPE_SOLID - Solid line

    • 2 : LINETYPE_DASHED - Dashed line

    • 3 : LINETYPE_DOTTED - Dotted line

    • 4 : LINETYPE_DASHED_DOTTED - Dashed-dotted line

    • -1 : LINETYPE_DASH_2_DOT - Sequence of one dash followed by two dots

    • -2 : LINETYPE_DASH_3_DOT - Sequence of one dash followed by three dots

    • -3 : LINETYPE_LONG_DASH - Sequence of long dashes

    • -4 : LINETYPE_LONG_SHORT_DASH - Sequence of a long dash followed by a short dash

    • -5 : LINETYPE_SPACED_DASH - Sequence of dashes double spaced

    • -6 : LINETYPE_SPACED_DOT - Sequence of dots double spaced

    • -7 : LINETYPE_DOUBLE_DOT - Sequence of pairs of dots

    • -8 : LINETYPE_TRIPLE_DOT - Sequence of groups of three dots



541
542
543
# File 'lib/gr.rb', line 541

def inqlinetype
  inquiry_int { |pt| super(pt) }
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.

Parameters:

  • width (Numeric)

    The polyline line width scale factor



556
557
558
# File 'lib/gr.rb', line 556

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

.setmarkercolorindObject

Define the color of subsequent polymarker output primitives.

Parameters:

  • color (Integer)

    The polymarker color index (COLOR < 1256)



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

def inqmarkercolorind
  inquiry_int { |pt| super(pt) }
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.

Parameters:

  • size (Numeric)

    Scale factor applied to the nominal marker size



# File 'lib/gr.rb', line 619

.setmarkertypeObject

Specify the marker type for polymarkers.

Polymarkers appear centered over their specified coordinates.

Parameters:

  • style (Integer)

    The polymarker marker type

    • 1 : MARKERTYPE_DOT - Smallest displayable dot

    • 2 : MARKERTYPE_PLUS - Plus sign

    • 3 : MARKERTYPE_ASTERISK - Asterisk

    • 4 : MARKERTYPE_CIRCLE - Hollow circle

    • 5 : MARKERTYPE_DIAGONAL_CROSS - Diagonal cross

    • -1 : MARKERTYPE_SOLID_CIRCLE - Filled circle

    • -2 : MARKERTYPE_TRIANGLE_UP - Hollow triangle pointing upward

    • -3 : MARKERTYPE_SOLID_TRI_UP - Filled triangle pointing upward

    • -4 : MARKERTYPE_TRIANGLE_DOWN - Hollow triangle pointing downward

    • -5 : MARKERTYPE_SOLID_TRI_DOWN - Filled triangle pointing downward

    • -6 : MARKERTYPE_SQUARE - Hollow square

    • -7 : MARKERTYPE_SOLID_SQUARE - Filled square

    • -8 : MARKERTYPE_BOWTIE - Hollow bowtie

    • -9 : MARKERTYPE_SOLID_BOWTIE - Filled bowtie

    • -10 : MARKERTYPE_HGLASS - Hollow hourglass

    • -11 : MARKERTYPE_SOLID_HGLASS - Filled hourglass

    • -12 : MARKERTYPE_DIAMOND - Hollow diamond

    • -13 : MARKERTYPE_SOLID_DIAMOND - Filled Diamond

    • -14 : MARKERTYPE_STAR - Hollow star

    • -15 : MARKERTYPE_SOLID_STAR - Filled Star

    • -16 : MARKERTYPE_TRI_UP_DOWN - Hollow triangles pointing up and down overlaid

    • -17 : MARKERTYPE_SOLID_TRI_RIGHT - Filled triangle point right

    • -18 : MARKERTYPE_SOLID_TRI_LEFT - Filled triangle pointing left

    • -19 : MARKERTYPE_HOLLOW PLUS - Hollow plus sign

    • -20 : MARKERTYPE_SOLID PLUS - Solid plus sign

    • -21 : MARKERTYPE_PENTAGON - Pentagon

    • -22 : MARKERTYPE_HEXAGON - Hexagon

    • -23 : MARKERTYPE_HEPTAGON - Heptagon

    • -24 : MARKERTYPE_OCTAGON - Octagon

    • -25 : MARKERTYPE_STAR_4 - 4-pointed star

    • -26 : MARKERTYPE_STAR_5 - 5-pointed star (pentagram)

    • -27 : MARKERTYPE_STAR_6 - 6-pointed star (hexagram)

    • -28 : MARKERTYPE_STAR_7 - 7-pointed star (heptagram)

    • -29 : MARKERTYPE_STAR_8 - 8-pointed star (octagram)

    • -30 : MARKERTYPE_VLINE - vertical line

    • -31 : MARKERTYPE_HLINE - horizontal line

    • -32 : MARKERTYPE_OMARK - o-mark



615
616
617
# File 'lib/gr.rb', line 615

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

.setmathfontObject



2518
2519
2520
# File 'lib/gr.rb', line 2518

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

.setorthographicprojectionObject

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

Parameters:

  • left (Numeric)

    xmin of the volume in worldcoordinates

  • right (Numeric)

    xmax of volume in worldcoordinates

  • bottom (Numeric)

    ymin of volume in worldcoordinates

  • top (Numeric)

    ymax of volume in worldcoordinates

  • near_plane (Numeric)

    distance to near clipping plane

  • far_plane (Numeric)

    distance to far clipping plane



# File 'lib/gr.rb', line 2324

.setperspectiveprojectionObject

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

Parameters:

  • near_plane (Numeric)

    distance to near clipping plane

  • far_plane (Numeric)

    distance to far clipping plane

  • fov (Numeric)

    vertical field of view, input must be between 0 and 180 degrees



# File 'lib/gr.rb', line 2283

.setpicturesizeforvolumeObject

Set the width and height of the resulting picture. These values are only used for gr_volume and gr_cpubasedvolume. The default values are 1000 for both.

Parameters:

  • width (Integer)

    width of the resulting image

  • height (Integer)

    height of the resulting image



# File 'lib/gr.rb', line 2446

.setprojectiontypeObject

Set the projection type with this flag.

Parameters:

  • flag (Integer)

    projection type The available options are:

    • 0 : PROJECTION_DEFAULT - default

    • 1 : PROJECTION_ORTHOGRAPHIC - orthographic

    • 2 : PROJECTION_PERSPECTIVE - perspective



# File 'lib/gr.rb', line 2268

.setregenflagsObject



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

.setresamplemethodObject

Set the resample method used for ‘drawimage`.

Parameters:

  • resample_method (Integer)

    the new resample method. The available options are:

    • 0x00000000 : RESAMPLE_DEFAULT

      • default

    • 0x01010101 : RESAMPLE_NEAREST

      • nearest neighbour

    • 0x02020202 : RESAMPLE_LINEAR

      • linear

    • 0x03030303 : RESAMPLE_LANCZOS

      • Lanczos

    Alternatively, combinations of these methods can be selected for horizontal or vertical upsampling or downsampling:

    • 0x00000000 : UPSAMPLE_VERTICAL_DEFAULT

      • default for vertical upsampling

    • 0x00000000 : UPSAMPLE_HORIZONTAL_DEFAULT

      • default for horizontal upsampling

    • 0x00000000 : DOWNSAMPLE_VERTICAL_DEFAULT

      • default for vertical downsampling

    • 0x00000000 : DOWNSAMPLE_HORIZONTAL_DEFAULT

      • default for horizontal downsampling

    • 0x00000001 : UPSAMPLE_VERTICAL_NEAREST

      • nearest neighbor for vertical upsampling

    • 0x00000100 : UPSAMPLE_HORIZONTAL_NEAREST

      • nearest neighbor for horizontal upsampling

    • 0x00010000 : DOWNSAMPLE_VERTICAL_NEAREST

      • nearest neighbor for vertical downsampling

    • 0x01000000 : DOWNSAMPLE_HORIZONTAL_NEAREST

      • nearest neighbor for horizontal downsampling

    • 0x00000002 : UPSAMPLE_VERTICAL_LINEAR

      • linear for vertical upsampling

    • 0x00000200 : UPSAMPLE_HORIZONTAL_LINEAR

      • linear for horizontal upsampling

    • 0x00020000 : DOWNSAMPLE_VERTICAL_LINEAR

      • linear for vertical downsampling

    • 0x02000000 : DOWNSAMPLE_HORIZONTAL_LINEAR

      • linear for horizontal downsampling

    • 0x00000003 : UPSAMPLE_VERTICAL_LANCZOS

      • lanczos for vertical upsampling

    • 0x00000300 : UPSAMPLE_HORIZONTAL_LANCZOS

      • lanczos for horizontal upsampling

    • 0x00030000 : DOWNSAMPLE_VERTICAL_LANCZOS

      • lanczos for vertical downsampling

    • 0x03000000 : DOWNSAMPLE_HORIZONTAL_LANCZOS

      • lanczos for horizontal downsampling



# File 'lib/gr.rb', line 2138

.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.

Parameters:

  • options (Integer)

    Scale specification

    • 1 : OPTION_X_LOG - Logarithmic X-axis

    • 2 : OPTION_Y_LOG - Logarithmic Y-axis

    • 4 : OPTION_Z_LOG - Logarithmic Z-axis

    • 8 : OPTION_FLIP_X - Flip X-axis

    • 16 : OPTION_FLIP_Y - Flip Y-axis

    • 32 : OPTION_FLIP_Z - Flip Z-axis

Returns:

  • (Integer)


# File 'lib/gr.rb', line 1036

.setscalefactors3dObject

Set the scale factor for each axis. A one means no scale. The scaling factors must not be zero. .

Parameters:

  • x_axis_scale (Numeric)

    factor for scaling the x-axis

  • y_axis_scale (Numeric)

    factor for scaling the y-axis

  • z_axis_scale (Numeric)

    factor for scaling the z-axis



# File 'lib/gr.rb', line 2375

.setsegtranObject



# File 'lib/gr.rb', line 1003

.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.

Parameters:

  • offsetx (Numeric)

    An x-offset, which specifies how far in the horizontal direction the shadow is offset from the object

  • offsety (Numeric)

    A y-offset, which specifies how far in the vertical direction the shadow is offset from the object

  • blur (Numeric)

    A blur value, which specifies whether the object has a hard or a diffuse edge



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

.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°.

Parameters:

  • zmin (Numeric)

    Minimum value for the Z-axis.

  • zmax (Numeric)

    Maximum value for the Z-axis.

  • rotation (Integer)

    Angle for the rotation of the X axis, in degrees.

  • tilt (integer)

    Viewing angle of the Z axis in degrees.

Returns:

  • (Integer)


1030
1031
1032
1033
1034
# File 'lib/gr.rb', line 1030

def inqspace
  inquiry %i[double double int int] do |*pts|
    super(*pts)
  end
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 ‘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.

Parameters:

  • phi (Numeric)

    azimuthal angle of the spherical coordinates

  • theta (Numeric)

    polar angle of the spherical coordinates

  • fov (Numeric)

    vertical field of view (0 or NaN for orthographic projection)

  • camera_distance (Numeric)

    distance between the camera and the focus point (0 or NaN for the radius of the object’s smallest bounding sphere)



# File 'lib/gr.rb', line 2392

.settextalignObject

  • 1 : TEXT_HALIGN_LEFT - Left justify

  • 2 : TEXT_HALIGN_CENTER - Center justify

  • 3 : TEXT_HALIGN_RIGHT - Right justify

‘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.

Parameters:

  • vertical (Integer)

    Vertical text alignment

    • 0 : TEXT_VALIGN_NORMAL

    • 1 : TEXT_VALIGN_TOP - Align with the top of the characters

    • 2 : TEXT_VALIGN_CAP - Aligned with the cap of the characters

    • 3 : TEXT_VALIGN_HALF - Aligned with the half line of the characters

    • 4 : TEXT_VALIGN_BASE - Aligned with the base line of the characters

    • 5 : TEXT_VALIGN_BOTTOM - Aligned with the bottom line of the characters



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

.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.

Parameters:

  • color (Integer)

    The text color index (COLOR < 1256)



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

.settextencodingObject



2419
2420
2421
2422
2423
# File 'lib/gr.rb', line 2419

def inqtextencoding
  inquiry_int do |encoding|
    super(encoding)
  end
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 using either native font rendering or FreeType. OUTLINE uses the GR path rendering functions to draw individual glyphs and produces the highest quality output.

Parameters:

  • font (Integer)

    Text font

    • 101 : FONT_TIMES_ROMAN

    • 102 : FONT_TIMES_ITALIC

    • 103 : FONT_TIMES_BOLD

    • 104 : FONT_TIMES_BOLDITALIC

    • 105 : FONT_HELVETICA

    • 106 : FONT_HELVETICA_OBLIQUE

    • 107 : FONT_HELVETICA_BOLD

    • 108 : FONT_HELVETICA_BOLDOBLIQUE

    • 109 : FONT_COURIER

    • 110 : FONT_COURIER_OBLIQUE

    • 111 : FONT_COURIER_BOLD

    • 112 : FONT_COURIER_BOLDOBLIQUE

    • 113 : FONT_SYMBOL

    • 114 : FONT_BOOKMAN_LIGHT

    • 115 : FONT_BOOKMAN_LIGHTITALIC

    • 116 : FONT_BOOKMAN_DEMI

    • 117 : FONT_BOOKMAN_DEMIITALIC

    • 118 : FONT_NEWCENTURYSCHLBK_ROMAN

    • 119 : FONT_NEWCENTURYSCHLBK_ITALIC

    • 120 : FONT_NEWCENTURYSCHLBK_BOLD

    • 121 : FONT_NEWCENTURYSCHLBK_BOLDITALIC

    • 122 : FONT_AVANTGARDE_BOOK

    • 123 : FONT_AVANTGARDE_BOOKOBLIQUE

    • 124 : FONT_AVANTGARDE_DEMI

    • 125 : FONT_AVANTGARDE_DEMIOBLIQUE

    • 126 : FONT_PALATINO_ROMAN

    • 127 : FONT_PALATINO_ITALIC

    • 128 : FONT_PALATINO_BOLD

    • 129 : FONT_PALATINO_BOLDITALIC

    • 130 : FONT_ZAPFCHANCERY_MEDIUMITALIC

    • 131 : FONT_ZAPFDINGBATS

    • 232 : FONT_COMPUTERMODERN

    • 233 : FONT_DEJAVUSANS

  • precision (Integer)

    Text precision

    • 0 : TEXT_PRECISION_STRING - String precision (higher quality)

    • 1 : TEXT_PRECISION_CHAR - Character precision (medium quality)

    • 2 : TEXT_PRECISION_STROKE - Stroke precision (lower quality)

    • 3 : TEXT_PRECISION_OUTLINE - Outline precision (highest quality)



# File 'lib/gr.rb', line 646

.settextpathObject

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

Parameters:

  • path (Integer)

    Text path

    • 0 : TEXT_PATH_RIGHT - left-to-right

    • 1 : TEXT_PATH_LEFT - right-to-left

    • 2 : TEXT_PATH_UP - downside-up

    • 3 : TEXT_PATH_DOWN - upside-down



# File 'lib/gr.rb', line 763

.setthreadnumberObject

Set the number of threads which can run parallel. The default value is the number of threads the cpu has.

Parameters:

  • num (Integer)

    num number of threads



# File 'lib/gr.rb', line 2439

.settransformationparametersObject

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

Parameters:

  • camera_pos_x (Numeric)

    x component of the cameraposition in world coordinates

  • camera_pos_y (Numeric)

    y component of the cameraposition in world coordinates

  • camera_pos_z (Numeric)

    z component of the cameraposition in world coordinates

  • up_x (Numeric)

    x component of the up vector

  • up_y (Numeric)

    y component of the up vector

  • up_z (Numeric)

    z component of the up vector

  • focus_point_x (Numeric)

    x component of focus-point inside volume

  • focus_point_y (Numeric)

    y component of focus-point inside volume

  • focus_point_z (Numeric)

    z component of focus-point inside volume



# File 'lib/gr.rb', line 2301

.settransparencyObject

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

Parameters:

  • alpha (Numeric)

    An alpha value (0.0 - 1.0)



# File 'lib/gr.rb', line 1871

.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.

Parameters:

  • xmin (Numeric)

    The left horizontal coordinate of the viewport.

  • xmax (Numeric)

    The right horizontal coordinate of the viewport (0 <= ‘xmin` < `xmax` <= 1).

  • ymin (Numeric)

    The bottom vertical coordinate of the viewport.

  • ymax (Numeric)

    The top vertical coordinate of the viewport (0 <= ‘ymin` < `ymax` <= 1).



# File 'lib/gr.rb', line 905

.setvolumebordercalculation(# @!method setthreadnumber) ⇒ Object

Set the gr_volume border type with this flag. This inflicts how the volume is calculated. When the flag is set to GR_VOLUME_WITH_BORDER the border will be calculated the same as the points inside the volume.

Parameters:

  • flag (Integer)

    calculation of the gr_volume border The available options are:

    • 0 : VOLUME_WITHOUT_BORDER - default value

    • 1 : VOLUME_WITH_BORDER - gr_volume with border



# File 'lib/gr.rb', line 2455

.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.

Parameters:

  • xmin (Numeric)

    The left horizontal coordinate of the window (‘xmin` < `xmax`).

  • xmax (Numeric)

    The right horizontal coordinate of the window.

  • ymin (Numeric)

    The bottom vertical coordinate of the window (‘ymin` < `ymax`).

  • ymax (Numeric)

    The top vertical coordinate of the window.



# File 'lib/gr.rb', line 876

.setwindow3dObject

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

Parameters:

  • xmin (Numeric)

    min x-value

  • xmax (Numeric)

    max x-value

  • ymin (Numeric)

    min y-value

  • ymax (Numeric)

    max y-value

  • zmin (Numeric)

    min z-value

  • zmax (Numeric)

    max z-value



# File 'lib/gr.rb', line 2356

.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.

Parameters:

  • xmin (Numeric)

    The left horizontal coordinate of the workstation viewport.

  • xmax (Numeric)

    The right horizontal coordinate of the workstation viewport.

  • ymin (Numeric)

    The bottom vertical coordinate of the workstation viewport.

  • ymax (Numeric)

    The top vertical coordinate of the workstation viewport.



# File 'lib/gr.rb', line 979

.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.

Parameters:

  • xmin (Numeric)

    The left horizontal coordinate of the workstation window.

  • xmax (Numeric)

    The right horizontal coordinate of the workstation window (0 <= ‘xmin` < `xmax` <= 1).

  • ymin (Numeric)

    The bottom vertical coordinate of the workstation window.

  • ymax (Numeric)

    The top vertical coordinate of the workstation window (0 <= ‘ymin` < `ymax` <= 1).



# File 'lib/gr.rb', line 959

.shade(*args) ⇒ Object

(Plot)



# File 'lib/gr.rb', line 2074

.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.

Parameters:

  • x (Array, NArray)

    A pointer to the X coordinates

  • y (Array, NArray)

    A pointer to the Y coordinates

  • dims (Array, NArray) (defaults to: [1200, 1200])

    The size of the grid used for rasterization

  • xform (Integer) (defaults to: 1)

    The transformation type used for color mapping The available transformation types are:

    • 0 : XFORM_BOOLEAN - boolean

    • 1 : XFORM_LINEAR - linear

    • 2 : XFORM_LOG - logarithmic

    • 3 : XFORM_LOGLOG - double logarithmic

    • 4 : XFORM_CUBIC - cubic

    • 5 : XFORM_EQUALIZED - histogram equalized



2119
2120
2121
2122
2123
# File 'lib/gr.rb', line 2119

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.

Parameters:

  • x (Array, NArray)

    A pointer to the X coordinates

  • y (Array, NArray)

    A pointer to the Y coordinates

  • dims (Array, NArray) (defaults to: [1200, 1200])

    The size of the grid used for rasterization

  • xform (Integer) (defaults to: 1)

    The transformation type used for color mapping The available transformation types are:

    • 0 : XFORM_BOOLEAN - boolean

    • 1 : XFORM_LINEAR - linear

    • 2 : XFORM_LOG - logarithmic

    • 3 : XFORM_LOGLOG - double logarithmic

    • 4 : XFORM_CUBIC - cubic

    • 5 : XFORM_EQUALIZED - histogram equalized



2096
2097
2098
2099
2100
# File 'lib/gr.rb', line 2096

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.

Parameters:

  • x (Array, NArray)

    A list containing the X coordinates

  • y (Array, NArray)

    A list containing the Y coordinates

  • m (Integer)

    The number of points in the polygon to be drawn (‘m` > len(`x`))

  • method (Integer)

    The smoothing method

    • If ‘method` is > 0, then a generalized cross-validated smoothing spline is calculated.

    • If ‘method` is 0, then an interpolating natural cubic spline is calculated.

    • If ‘method` is < -1, then a cubic B-spline is calculated.



501
502
503
504
# File 'lib/gr.rb', line 501

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

.stairs(*args) ⇒ Object

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



1565
1566
1567
# File 'lib/gr/plot.rb', line 1565

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

.startlistenerInteger

Returns:

  • (Integer)


2510
2511
2512
2513
2514
# File 'lib/gr.rb', line 2510

def startlistener
  inquiry_int do |ret|
    super(ret)
  end
end

.stem(*args) ⇒ Object

(Plot) Draw a stem plot.



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

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

.step(*args) ⇒ Object

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



1560
1561
1562
# File 'lib/gr/plot.rb', line 1560

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

.subplot(nr, nc, p, kv = {}) ⇒ Object

Set current subplot index.



1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
# File 'lib/gr/plot.rb', line 1800

def subplot(nr, nc, p, kv = {})
  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],
    # The policy of clearing when p[0]==1 is controversial
    clear: p[0] == 1,
    update: p[-1] == nr * nc
  }.merge kv
end

.surface(*args) ⇒ Object

Note:

‘surface` is overwritten by `require gr/plot`. The original method is moved to the underscored name. The yard document will show the method name after evacuation.

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:

Parameters:

  • x (Array, NArray)

    A list containing the X coordinates

  • y (Array, NArray)

    A list containing the Y coordinates

  • z (Array, NArray)

    A list of length ‘len(x)` * `len(y)` or an appropriately dimensioned array containing the Z coordinates

  • option (Integer)

    Surface display option

    • 0 LINES - Use X Y polylines to denote the surface

    • 1 MESH - Use a wire grid to denote the surface

    • 2 FILLED_MESH - Applies an opaque grid to the surface

    • 3 Z_SHADED_MESH - Applies Z-value shading to the surface

    • 4 COLORED_MESH - Applies a colored grid to the surface

    • 5 CELL_ARRAY - Applies a grid of individually-colored cells to the surface

    • 6 SHADED_MESH - Applies light source shading to the 3-D surface

Raises:

  • (ArgumentError)


1429
1430
1431
1432
1433
1434
1435
# File 'lib/gr.rb', line 1429

def surface(x, y, z, option)
  nx = x.length
  ny = y.length
  raise ArgumentError, "z must have length nx * ny (expected #{nx * ny}, got #{z.length})" if z.length != nx * ny

  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.

Parameters:

  • x (Numeric)

    The X coordinate of starting position of the text string

  • y (Numeric)

    The Y coordinate of starting position of the text string

  • string (String)

    The text to be drawn



# File 'lib/gr.rb', line 304

.text3dObject



2411
2412
2413
2414
2415
# File 'lib/gr.rb', line 2411

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

.text_maxsizeObject



# File 'lib/gr.rb', line 1939

.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 `mathtex` function.

Parameters:

  • x (Numeric)

    The X coordinate of starting position of the text string

  • y (Numeric)

    The Y coordinate of starting position of the text string

  • string (String)

    The text to be drawn

Returns:

  • (Integer)


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

.textxObject

Draw a text at position ‘x`, `y` using the given options and current text attributes.

GR_TEXT_ENABLE_INLINE_MATH)

The values for ‘x` and `y` specify the text position. If the GR_TEXT_USE_WC option is set, they are interpreted as world coordinates, otherwise as normalized device coordinates. The string may contain new line characters and inline math expressions ($…$). The latter are only taken into account, if the GR_TEXT_ENABLE_INLINE_MATH option is set. 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.

Parameters:

  • x (Numeric)

    The X coordinate of the starting position of the text string

  • y (Numeric)

    The Y coordinate of the starting position of the text string

  • string (String)

    The text to be drawn

  • opts (Integer)

    Bit mask including text options (GR_TEXT_USE_WC,



339
340
341
342
343
# File 'lib/gr.rb', line 339

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

.tickNumeric

Returns:

  • (Numeric)


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

.titles3dObject

Display axis titles just outside of their respective axes.

Parameters:

  • x_title (String)

    The text to be displayed on the X axis

  • x_title (String)

    The text to be displayed on the Y axis

  • x_title (String)

    The text to be displayed on the Z axis



# File 'lib/gr.rb', line 1397

.to_rgb_color(z) ⇒ Array, NArray

Parameters:

  • z (Array, NArray)

Returns:

  • (Array, NArray)


2232
2233
2234
2235
2236
2237
2238
2239
2240
# File 'lib/gr.rb', line 2232

def to_rgb_color(z)
  zmin, zmax = z.minmax
  return Array.new(z.length, 0) if zmax == zmin

  z.map  do |i|
    zi = (i - zmin) / (zmax - zmin).to_f
    inqcolor(1000 + (zi * 255).round)
  end
end

.tricont(*args) ⇒ Object

(Plot) Draw a triangular contour plot.



1693
1694
1695
# File 'lib/gr/plot.rb', line 1693

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.

Parameters:

  • x (Array, NArray)

    A list containing the X coordinates

  • y (Array, NArray)

    A list containing the Y coordinates

  • z (Array, NArray)

    A list containing the Z coordinates

  • levels (Array, NArray)

    A list of contour levels



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

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

.trisurf(*args) ⇒ Object

(Plot) Draw a triangular surface plot.



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

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.

Parameters:

  • x (Array, NArray)

    A list containing the X coordinates

  • y (Array, NArray)

    A list containing the Y coordinates

  • z (Array, NArray)

    A list containing the Z coordinates



1997
1998
1999
2000
# File 'lib/gr.rb', line 1997

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

.updategksObject



# File 'lib/gr.rb', line 1009

.updatewsObject

Update the specified workstation.



# File 'lib/gr.rb', line 223

.uselinespecInteger

Returns:

  • (Integer)


1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
# File 'lib/gr.rb', line 1957

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, Fiddle::RUBY_FREE)
  dim = 3
  n_tri = inquiry_int do |ntri|
    super(npoints, x, y, ntri, triangles.ref)
  end
  if n_tri > 0
    tri = triangles.to_str(dim * n_tri * Fiddle::SIZEOF_INT).unpack('l*') # Int32
    # Ruby  : 0-based indexing
    # Julia : 1-based indexing
    tri = tri.each_slice(dim).to_a
    [n_tri, tri]
  else
    0
  end
end

.validaterangeInteger

Returns:

  • (Integer)


1590
1591
1592
1593
1594
1595
1596
# File 'lib/gr.rb', line 1590

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

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

Draw a standard vertical error bar graph.

Parameters:

  • x (Array, NArray)

    A list of length N containing the X coordinates

  • y (Array, NArray)

    A list of length N containing the Y coordinates

  • e1 (Array, NArray)

    The absolute values of the lower error bar data

  • e2 (Array, NArray)

    The absolute values of the lower error bar data



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

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.

Returns:

  • (String)


2070
2071
2072
# File 'lib/gr.rb', line 2070

def version
  super.to_s
end

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

(Plot)



1735
1736
1737
1738
1739
# File 'lib/gr/plot.rb', line 1735

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

.wc3towc(x, y, z) ⇒ Object



1693
1694
1695
1696
1697
1698
1699
1700
# File 'lib/gr.rb', line 1693

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



1685
1686
1687
1688
1689
1690
1691
# File 'lib/gr.rb', line 1685

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.



1698
1699
1700
# File 'lib/gr/plot.rb', line 1698

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