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, 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- OPTION_X_LOG =
1- OPTION_Y_LOG =
2- OPTION_Z_LOG =
4- OPTION_FLIP_X =
8- OPTION_FLIP_Y =
16- OPTION_FLIP_Z =
32- OPTION_LINES =
0- OPTION_MESH =
1- OPTION_FILLED_MESH =
2- OPTION_Z_SHADED_MESH =
3- OPTION_COLORED_MESH =
4- OPTION_CELL_ARRAY =
5- OPTION_SHADED_MESH =
6- MODEL_RGB =
0- MODEL_HSV =
1- COLORMAP_UNIFORM =
0- COLORMAP_TEMPERATURE =
1- COLORMAP_GRAYSCALE =
2- COLORMAP_GLOWING =
3- COLORMAP_RAINBOWLIKE =
4- COLORMAP_GEOLOGIC =
5- COLORMAP_GREENSCALE =
6- COLORMAP_CYANSCALE =
7- COLORMAP_BLUESCALE =
8- COLORMAP_MAGENTASCALE =
9- COLORMAP_REDSCALE =
10- COLORMAP_FLAME =
11- COLORMAP_BROWNSCALE =
12- COLORMAP_PILATUS =
13- COLORMAP_AUTUMN =
14- COLORMAP_BONE =
15- COLORMAP_COOL =
16- COLORMAP_COPPER =
17- COLORMAP_GRAY =
18- COLORMAP_HOT =
19- COLORMAP_HSV =
20- COLORMAP_JET =
21- COLORMAP_PINK =
22- COLORMAP_SPECTRAL =
23- COLORMAP_SPRING =
24- COLORMAP_SUMMER =
25- COLORMAP_WINTER =
26- COLORMAP_GIST_EARTH =
27- COLORMAP_GIST_HEAT =
28- COLORMAP_GIST_NCAR =
29- COLORMAP_GIST_RAINBOW =
30- COLORMAP_GIST_STERN =
31- COLORMAP_AFMHOT =
32- COLORMAP_BRG =
33- COLORMAP_BWR =
34- COLORMAP_COOLWARM =
35- COLORMAP_CMRMAP =
36- COLORMAP_CUBEHELIX =
37- COLORMAP_GNUPLOT =
38- COLORMAP_GNUPLOT2 =
39- COLORMAP_OCEAN =
40- COLORMAP_RAINBOW =
41- COLORMAP_SEISMIC =
42- COLORMAP_TERRAIN =
43- COLORMAP_VIRIDIS =
44- COLORMAP_INFERNO =
45- COLORMAP_PLASMA =
46- COLORMAP_MAGMA =
47- FONT_TIMES_ROMAN =
101- FONT_TIMES_ITALIC =
102- FONT_TIMES_BOLD =
103- FONT_TIMES_BOLDITALIC =
104- FONT_HELVETICA =
105- FONT_HELVETICA_OBLIQUE =
106- FONT_HELVETICA_BOLD =
107- FONT_HELVETICA_BOLDOBLIQUE =
108- FONT_COURIER =
109- FONT_COURIER_OBLIQUE =
110- FONT_COURIER_BOLD =
111- FONT_COURIER_BOLDOBLIQUE =
112- FONT_SYMBOL =
113- FONT_BOOKMAN_LIGHT =
114- FONT_BOOKMAN_LIGHTITALIC =
115- FONT_BOOKMAN_DEMI =
116- FONT_BOOKMAN_DEMIITALIC =
117- FONT_NEWCENTURYSCHLBK_ROMAN =
118- FONT_NEWCENTURYSCHLBK_ITALIC =
119- FONT_NEWCENTURYSCHLBK_BOLD =
120- FONT_NEWCENTURYSCHLBK_BOLDITALIC =
121- FONT_AVANTGARDE_BOOK =
122- FONT_AVANTGARDE_BOOKOBLIQUE =
123- FONT_AVANTGARDE_DEMI =
124- FONT_AVANTGARDE_DEMIOBLIQUE =
125- FONT_PALATINO_ROMAN =
126- FONT_PALATINO_ITALIC =
127- FONT_PALATINO_BOLD =
128- FONT_PALATINO_BOLDITALIC =
129- FONT_ZAPFCHANCERY_MEDIUMITALIC =
130- FONT_ZAPFDINGBATS =
131- PRINT_PS =
GR.beginprint types
'ps'- PRINT_EPS =
'eps'- PRINT_PDF =
'pdf'- PRINT_PGF =
'pgf'- PRINT_BMP =
'bmp'- PRINT_JPEG =
'jpeg'- PRINT_JPG =
'jpg'- PRINT_PNG =
'png'- PRINT_TIFF =
'tiff'- PRINT_TIF =
'tif'- PRINT_FIG =
'fig'- PRINT_SVG =
'svg'- PRINT_WMF =
'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- VERSION =
GRCommons::VERSION
Constants included from GRCommons::GRCommonUtils
GRCommons::GRCommonUtils::SUPPORTED_TYPES
Class Attribute Summary collapse
-
.ffi_lib ⇒ Object
Returns the value of attribute ffi_lib.
Class Method Summary collapse
-
._contour_ ⇒ Object
Draw contours of a three-dimensional data set whose values are specified over a rectangular mesh.
-
._contourf_ ⇒ Object
Draw filled contours of a three-dimensional data set whose values are specified over a rectangular mesh.
- ._hexbin_ ⇒ Integer
- ._shade_ ⇒ Object
-
._surface_ ⇒ Object
Draw a three-dimensional surface plot for the given data points.
-
.activatews ⇒ Object
Activate the specified workstation.
- .adjustlimits(amin, amax) ⇒ Integer
- .adjustrange(amin, amax) ⇒ Object
-
.axes ⇒ Object
(also: axes2d)
Draw X and Y coordinate axes with linearly and/or logarithmically spaced tick marks.
-
.axes3d ⇒ Object
Draw X, Y and Z coordinate axes with linearly and/or logarithmically spaced tick marks.
-
.axeslbl ⇒ Object
Create axes in the current workspace and supply a custom function for changing the behaviour of the tick labels.
-
.barplot(labels, heights, kv = {}) ⇒ Object
(Plot) Draw a bar plot.
-
.begingraphics ⇒ Object
Open a file for graphics output.
-
.beginprint(file_path) ⇒ Object
Open and activate a print device.
-
.beginprintext ⇒ Object
Open and activate a print device with the given layout attributes.
- .beginselection ⇒ Object
-
.camerainteraction ⇒ Object
Rotate the current scene according to a virtual arcball.
-
.cellarray(xmin, xmax, ymin, ymax, dimx, dimy, color) ⇒ Object
Display rasterlike images in a device-independent manner.
-
.clearws ⇒ Object
Clear the specified workstation.
- .closegks ⇒ Object
- .closeseg ⇒ Object
-
.closews ⇒ Object
Close the specified workstation.
- .colorbar ⇒ Object
-
.configurews ⇒ Object
Configure the specified workstation.
-
.contour(*args) ⇒ Object
(Plot) Draw a contour plot.
-
.contourf(*args) ⇒ Object
(Plot) Draw a filled contour plot.
- .copysegws ⇒ Object
- .createseg ⇒ Object
-
.deactivatews ⇒ Object
Deactivate the specified workstation.
- .delaunay(x, y) ⇒ Integer
- .destroycontext ⇒ Object
-
.drawarc ⇒ Object
Draw a circular or elliptical arc covering the specified rectangle.
-
.drawarrow ⇒ Object
Draw an arrow between two points.
- .drawgraphics ⇒ Integer
-
.drawimage(xmin, xmax, ymin, ymax, width, height, data, model = 0) ⇒ Object
Draw an image into a given rectangular area.
-
.drawpath(points, codes, fill) ⇒ Object
Draw simple and compound outlines consisting of line segments and bezier curves.
-
.drawrect ⇒ Object
Draw a rectangle using the current line attributes.
- .emergencyclosegks ⇒ Object
- .endgraphics ⇒ Object
- .endprint ⇒ Object
- .endselection ⇒ Object
-
.fillarc ⇒ Object
Fill a circular or elliptical arc covering the specified rectangle.
-
.fillarea(x, y) ⇒ Object
Allows you to specify a polygonal shape of an area to be filled.
-
.fillrect ⇒ Object
Draw a filled rectangle using the current fill attributes.
- .findboundary ⇒ Object
-
.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.
- .getgraphics ⇒ String
- .gradient(x, y, z) ⇒ Object deprecated Deprecated.
-
.grid ⇒ Object
Draw a linear and/or logarithmic grid.
-
.grid3d ⇒ Object
Draw a linear and/or logarithmic grid.
-
.gridit(xd, yd, zd, nx, ny) ⇒ Object
Interpolate data from arbitrary points at points on a rectangular grid.
-
.heatmap(*args) ⇒ Object
(Plot) Draw a heatmap.
-
.herrorbars(x, y, e1, e2) ⇒ Object
Draw a standard horizontal error bar graph.
-
.hexbin(*args) ⇒ Object
(Plot) Draw a hexagon binning plot.
-
.histogram(series, kv = {}) ⇒ Object
(Plot) Draw a histogram.
- .hold(flag = true) ⇒ Object
- .hsvtorgb(h, s, v) ⇒ Integer
- .importgraphics ⇒ Integer
-
.imshow(img, kv = {}) ⇒ Object
(Plot) Draw an image.
- .initgr ⇒ Object
- .inqbbox ⇒ Object
-
.inqbordercolorind ⇒ Object
Define the color of subsequent path output primitives.
-
.inqborderwidth ⇒ Object
Define the border width of subsequent path output primitives.
-
.inqcharheight ⇒ Numeric
Gets the current character height.
- .inqclipxform ⇒ Object
- .inqcolor(color) ⇒ Object
- .inqcolorfromrgb ⇒ Integer
-
.inqcolormap ⇒ Object
inqcolormap.
-
.inqdspsize ⇒ Array
Get the current display size.
-
.inqfillcolorind ⇒ Integer
Returns the current fill area color index.
-
.inqfillintstyle ⇒ Integer
Returns the fill area interior style to be used for fill areas.
-
.inqfillstyle ⇒ Integer
Returns the current fill area color index.
-
.inqlinecolorind ⇒ Object
Define the color of subsequent polyline output primitives.
-
.inqlinetype ⇒ Object
Specify the line style for polylines.
-
.inqlinewidth ⇒ Object
Define the line width of subsequent polyline output primitives.
-
.inqmarkercolorind ⇒ Object
Define the color of subsequent polymarker output primitives.
-
.inqmarkersize ⇒ Numeric
Inquire the marker size for polymarkers.
-
.inqmarkertype ⇒ Object
Specifiy the marker type for polymarkers.
-
.inqmathtex(x, y, string) ⇒ Object
inqmathtex.
-
.inqorthographicprojection ⇒ Object
Return the camera position, up vector and focus point.
-
.inqperspectiveprojection ⇒ Object
Return the parameters for the perspective projection.
-
.inqprojectiontype ⇒ Object
Return the projection type.
- .inqregenflags ⇒ Integer
-
.inqresamplemethod ⇒ Integer
Inquire the resample method used for
drawimage. -
.inqscale ⇒ Object
inqscale.
-
.inqscalefactors3d ⇒ Object
Returns the scale factors for each axis.
-
.inqspace ⇒ Integer
Set the abstract Z-space used for mapping three-dimensional output primitives into the current world coordinate space.
-
.inqtext(x, y, string) ⇒ Object
Draw a text at position
x,yusing the current text attributes. - .inqtext3d(x, y, z, string, axis) ⇒ Object
-
.inqtextcolorind ⇒ Integer
Gets the current text color index.
- .inqtextencoding ⇒ Object
-
.inqtextext(x, y, string) ⇒ Object
inqtextext.
-
.inqtransformationparameters ⇒ Object
Return the camera position, up vector and focus point.
-
.inqviewport ⇒ Object
inqviewport.
-
.inqwindow ⇒ Object
inqwindow.
-
.inqwindow3d ⇒ Object
Return the three dimensional window.
-
.interp2(x, y, z, xq, yq, method, extrapval) ⇒ Object
Interpolation in two dimensions using one of four different methods.
-
.isosurface(v, kv = {}) ⇒ Object
(Plot) Draw an isosurface.
-
.loadfont(str) ⇒ Object
Load a font file from a given filename.
-
.mathtex ⇒ Object
Generate a character string starting at the given location.
- .moveselection ⇒ Object
- .ndctowc(x, y) ⇒ Object
-
.nonuniformcellarray(x, y, dimx, dimy, color) ⇒ Object
Display a two dimensional color index array with nonuniform cell sizes.
-
.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.
-
.nonuniformpolarheatmap(*args) ⇒ Object
(Plot) Draw a nonuniformpolarheatmap.
- .opengks ⇒ Object
-
.openws ⇒ Object
Open a graphical workstation.
-
.panzoom(x, y, zoom) ⇒ Object
panzoom.
-
.path(x, y, codes) ⇒ Object
Draw paths using the given vertices and path codes.
-
.plot(*args) ⇒ Object
(Plot) Draw one or more line plots.
-
.plot3(*args) ⇒ Object
(Plot) Draw one or more three-dimensional line plots.
-
.polar(*args) ⇒ Object
(Plot).
-
.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.
-
.polarheatmap(*args) ⇒ Object
(Plot) Draw a polarheatmap.
-
.polarhistogram(x, kv = {}) ⇒ Object
(Plot).
-
.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.
-
.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.
-
.polymarker(x, y, markersize = nil, marker_z = nil) ⇒ Object
Draw marker symbols centered at the given data points.
-
.polymarker3d(x, y, z) ⇒ Object
Draw marker symbols centered at the given 3D data points.
- .precision ⇒ Numeric
-
.quiver(x, y, u, v, color) ⇒ Object
Draw a quiver plot on a grid of nx*ny points.
- .readimage(path) ⇒ Integer
- .redrawsegws ⇒ Object
-
.reducepoints(xd, yd, n) ⇒ Object
Reduces the number of points of the x and y array.
- .resizeselection ⇒ Object
- .restorestate ⇒ Object
-
.savefig(filename, kv = {}) ⇒ Object
(Plot) Save the current figure to a file.
- .savestate ⇒ Object
-
.scatter(*args) ⇒ Object
(Plot) Draw one or more scatter plots.
-
.scatter3(*args) ⇒ Object
(Plot) Draw one or more three-dimensional scatter plots.
- .selectclipxform ⇒ Object
- .selectcontext ⇒ Object
-
.selntran ⇒ Object
selntranselects a predefined transformation from world coordinates to normalized device coordinates. -
.setarrowsize ⇒ Object
Set the arrow size to be used for subsequent arrow commands.
-
.setarrowstyle ⇒ Object
Set the arrow style to be used for subsequent arrow commands.
-
.setbordercolorind ⇒ Object
Define the color of subsequent path output primitives.
-
.setborderwidth ⇒ Object
Define the border width of subsequent path output primitives.
-
.setcharexpan ⇒ Object
Set the current character expansion factor (width to height ratio).
-
.setcharheight ⇒ Object
Set the current character height.
- .setcharspace ⇒ Object
-
.setcharup ⇒ Object
Set the current character text angle up vector.
-
.setclip ⇒ Object
Set the clipping indicator.
-
.setcolormap ⇒ Object
Set the currently used colormap.
-
.setcolormapfromrgb(r, g, b, positions: nil) ⇒ Object
Define a colormap by a list of RGB colors.
-
.setcolorrep ⇒ Object
Redefine an existing color index representation by specifying an RGB color triplet.
-
.setcoordxform(mat) ⇒ Object
Change the coordinate transformation according to the given matrix.
-
.setfillcolorind ⇒ Object
Sets the current fill area color index.
-
.setfillintstyle ⇒ Object
Set the fill area interior style to be used for fill areas.
-
.setfillstyle ⇒ Object
Sets the fill style to be used for subsequent fill areas.
-
.setlinecolorind ⇒ Object
Define the color of subsequent polyline output primitives.
-
.setlinetype ⇒ Object
Specify the line style for polylines.
-
.setlinewidth ⇒ Object
Define the line width of subsequent polyline output primitives.
-
.setmarkercolorind ⇒ Object
Define the color of subsequent polymarker output primitives.
-
.setmarkersize ⇒ Object
Specify the marker size for polymarkers.
-
.setmarkertype ⇒ Object
Specifiy the marker type for polymarkers.
-
.setorthographicprojection ⇒ Object
Set parameters for orthographic transformation.
-
.setperspectiveprojection ⇒ Object
Set the far and near clipping plane for perspective projection and the vertical field ov view.
-
.setprojectiontype ⇒ Object
Set the projection type with this flag.
- .setregenflags ⇒ Object
-
.setresamplemethod ⇒ Object
Set the resample method used for
drawimage. -
.setscale ⇒ Integer
setscalesets the type of transformation to be used for subsequent GR output primitives. -
.setscalefactors3d ⇒ Object
Set the scale factor for each axis.
- .setsegtran ⇒ Object
-
.setshadow ⇒ Object
setshadowallows 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. -
.setspace ⇒ Integer
Set the abstract Z-space used for mapping three-dimensional output primitives into the current world coordinate space.
-
.setspace3d ⇒ Object
Set the camera for orthographic or perspective projection.
-
.settextalign ⇒ Object
-
1 : TEXT_HALIGN_LEFT - Left justify * 2 : TEXT_HALIGN_CENTER - Center justify * 3 : TEXT_HALIGN_RIGHT - Right justify.
-
-
.settextcolorind ⇒ Object
Sets the current text color index.
- .settextencoding ⇒ Object
-
.settextfontprec ⇒ Object
Specify the text font and precision for subsequent text output primitives.
-
.settextpath ⇒ Object
Define the current direction in which subsequent text will be drawn.
-
.settransformationparameters ⇒ Object
Method to set the camera position, the upward facing direction and the focus point of the shown volume.
-
.settransparency ⇒ Object
Set the value of the alpha component associated with GR colors.
-
.setviewport ⇒ Object
setviewportestablishes a rectangular subspace of normalized device coordinates. -
.setwindow ⇒ Object
setwindowestablishes a window, or rectangular subspace, of world coordinates to be plotted. -
.setwindow3d ⇒ Object
Set the three dimensional window.
-
.setwsviewport ⇒ Object
Define the size of the workstation graphics window in meters.
-
.setwswindow ⇒ Object
Set the area of the NDC viewport that is to be drawn in the workstation window.
-
.shade(*args) ⇒ Object
(Plot).
-
.shadelines(x, y, dims: [1200, 1200], xform: 1) ⇒ Object
Display a line set as an aggregated and rasterized image.
-
.shadepoints(x, y, dims: [1200, 1200], xform: 1) ⇒ Object
Display a point set as a aggregated and rasterized image.
-
.spline(x, y, m, method) ⇒ Object
Generate a cubic spline-fit, starting from the first data point and ending at the last data point.
-
.stem(*args) ⇒ Object
(Plot) Draw a stem plot.
-
.step(*args) ⇒ Object
(Plot) Draw one or more step or staircase plots.
-
.subplot(nr, nc, p, kv = {}) ⇒ Object
Set current subplot index.
-
.surface(*args) ⇒ Object
Draw a three-dimensional surface plot for the given data points.
-
.text ⇒ Object
Draw a text at position
x,yusing the current text attributes. - .text3d ⇒ Object
-
.textext ⇒ Integer
Draw a text at position
x,yusing the current text attributes. - .tick ⇒ Numeric
-
.titles3d ⇒ Object
Display axis titles just outside of their respective axes.
- .to_rgb_color(z) ⇒ Array, NArray
-
.tricont(*args) ⇒ Object
(Plot) Draw a triangular contour plot.
-
.tricontour(x, y, z, levels) ⇒ Object
Draw a contour plot for the given triangle mesh.
-
.trisurf(*args) ⇒ Object
(Plot) Draw a triangular surface plot.
-
.trisurface(x, y, z) ⇒ Object
Draw a triangular surface plot for the given data points.
- .updategks ⇒ Object
-
.updatews ⇒ Object
Update the specified workstation.
- .uselinespec ⇒ Integer
- .validaterange ⇒ Integer
-
.verrorbars(x, y, e1, e2) ⇒ Object
Draw a standard vertical error bar graph.
-
.version ⇒ String
Returns the combined version strings of the GR runtime.
-
.volume(v, kv = {}) ⇒ Object
(Plot).
- .wc3towc(x, y, z) ⇒ Object
- .wctondc(x, y) ⇒ Object
-
.wireframe(*args) ⇒ Object
(Plot) Draw a three-dimensional wireframe plot.
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
Class Attribute Details
.ffi_lib ⇒ Object
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
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.
1314 1315 1316 1317 1318 1319 1320 |
# File 'lib/gr/plot.rb', line 1314 def contour(x, y, h, z, major_h) # TODO: check: Arrays have incorrect length or dimension. nx = x.length ny = y.length nh = h.length super(nx, ny, nh, x, y, h, z, major_h) end |
._contourf_ ⇒ Object
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.
1320 1321 1322 1323 1324 1325 1326 |
# File 'lib/gr/plot.rb', line 1320 def contourf(x, y, h, z, major_h) # TODO: check: Arrays have incorrect length or dimension. nx = x.length ny = y.length nh = h.length super(nx, ny, nh, x, y, h, z, major_h) end |
._hexbin_ ⇒ Integer
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.
1326 1327 1328 1329 |
# File 'lib/gr/plot.rb', line 1326 def hexbin(x, y, nbins) n = x.length super(n, x, y, nbins) end |
._shade_ ⇒ Object
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 1368
|
._surface_ ⇒ Object
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.
1343 1344 1345 1346 1347 1348 |
# File 'lib/gr/plot.rb', line 1343 def surface(x, y, z, option) # TODO: check: Arrays have incorrect length or dimension. nx = x.length ny = y.length super(nx, ny, x, y, z, option) end |
.activatews ⇒ Object
Activate the specified workstation.
|
|
# File 'lib/gr.rb', line 151
|
.adjustlimits(amin, amax) ⇒ Integer
1440 1441 1442 1443 1444 1445 1446 |
# File 'lib/gr.rb', line 1440 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
1448 1449 1450 1451 1452 1453 1454 |
# File 'lib/gr.rb', line 1448 def adjustrange(amin, amax) inquiry i[double double] do |pamin, pamax| pamin.write_double amin pamax.write_double amax super(pamin, pamax) end end |
.axes ⇒ Object 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.
1059 |
# File 'lib/gr.rb', line 1059 alias axes2d axes |
.axes3d ⇒ Object
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.
|
|
# File 'lib/gr.rb', line 1220
|
.axeslbl ⇒ Object
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).
-
|
|
# File 'lib/gr.rb', line 1061
|
.barplot(labels, heights, kv = {}) ⇒ Object
(Plot) Draw a bar plot.
1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 |
# File 'lib/gr/plot.rb', line 1382 def (labels, heights, kv = {}) labels = labels.map(&:to_s) wc, hc = (heights) create_plot(:bar, labels, heights, kv) do |plt| if kv[:horizontal] plt.args = [[hc, wc, nil, nil, '']] plt.kvs[:yticks] = [1, 1] plt.kvs[:yticklabels] = labels else plt.args = [[wc, hc, nil, nil, '']] plt.kvs[:xticks] = [1, 1] plt.kvs[:xticklabels] = labels end end end |
.begingraphics ⇒ Object
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.
|
|
# File 'lib/gr.rb', line 1737
|
.beginprint(file_path) ⇒ Object
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
1477 1478 1479 1480 1481 1482 1483 |
# File 'lib/gr.rb', line 1477 def beginprint(file_path) super(file_path) if block_given? yield endprint end end |
.beginprintext ⇒ Object
Open and activate a print device with the given layout attributes.
|
|
# File 'lib/gr.rb', line 1485
|
.beginselection ⇒ Object
|
|
# File 'lib/gr.rb', line 1772
|
.camerainteraction ⇒ Object
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).
|
|
# File 'lib/gr.rb', line 2188
|
.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.
279 280 281 |
# File 'lib/gr.rb', line 279 def cellarray(xmin, xmax, ymin, ymax, dimx, dimy, color) super(xmin, xmax, ymin, ymax, dimx, dimy, 1, 1, dimx, dimy, int(color)) end |
.clearws ⇒ Object
Clear the specified workstation.
|
|
# File 'lib/gr.rb', line 167
|
.closegks ⇒ Object
|
|
# File 'lib/gr.rb', line 99
|
.closeseg ⇒ Object
|
|
# File 'lib/gr.rb', line 899
|
.closews ⇒ Object
Close the specified workstation.
|
|
# File 'lib/gr.rb', line 145
|
.colorbar ⇒ Object
1419 1420 1421 1422 1423 |
# File 'lib/gr.rb', line 1419 def inqcolor(color) inquiry_int do |rgb| super(color, rgb) end end |
.configurews ⇒ Object
Configure the specified workstation.
|
|
# File 'lib/gr.rb', line 163
|
.contour(*args) ⇒ Object
(Plot) Draw a contour plot.
1320 1321 1322 1323 1324 1325 1326 |
# File 'lib/gr.rb', line 1320 def contour(x, y, h, z, major_h) # TODO: check: Arrays have incorrect length or dimension. nx = x.length ny = y.length nh = h.length super(nx, ny, nh, x, y, h, z, major_h) end |
.contourf(*args) ⇒ Object
(Plot) Draw a filled contour plot.
1345 1346 1347 1348 1349 1350 1351 |
# File 'lib/gr.rb', line 1345 def contourf(x, y, h, z, major_h) # TODO: check: Arrays have incorrect length or dimension. nx = x.length ny = y.length nh = h.length super(nx, ny, nh, x, y, h, z, major_h) end |
.copysegws ⇒ Object
|
|
# File 'lib/gr.rb', line 893
|
.createseg ⇒ Object
|
|
# File 'lib/gr.rb', line 891
|
.deactivatews ⇒ Object
Deactivate the specified workstation.
|
|
# File 'lib/gr.rb', line 157
|
.delaunay(x, y) ⇒ Integer
1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 |
# File 'lib/gr.rb', line 1805 def delaunay(x, y) # Feel free to make a pull request if you catch a mistake # or you have an idea to improve it. npoints = equal_length(x, y) triangles = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INTPTR_T) dim = 3 n_tri = inquiry_int do |ntri| super(npoints, x, y, ntri, triangles.ref) end if n_tri > 0 tri = triangles.to_str(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 |
.destroycontext ⇒ Object
|
|
# File 'lib/gr.rb', line 1800
|
.drawarc ⇒ Object
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.
|
|
# File 'lib/gr.rb', line 1570
|
.drawarrow ⇒ Object
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.
|
|
# File 'lib/gr.rb', line 1654
|
.drawgraphics ⇒ Integer
|
|
# File 'lib/gr.rb', line 1753
|
.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.
1699 1700 1701 |
# File 'lib/gr.rb', line 1699 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.
1614 1615 1616 1617 |
# File 'lib/gr.rb', line 1614 def drawpath(points, codes, fill) len = codes.length super(len, points, uint8(codes), fill) end |
.drawrect ⇒ Object
Draw a rectangle using the current line attributes.
|
|
# File 'lib/gr.rb', line 1552
|
.emergencyclosegks ⇒ Object
|
|
# File 'lib/gr.rb', line 901
|
.endgraphics ⇒ Object
|
|
# File 'lib/gr.rb', line 1746
|
.endprint ⇒ Object
1527 1528 1529 1530 1531 1532 1533 |
# File 'lib/gr.rb', line 1527 def ndctowc(x, y) inquiry i[double double] do |px, py| px.write_double x py.write_double y super(px, py) end end |
.endselection ⇒ Object
|
|
# File 'lib/gr.rb', line 1774
|
.fillarc ⇒ Object
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.
|
|
# File 'lib/gr.rb', line 1585
|
.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.
259 260 261 262 |
# File 'lib/gr.rb', line 259 def fillarea(x, y) n = equal_length(x, y) super(n, x, y) end |
.fillrect ⇒ Object
Draw a filled rectangle using the current fill attributes.
|
|
# File 'lib/gr.rb', line 1561
|
.findboundary ⇒ Object
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 1969
|
.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.
379 380 381 382 383 |
# File 'lib/gr.rb', line 379 def gdp(x, y, primid, datrec) n = equal_length(x, y) ldr = datrec.length super(n, x, y, primid, ldr, int(datrec)) end |
.getgraphics ⇒ String
1749 1750 1751 |
# File 'lib/gr.rb', line 1749 def getgraphics(*) super.to_s end |
.gradient(x, y, z) ⇒ Object
1851 1852 1853 1854 1855 1856 1857 1858 |
# File 'lib/gr.rb', line 1851 def gradient(x, y, z) # TODO: check: Arrays have incorrect length or dimension. nx = x.length ny = y.length inquiry [{ double: nx * ny }, { double: nx * ny }] do |pu, pv| super(nx, ny, x, y, z, pu, pv) end end |
.grid ⇒ Object
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.
|
|
# File 'lib/gr.rb', line 1110
|
.grid3d ⇒ Object
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.
|
|
# File 'lib/gr.rb', line 1134
|
.gridit(xd, yd, zd, nx, ny) ⇒ Object
Interpolate data from arbitrary points at points on a rectangular grid.
416 417 418 419 420 421 |
# File 'lib/gr.rb', line 416 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.
1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 |
# File 'lib/gr/plot.rb', line 1272 def heatmap(*args) # FIXME args, kv = format_xyzc(*args) _x, _y, z = args ysize, xsize = z.shape z = z.reshape(xsize, ysize) create_plot(:heatmap, kv) do |plt| plt.kvs[:xlim] ||= [0.5, xsize + 0.5] plt.kvs[:ylim] ||= [0.5, ysize + 0.5] plt.args = [[(1..xsize).to_a, (1..ysize).to_a, z, nil, '']] end end |
.herrorbars(x, y, e1, e2) ⇒ Object
Draw a standard horizontal error bar graph.
1184 1185 1186 1187 |
# File 'lib/gr.rb', line 1184 def (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.
1371 1372 1373 1374 |
# File 'lib/gr.rb', line 1371 def hexbin(x, y, nbins) n = x.length super(n, x, y, nbins) end |
.histogram(series, kv = {}) ⇒ Object
(Plot) Draw a histogram.
1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 |
# File 'lib/gr/plot.rb', line 1399 def histogram(series, kv = {}) create_plot(:hist, series, kv) do |plt| nbins = plt.kvs[:nbins] || 0 x, y = hist(series, nbins) plt.args = if kv[:horizontal] [[y, x, nil, nil, '']] else [[x, y, nil, nil, '']] end end end |
.hold(flag = true) ⇒ Object
1427 1428 1429 1430 |
# File 'lib/gr/plot.rb', line 1427 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
1428 1429 1430 1431 1432 |
# File 'lib/gr.rb', line 1428 def hsvtorgb(h, s, v) inquiry i[double double double] do |r, g, b| super(h, s, v, r, g, b) end end |
.importgraphics ⇒ Integer
|
|
# File 'lib/gr.rb', line 1703
|
.imshow(img, kv = {}) ⇒ Object
(Plot) Draw an image.
1412 1413 1414 1415 1416 1417 |
# File 'lib/gr/plot.rb', line 1412 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 |
.initgr ⇒ Object
|
|
# File 'lib/gr.rb', line 95
|
.inqbbox ⇒ Object
1780 1781 1782 1783 1784 |
# File 'lib/gr.rb', line 1780 def inqbbox inquiry i[double double double double] do |*pts| super(*pts) end end |
.inqbordercolorind ⇒ Object
Define the color of subsequent path output primitives.
2102 2103 2104 |
# File 'lib/gr.rb', line 2102 def inqbordercolorind inquiry_int { |pt| super(pt) } end |
.inqborderwidth ⇒ Object
Define the border width of subsequent path output primitives.
2092 2093 2094 |
# File 'lib/gr.rb', line 2092 def inqborderwidth inquiry_double { |pt| super(pt) } end |
.inqcharheight ⇒ Numeric
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).
648 649 650 |
# File 'lib/gr.rb', line 648 def inqcharheight inquiry_double { |pt| super(pt) } end |
.inqclipxform ⇒ Object
2108 2109 2110 |
# File 'lib/gr.rb', line 2108 def inqclipxform inquiry_int { |pt| super(pt) } end |
.inqcolor(color) ⇒ Object
1419 1420 1421 1422 1423 |
# File 'lib/gr.rb', line 1419 def inqcolor(color) inquiry_int do |rgb| super(color, rgb) end end |
.inqcolorfromrgb ⇒ Integer
1428 1429 1430 1431 1432 |
# File 'lib/gr.rb', line 1428 def hsvtorgb(h, s, v) inquiry i[double double double] do |r, g, b| super(h, s, v, r, g, b) end end |
.inqcolormap ⇒ Object
inqcolormap
1386 1387 1388 |
# File 'lib/gr.rb', line 1386 def inqcolormap inquiry_int { |pt| super(pt) } end |
.inqdspsize ⇒ Array
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.
109 110 111 112 113 |
# File 'lib/gr.rb', line 109 def inqdspsize inquiry i[double double int int] do |*pts| super(*pts) end end |
.inqfillcolorind ⇒ Integer
Returns the current fill area color index.
This function gets the color of fill area output primitives.
756 757 758 |
# File 'lib/gr.rb', line 756 def inqfillcolorind inquiry_int { |pt| super(pt) } end |
.inqfillintstyle ⇒ Integer
Returns the fill area interior style to be used for fill areas.
This function gets the currently set fill style.
715 716 717 |
# File 'lib/gr.rb', line 715 def inqfillintstyle inquiry_int { |pt| super(pt) } end |
.inqfillstyle ⇒ Integer
Returns the current fill area color index.
This function gets the color index for PATTERN and HATCH fills.
737 738 739 |
# File 'lib/gr.rb', line 737 def inqfillstyle inquiry_int { |pt| super(pt) } end |
.inqlinecolorind ⇒ Object
Define the color of subsequent polyline output primitives.
466 467 468 |
# File 'lib/gr.rb', line 466 def inqlinecolorind inquiry_int { |pt| super(pt) } end |
.inqlinetype ⇒ Object
Specify the line style for polylines.
441 442 443 |
# File 'lib/gr.rb', line 441 def inqlinetype inquiry_int { |pt| super(pt) } end |
.inqlinewidth ⇒ Object
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.
456 457 458 |
# File 'lib/gr.rb', line 456 def inqlinewidth inquiry_double { |pt| super(pt) } end |
.inqmarkercolorind ⇒ Object
Define the color of subsequent polymarker output primitives.
542 543 544 |
# File 'lib/gr.rb', line 542 def inqmarkercolorind inquiry_int { |pt| super(pt) } end |
.inqmarkersize ⇒ Numeric
Inquire the marker size for polymarkers.
532 533 534 |
# File 'lib/gr.rb', line 532 def inqmarkersize inquiry_double { |pt| super(pt) } end |
.inqmarkertype ⇒ Object
Specifiy the marker type for polymarkers.
Polymarkers appear centered over their specified coordinates.
515 516 517 |
# File 'lib/gr.rb', line 515 def inqmarkertype inquiry_int { |pt| super(pt) } end |
.inqmathtex(x, y, string) ⇒ Object
inqmathtex
1766 1767 1768 1769 1770 |
# File 'lib/gr.rb', line 1766 def inqmathtex(x, y, string) inquiry [{ double: 4 }, { double: 4 }] do |tbx, tby| super(x, y, string, tbx, tby) end end |
.inqorthographicprojection ⇒ Object
Return the camera position, up vector and focus point.
2182 2183 2184 2185 2186 |
# File 'lib/gr.rb', line 2182 def inqorthographicprojection inquiry([:double] * 6) do |*pts| super(*pts) end end |
.inqperspectiveprojection ⇒ Object
Return the parameters for the perspective projection.
2139 2140 2141 2142 2143 |
# File 'lib/gr.rb', line 2139 def inqperspectiveprojection inquiry i[double double double] do |*pts| super(*pts) end end |
.inqprojectiontype ⇒ Object
Return the projection type.
2123 2124 2125 |
# File 'lib/gr.rb', line 2123 def inqprojectiontype inquiry_int { |pt| super(pt) } end |
.inqregenflags ⇒ Integer
|
|
# File 'lib/gr.rb', line 1791
|
.inqresamplemethod ⇒ Integer
Inquire the resample method used for drawimage
2034 2035 2036 2037 2038 |
# File 'lib/gr.rb', line 2034 def inqresamplemethod inquiry_uint do |resample_method| super(resample_method) end end |
.inqscale ⇒ Object
inqscale
956 957 958 |
# File 'lib/gr.rb', line 956 def inqscale inquiry_int { |pt| super(pt) } end |
.inqscalefactors3d ⇒ Object
Returns the scale factors for each axis.
2230 2231 2232 2233 2234 |
# File 'lib/gr.rb', line 2230 def inqscalefactors3d inquiry i[double double double] do |*opts| super(*opts) end end |
.inqspace ⇒ Integer
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°.
924 925 926 927 928 |
# File 'lib/gr.rb', line 924 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 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.
245 246 247 248 249 |
# File 'lib/gr.rb', line 245 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
2255 2256 2257 2258 2259 |
# File 'lib/gr.rb', line 2255 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 |
.inqtextcolorind ⇒ Integer
Gets the current text color index.
This function gets the color of text output primitives.
627 628 629 |
# File 'lib/gr.rb', line 627 def inqtextcolorind inquiry_int { |pt| super(pt) } end |
.inqtextencoding ⇒ Object
2263 2264 2265 2266 2267 |
# File 'lib/gr.rb', line 2263 def inqtextencoding inquiry_int do |encoding| super(encoding) end end |
.inqtextext(x, y, string) ⇒ Object
inqtextext
1018 1019 1020 1021 1022 |
# File 'lib/gr.rb', line 1018 def inqtextext(x, y, string) inquiry [{ double: 4 }, { double: 4 }] do |tbx, tby| super(x, y, string, tbx, tby) end end |
.inqtransformationparameters ⇒ Object
Return the camera position, up vector and focus point.
2162 2163 2164 2165 2166 |
# File 'lib/gr.rb', line 2162 def inqtransformationparameters inquiry([:double] * 9) do |*pts| super(*pts) end end |
.inqviewport ⇒ Object
inqviewport
820 821 822 823 824 |
# File 'lib/gr.rb', line 820 def inquiry i[double double double double] do |*pts| super(*pts) end end |
.inqwindow ⇒ Object
inqwindow
793 794 795 796 797 |
# File 'lib/gr.rb', line 793 def inqwindow inquiry i[double double double double] do |*pts| super(*pts) end end |
.inqwindow3d ⇒ Object
Return the three dimensional window.
2213 2214 2215 2216 2217 |
# File 'lib/gr.rb', line 2213 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
1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 |
# File 'lib/gr.rb', line 1900 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.
1420 1421 1422 1423 1424 1425 |
# File 'lib/gr/plot.rb', line 1420 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.
2277 2278 2279 2280 2281 |
# File 'lib/gr.rb', line 2277 def loadfont(str) inquiry_int do |font| super(str, font) end end |
.mathtex ⇒ Object
Generate a character string starting at the given location. Strings can be defined to create mathematical symbols and Greek letters using LaTeX syntax.
|
|
# File 'lib/gr.rb', line 1756
|
.moveselection ⇒ Object
|
|
# File 'lib/gr.rb', line 1776
|
.ndctowc(x, y) ⇒ Object
1527 1528 1529 1530 1531 1532 1533 |
# File 'lib/gr.rb', line 1527 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.
295 296 297 298 299 300 301 |
# File 'lib/gr.rb', line 295 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 |
.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 simialr to gr_polarcellarray with the difference that the individual cell sizes are specified allowing nonuniform sized cells.
362 363 364 365 366 367 368 |
# File 'lib/gr.rb', line 362 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.
1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 |
# File 'lib/gr/plot.rb', line 1301 def nonuniformpolarheatmap(*args) # FIXME args, kv = format_xyzc(*args) _x, _y, z = args ysize, xsize = z.shape z = z.reshape(xsize, ysize) create_plot(:nonuniformpolarheatmap, kv) do |plt| plt.kvs[:xlim] ||= [0.5, xsize + 0.5] plt.kvs[:ylim] ||= [0.5, ysize + 0.5] plt.args = [[(1..xsize).to_a, (1..ysize).to_a, z, nil, '']] end end |
.opengks ⇒ Object
|
|
# File 'lib/gr.rb', line 97
|
.openws ⇒ Object
Open a graphical workstation.
|
|
# File 'lib/gr.rb', line 115
|
.panzoom(x, y, zoom) ⇒ Object
panzoom
1976 1977 1978 1979 1980 |
# File 'lib/gr.rb', line 1976 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.
2069 2070 2071 2072 |
# File 'lib/gr.rb', line 2069 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.
1242 1243 1244 |
# File 'lib/gr/plot.rb', line 1242 def plot(*args) create_plot(:line, *args) end |
.plot3(*args) ⇒ Object
(Plot) Draw one or more three-dimensional line plots.
1359 1360 1361 |
# File 'lib/gr/plot.rb', line 1359 def plot3(*args) create_plot(:plot3, *args) end |
.polar(*args) ⇒ Object
(Plot)
1349 1350 1351 |
# File 'lib/gr/plot.rb', line 1349 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
345 346 347 |
# File 'lib/gr.rb', line 345 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.
1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 |
# File 'lib/gr/plot.rb', line 1286 def polarheatmap(*args) d = args.shift # FIXME z = Numo::DFloat.cast(d) raise 'expected 2-D array' unless z.ndim == 2 create_plot(:polarheatmap, z, *args) do |plt| width, height = z.shape plt.kvs[:xlim] ||= [0.5, width + 0.5] plt.kvs[:ylim] ||= [0.5, height + 0.5] plt.args = [[(1..width).to_a, (1..height).to_a, z, nil, '']] end end |
.polarhistogram(x, kv = {}) ⇒ Object
(Plot)
1262 1263 1264 1265 1266 1267 1268 1269 |
# File 'lib/gr/plot.rb', line 1262 def polarhistogram(x, kv = {}) plt = GR::Plot.new(x, kv) plt.kvs[:kind] = :polarhist nbins = plt.kvs[:nbins] || 0 x, y = hist(x, nbins) plt.args = [[x, y, nil, nil, '']] plt.plot_data end |
.polyline(x, y, 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.
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/gr.rb', line 187 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 = Array.new(n, linewidth) if linewidth.is_a?(Numeric) linewidth.map! { |i| (100 * i).round } line_z ||= Array.new(n, 0) raise ArgumentError if n != equal_length(linewidth, line_z) color = to_rgb_color(line_z) gdp(x, y, GDP_DRAW_LINES, linewidth.zip(color).flatten) 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.
1200 1201 1202 1203 |
# File 'lib/gr.rb', line 1200 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.
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
# File 'lib/gr.rb', line 214 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 = Array.new(n, markersize) if markersize.is_a?(Numeric) markersize.map! { |i| (100 * i).round } marker_z ||= Array.new(n, 0) raise ArgumentError if n != equal_length(markersize, marker_z) color = to_rgb_color(marker_z) gdp(x, y, GDP_DRAW_MARKERS, markersize.zip(color).flatten) 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.
1215 1216 1217 1218 |
# File 'lib/gr.rb', line 1215 def polymarker3d(x, y, z) n = equal_length(x, y, z) super(n, x, y, z) end |
.precision ⇒ Numeric
|
|
# File 'lib/gr.rb', line 1786
|
.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.
1874 1875 1876 1877 1878 1879 |
# File 'lib/gr.rb', line 1874 def quiver(x, y, u, v, color) # TODO: check: Arrays have incorrect length or dimension. nx = x.length ny = y.length super(nx, ny, x, y, u, v, (color ? 1 : 0)) end |
.readimage(path) ⇒ Integer
1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 |
# File 'lib/gr.rb', line 1668 def readimage(path) # Feel free to make a pull request if you catch a mistake # or you have an idea to improve it. data = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INTPTR_T) w, h = inquiry [:int, :int] do |width, height| # data is a pointer of a pointer super(path, width, height, data.ref) end d = data.to_str(w * h * Fiddle::SIZEOF_INT).unpack('L*') # UInt32 [w, h, d] end |
.redrawsegws ⇒ Object
|
|
# File 'lib/gr.rb', line 895
|
.reducepoints(xd, yd, n) ⇒ Object
Reduces the number of points of the x and y array.
1831 1832 1833 1834 1835 1836 1837 |
# File 'lib/gr.rb', line 1831 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 |
.resizeselection ⇒ Object
1780 1781 1782 1783 1784 |
# File 'lib/gr.rb', line 1780 def inqbbox inquiry i[double double double double] do |*pts| super(*pts) end end |
.restorestate ⇒ Object
|
|
# File 'lib/gr.rb', line 1796
|
.savefig(filename, kv = {}) ⇒ Object
(Plot) Save the current figure to a file.
1456 1457 1458 1459 1460 1461 1462 |
# File 'lib/gr/plot.rb', line 1456 def savefig(filename, kv = {}) GR.beginprint(filename) plt = GR::Plot.last_plot plt.kvs.merge!(kv) plt.plot_data(false) GR.endprint end |
.savestate ⇒ Object
|
|
# File 'lib/gr.rb', line 1794
|
.scatter(*args) ⇒ Object
(Plot) Draw one or more scatter plots.
1252 1253 1254 |
# File 'lib/gr/plot.rb', line 1252 def scatter(*args) create_plot(:scatter, *args) end |
.scatter3(*args) ⇒ Object
(Plot) Draw one or more three-dimensional scatter plots.
1364 1365 1366 |
# File 'lib/gr/plot.rb', line 1364 def scatter3(*args) create_plot(:scatter3, *args) end |
.selectclipxform ⇒ Object
2108 2109 2110 |
# File 'lib/gr.rb', line 2108 def inqclipxform inquiry_int { |pt| super(pt) } end |
.selectcontext ⇒ Object
|
|
# File 'lib/gr.rb', line 1798
|
.selntran ⇒ Object
selntran selects a predefined transformation from world coordinates to normalized device coordinates.
|
|
# File 'lib/gr.rb', line 826
|
.setarrowsize ⇒ Object
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.
|
|
# File 'lib/gr.rb', line 1645
|
.setarrowstyle ⇒ Object
Set the arrow style to be used for subsequent arrow commands.
setarrowstyle defines the arrow style for subsequent arrow primitives.
|
|
# File 'lib/gr.rb', line 1619
|
.setbordercolorind ⇒ Object
Define the color of subsequent path output primitives.
2102 2103 2104 |
# File 'lib/gr.rb', line 2102 def inqbordercolorind inquiry_int { |pt| super(pt) } end |
.setborderwidth ⇒ Object
Define the border width of subsequent path output primitives.
2092 2093 2094 |
# File 'lib/gr.rb', line 2092 def inqborderwidth inquiry_double { |pt| super(pt) } end |
.setcharexpan ⇒ Object
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.
|
|
# File 'lib/gr.rb', line 598
|
.setcharheight ⇒ Object
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).
|
|
# File 'lib/gr.rb', line 631
|
.setcharspace ⇒ Object
|
|
# File 'lib/gr.rb', line 610
|
.setcharup ⇒ Object
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.
|
|
# File 'lib/gr.rb', line 652
|
.setclip ⇒ Object
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.
|
|
# File 'lib/gr.rb', line 837
|
.setcolormap ⇒ Object
Set the currently used colormap.
-
A list of colormaps can be found at: gr-framework.org/colormaps.html
Using a negative index will use the reverse of the selected colormap.
|
|
# File 'lib/gr.rb', line 1376
|
.setcolormapfromrgb(r, g, b, positions: nil) ⇒ Object
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.
1407 1408 1409 1410 1411 1412 1413 1414 1415 |
# File 'lib/gr.rb', line 1407 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 |
.setcolorrep ⇒ Object
Redefine an existing color index representation by specifying an RGB color triplet.
|
|
# File 'lib/gr.rb', line 760
|
.setcoordxform(mat) ⇒ Object
Change the coordinate transformation according to the given matrix.
1731 1732 1733 1734 1735 |
# File 'lib/gr.rb', line 1731 def setcoordxform(mat) raise if mat.size != 6 super(mat) end |
.setfillcolorind ⇒ Object
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.
|
|
# File 'lib/gr.rb', line 741
|
.setfillintstyle ⇒ Object
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.
|
|
# File 'lib/gr.rb', line 696
|
.setfillstyle ⇒ Object
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.
|
|
# File 'lib/gr.rb', line 719
|
.setlinecolorind ⇒ Object
Define the color of subsequent polyline output primitives.
466 467 468 |
# File 'lib/gr.rb', line 466 def inqlinecolorind inquiry_int { |pt| super(pt) } end |
.setlinetype ⇒ Object
Specify the line style for polylines.
441 442 443 |
# File 'lib/gr.rb', line 441 def inqlinetype inquiry_int { |pt| super(pt) } end |
.setlinewidth ⇒ Object
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.
456 457 458 |
# File 'lib/gr.rb', line 456 def inqlinewidth inquiry_double { |pt| super(pt) } end |
.setmarkercolorind ⇒ Object
Define the color of subsequent polymarker output primitives.
542 543 544 |
# File 'lib/gr.rb', line 542 def inqmarkercolorind inquiry_int { |pt| super(pt) } end |
.setmarkersize ⇒ Object
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.
|
|
# File 'lib/gr.rb', line 519
|
.setmarkertype ⇒ Object
Specifiy the marker type for polymarkers.
Polymarkers appear centered over their specified coordinates.
515 516 517 |
# File 'lib/gr.rb', line 515 def inqmarkertype inquiry_int { |pt| super(pt) } end |
.setorthographicprojection ⇒ Object
Set parameters for orthographic transformation. Switches projection type to orthographic.
|
|
# File 'lib/gr.rb', line 2168
|
.setperspectiveprojection ⇒ Object
Set the far and near clipping plane for perspective projection and the vertical field ov view. Switches projection type to perspective.
|
|
# File 'lib/gr.rb', line 2127
|
.setprojectiontype ⇒ Object
Set the projection type with this flag.
|
|
# File 'lib/gr.rb', line 2112
|
.setregenflags ⇒ Object
|
|
# File 'lib/gr.rb', line 1789
|
.setresamplemethod ⇒ Object
Set the resample method used for drawimage.
|
|
# File 'lib/gr.rb', line 1982
|
.setscale ⇒ Integer
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.
|
|
# File 'lib/gr.rb', line 930
|
.setscalefactors3d ⇒ Object
Set the scale factor for each axis. A one means no scale. The scaling factors must not be zero. .
|
|
# File 'lib/gr.rb', line 2219
|
.setsegtran ⇒ Object
|
|
# File 'lib/gr.rb', line 897
|
.setshadow ⇒ Object
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.
|
|
# File 'lib/gr.rb', line 1706
|
.setspace ⇒ Integer
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°.
924 925 926 927 928 |
# File 'lib/gr.rb', line 924 def inqspace inquiry i[double double int int] do |*pts| super(*pts) end end |
.setspace3d ⇒ Object
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.
|
|
# File 'lib/gr.rb', line 2236
|
.settextalign ⇒ Object
-
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.
|
|
# File 'lib/gr.rb', line 678
|
.settextcolorind ⇒ Object
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.
|
|
# File 'lib/gr.rb', line 612
|
.settextencoding ⇒ Object
2263 2264 2265 2266 2267 |
# File 'lib/gr.rb', line 2263 def inqtextencoding inquiry_int do |encoding| super(encoding) end end |
.settextfontprec ⇒ Object
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.
|
|
# File 'lib/gr.rb', line 546
|
.settextpath ⇒ Object
Define the current direction in which subsequent text will be drawn.
|
|
# File 'lib/gr.rb', line 663
|
.settransformationparameters ⇒ Object
Method to set the camera position, the upward facing direction and the focus point of the shown volume.
|
|
# File 'lib/gr.rb', line 2145
|
.settransparency ⇒ Object
Set the value of the alpha component associated with GR colors.
|
|
# File 'lib/gr.rb', line 1721
|
.setviewport ⇒ Object
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.
|
|
# File 'lib/gr.rb', line 799
|
.setwindow ⇒ Object
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.
|
|
# File 'lib/gr.rb', line 770
|
.setwindow3d ⇒ Object
Set the three dimensional window. Only used for perspective and orthographic projection.
|
|
# File 'lib/gr.rb', line 2200
|
.setwsviewport ⇒ Object
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.
|
|
# File 'lib/gr.rb', line 873
|
.setwswindow ⇒ Object
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.
|
|
# File 'lib/gr.rb', line 853
|
.shade(*args) ⇒ Object
(Plot)
|
|
# File 'lib/gr.rb', line 1918
|
.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.
1963 1964 1965 1966 1967 |
# File 'lib/gr.rb', line 1963 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.
1940 1941 1942 1943 1944 |
# File 'lib/gr.rb', line 1940 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.
401 402 403 404 |
# File 'lib/gr.rb', line 401 def spline(x, y, m, method) n = equal_length(x, y) super(n, x, y, m, method) end |
.stem(*args) ⇒ Object
(Plot) Draw a stem plot.
1257 1258 1259 |
# File 'lib/gr/plot.rb', line 1257 def stem(*args) create_plot(:stem, *args) end |
.step(*args) ⇒ Object
(Plot) Draw one or more step or staircase plots.
1247 1248 1249 |
# File 'lib/gr/plot.rb', line 1247 def step(*args) create_plot(:step, *args) end |
.subplot(nr, nc, p, kv = {}) ⇒ Object
Set current subplot index.
1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 |
# File 'lib/gr/plot.rb', line 1433 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
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:
1292 1293 1294 1295 1296 1297 |
# File 'lib/gr.rb', line 1292 def surface(x, y, z, option) # TODO: check: Arrays have incorrect length or dimension. nx = x.length ny = y.length super(nx, ny, x, y, z, option) end |
.text ⇒ Object
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.
245 246 247 248 249 |
# File 'lib/gr.rb', line 245 def inqtext(x, y, string) inquiry [{ double: 4 }, { double: 4 }] do |tbx, tby| super(x, y, string, tbx, tby) end end |
.text3d ⇒ Object
2255 2256 2257 2258 2259 |
# File 'lib/gr.rb', line 2255 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 |
.textext ⇒ Integer
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.
*
Note: \v is a replacement for \nu which would conflict with \n (newline) For more sophisticated mathematical formulas, you should use the mathtex function.
|
|
# File 'lib/gr.rb', line 960
|
.tick ⇒ Numeric
|
|
# File 'lib/gr.rb', line 1434
|
.titles3d ⇒ Object
Display axis titles just outside of their respective axes.
|
|
# File 'lib/gr.rb', line 1260
|
.to_rgb_color(z) ⇒ Array, NArray
2076 2077 2078 2079 2080 2081 2082 2083 2084 |
# File 'lib/gr.rb', line 2076 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.
1333 1334 1335 |
# File 'lib/gr/plot.rb', line 1333 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.
1360 1361 1362 1363 1364 |
# File 'lib/gr.rb', line 1360 def tricontour(x, y, z, levels) npoints = x.length # equal_length ? nlevels = levels.length super(npoints, x, y, z, nlevels, levels) end |
.trisurf(*args) ⇒ Object
(Plot) Draw a triangular surface plot.
1354 1355 1356 |
# File 'lib/gr/plot.rb', line 1354 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.
1845 1846 1847 1848 |
# File 'lib/gr.rb', line 1845 def trisurface(x, y, z) n = [x, y, z].map(&:length).min super(n, x, y, z) end |
.updategks ⇒ Object
|
|
# File 'lib/gr.rb', line 903
|
.updatews ⇒ Object
Update the specified workstation.
|
|
# File 'lib/gr.rb', line 171
|
.uselinespec ⇒ Integer
1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 |
# File 'lib/gr.rb', line 1805 def delaunay(x, y) # Feel free to make a pull request if you catch a mistake # or you have an idea to improve it. npoints = equal_length(x, y) triangles = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INTPTR_T) dim = 3 n_tri = inquiry_int do |ntri| super(npoints, x, y, ntri, triangles.ref) end if n_tri > 0 tri = triangles.to_str(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 |
.validaterange ⇒ Integer
1440 1441 1442 1443 1444 1445 1446 |
# File 'lib/gr.rb', line 1440 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.
1172 1173 1174 1175 |
# File 'lib/gr.rb', line 1172 def (x, y, e1, e2) n = equal_length(x, y, e1, e2) super(n, x, y, e1, e2) end |
.version ⇒ String
Returns the combined version strings of the GR runtime.
1914 1915 1916 |
# File 'lib/gr.rb', line 1914 def version super.to_s end |
.volume(v, kv = {}) ⇒ Object
(Plot)
1375 1376 1377 1378 1379 |
# File 'lib/gr/plot.rb', line 1375 def volume(v, kv = {}) create_plot(:volume, v, kv) do |plt| plt.args = [[nil, nil, v, nil, '']] end end |
.wc3towc(x, y, z) ⇒ Object
1543 1544 1545 1546 1547 1548 1549 1550 |
# File 'lib/gr.rb', line 1543 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
1535 1536 1537 1538 1539 1540 1541 |
# File 'lib/gr.rb', line 1535 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.
1338 1339 1340 |
# File 'lib/gr/plot.rb', line 1338 def wireframe(*args) create_plot(:wireframe, *format_xyzc(*args)) end |