ruby-gr 0.0.25 → 0.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 684689c3494cbf841d908396c562fb418796d25afabd0a5d9c58497a8dca6a32
4
- data.tar.gz: 3274ea957c350ddc0ec0abd5c260e54e933ab80930dba7bf5252d807bc47c770
3
+ metadata.gz: fd24ca7e167933c74ba77c3185be37e322665f41c4e94d547789d28f7b282d7a
4
+ data.tar.gz: a3f53215287be5208e2217bc83fc033030aa2067cb438e46343b85b33357adab
5
5
  SHA512:
6
- metadata.gz: 00b957ba8bf7f2f63b67cba456fd0016a8cc18503bbee605e3f02001e61ee377d02d7800eaacfe3077878a3cb92b8ecd9987378a40acae018ddc2428f699f2c4
7
- data.tar.gz: ed6aaaf3a5ca30ecdf5695623b36036afe00610c720bef330ae25922fce12ad7c76a42ff8801066c3dccf4d973a77d83861651998b7da960c4b5bea7d236fa47
6
+ metadata.gz: f661c8aa91cb27046f66590643a372391c5d9fa1703146b891137f1a0639c3671243679d4f14697e304e737d17408a5c880c8e2399278285b02fddfe08a18e8a
7
+ data.tar.gz: 32945088f9c0cbf22a8525c36f0dd527fcd5d81a763986a334736331b1d0ad9013d9f6b89a3202118427a85021b261bd0b35caad6690d38e8969efe0299c7c60
data/README.md CHANGED
@@ -34,13 +34,13 @@ gem install ruby-gr
34
34
  ```
35
35
  Note: If you are using [RubyInstaller](https://rubyinstaller.org/) (Windows), pacman will automatically install [mingw-w64-gr](https://packages.msys2.org/base/mingw-w64-gr).
36
36
 
37
- Set environment variable `GRDIR`.
37
+ Set environment variable `GRDIR`.
38
38
 
39
39
  ```sh
40
40
  export GRDIR="/your/path/to/gr"
41
41
  ```
42
42
 
43
- If you use package managers to install GR, [pkg-config](https://github.com/ruby-gnome/pkg-config) may automatically detect the shared library location without specifying the `GRDIR` environment variable.
43
+ If you use package managers to install GR, [pkg-config](https://github.com/ruby-gnome/pkg-config) may automatically detect the shared library location without specifying the `GRDIR` environment variable.
44
44
 
45
45
  ## Quick Start
46
46
 
@@ -79,7 +79,7 @@ GR.plot(
79
79
  )
80
80
  ```
81
81
 
82
- Save in PNG format.
82
+ Save the figure in PNG format.
83
83
 
84
84
  ```ruby
85
85
  GR.savefig("figure.png")
@@ -87,17 +87,17 @@ GR.savefig("figure.png")
87
87
 
88
88
  ## API Overview
89
89
 
90
- There are two different approaches to plotting with GR.rb. One way is to call Matlab-like APIs. The other is to call GR/GR3 native functions.
90
+ There are two different approaches when plotting with GR.rb. One is to call Matlab-like APIs. The other is to call GR/GR3 native functions.
91
91
 
92
- #### GR::Plot - A simple, matlab-style API.
92
+ #### GR::Plot - A simple, matlab-style API.
93
93
 
94
94
  ```ruby
95
95
  require 'gr/plot'
96
96
  GR.plot(x, y)
97
97
  ```
98
98
 
99
- List of vailable functions. See [GR.rb Wiki](https://github.com/red-data-tools/GR.rb/wiki) for details.
100
- Some GR module methods are overridden.
99
+ Below are a list of available functions. See [GR.rb Wiki](https://github.com/red-data-tools/GR.rb/wiki) for details.
100
+ Some GR module methods are overwritten.
101
101
 
102
102
  [`plot`](../../wiki/Plotting-functions#plot)
103
103
  [`step`](../../wiki/Plotting-functions#step)
@@ -123,7 +123,7 @@ Some GR module methods are overridden.
123
123
  [`imshow`](../../wiki/Plotting-functions#imshow)
124
124
  [`isosurface`](../../wiki/Plotting-functions#isosurface)
125
125
 
126
- We are planning to prepare a [more object-oriented interface](https://github.com/kojix2/GRUtils.rb) based on [GRUtils.jl](https://github.com/heliosdrm/GRUtils.jl) in the future.
126
+ We are preparing a [more object-oriented interface](https://github.com/kojix2/GRUtils.rb) based on [GRUtils.jl](https://github.com/heliosdrm/GRUtils.jl) in the future.
127
127
 
128
128
  #### GR - A module for calling native GR functions.
129
129
 
@@ -154,7 +154,7 @@ GR3.cameralookat(-3, 2, -2, 0, 0, 0, 0, 0, -1)
154
154
  - [GR Framework](https://gr-framework.org/)
155
155
  - [GR.rb API Documentation](https://rubydoc.info/gems/ruby-gr)
156
156
 
157
- Although GR.rb adds methods dynamically, we try our best to provide a complete yard document. However, if you want to see more up-to-date information, we recommend using the official GR reference.
157
+ Although GR.rb adds methods dynamically, we try our best to provide a complete yard document. If you want to see more up-to-date information, we recommend using the official GR reference.
158
158
 
159
159
  ## GR Installation
160
160
 
@@ -168,24 +168,45 @@ Set environment variable GRDIR.
168
168
  export GRDIR="your/path/to/gr"
169
169
  ```
170
170
 
171
- * macOS Catalina and macOS Mojave: See the "How to open an app that hasn’t been notarized or is from an unidentified developer" section of [Safely open apps on your Mac](https://support.apple.com/en-us/HT202491) in the Apple documentation.
171
+ * macOS Catalina and macOS Mojave: See the "How to open an app that hasn’t been notarized or is from an unidentified developer" section under [Safely open apps on your Mac](https://support.apple.com/en-us/HT202491) in the Apple documentation.
172
172
 
173
173
  ### Using package managers
174
174
 
175
175
  * The third party GR packages for Mac, Linux and Windows are available (for advanced users).
176
176
  * If you find any problem, please report the issue [here](https://github.com/red-data-tools/GR.rb/issues).
177
- * Note: These packages may not have some features, for example, video output.
177
+ * Note: These packages may not have some features such as video output.
178
178
 
179
179
  #### Mac - Homebrew
180
180
 
181
181
  ```sh
182
182
  brew install libgr
183
+ # brew install --build-from-source libgr
183
184
  ```
184
185
 
185
- #### Linux - APT Yum
186
+
187
+ #### Linux - APT
186
188
 
187
189
  [packages.red-data-tools.org](https://github.com/red-data-tools/packages.red-data-tools.org) provides `libgr-dev`, `libgr3-dev` and `libgrm-dev`
188
190
 
191
+ Debian GNU/Linux and Ubuntu
192
+
193
+ ```sh
194
+ sudo apt install -y -V ca-certificates lsb-release wget
195
+ wget https://packages.red-data-tools.org/$(lsb_release --id --short | tr 'A-Z' 'a-z')/red-data-tools-apt-source-latest-$(lsb_release --codename --short).deb
196
+ sudo apt install -y -V ./red-data-tools-apt-source-latest-$(lsb_release --codename --short).deb
197
+ sudo apt update
198
+ sudo apt install libgrm-dev
199
+ ```
200
+
201
+ #### Linux - Yum
202
+
203
+ CentOS
204
+
205
+ ```sh
206
+ (. /etc/os-release && sudo dnf install -y https://packages.red-data-tools.org/centos/${VERSION_ID}/red-data-tools-release-latest.noarch.rpm)
207
+ sudo dnf install -y gr-devel
208
+ ```
209
+
189
210
  ### Windows - MSYS2
190
211
 
191
212
  If you are using Rubyinstaller, pacman will automatically install [mingw-w64-gr](https://packages.msys2.org/base/mingw-w64-gr) when the gem is installed.
@@ -196,7 +217,7 @@ GR.rb will be the default backend for [Charty](https://github.com/red-data-tools
196
217
 
197
218
  ## Contributing
198
219
 
199
- GR.rb is a library under development, so even small improvements like typofix are welcome!
220
+ GR.rb is a library under development, so even small improvements like fixing typos are welcome!
200
221
  Please feel free to send us your PR.
201
222
 
202
223
  * [Report bugs](https://github.com/red-data-tools/GR.rb/issues)
@@ -209,4 +230,3 @@ Please feel free to send us your PR.
209
230
  ## Acknowledgements
210
231
 
211
232
  We would like to thank Josef Heinen, the creator of [GR](https://github.com/sciapp/gr) and [GR.jl](https://github.com/jheinen/GR.jl), Florian Rhiem, the creator of [python-gr](https://github.com/sciapp/python-gr), and all [GR](https://github.com/sciapp/gr) developers.
212
-
data/lib/gr.rb CHANGED
@@ -175,30 +175,56 @@ module GR
175
175
  # Draw a polyline using the current line attributes,
176
176
  # starting from the first data point and ending at the last data point.
177
177
  #
178
- # @param x [Array, NArray] A list containing the X coordinates
179
- # @param y [Array, NArray] A list containing the Y coordinates
178
+ # @param x [Array, NArray] A list containing the X coordinates
179
+ # @param y [Array, NArray] A list containing the Y coordinates
180
+ # @param linewidth [Array, NArray, Numeric] A list containing the line widths
181
+ # @param line_z [Array, NArray] A list to be converted to colors
180
182
  #
181
183
  # The values for x and y are in world coordinates.
182
184
  # The attributes that control the appearance of a polyline are linetype,
183
185
  # linewidth and color index.
184
186
  #
185
- def polyline(x, y)
187
+ def polyline(x, y, linewidth = nil, line_z = nil)
188
+ # GR.jl - Multiple dispatch
186
189
  n = equal_length(x, y)
187
- super(n, x, y)
190
+ if linewidth.nil? && line_z.nil?
191
+ super(n, x, y)
192
+ else
193
+ linewidth = Array.new(n, linewidth) if linewidth.is_a?(Numeric)
194
+ linewidth.map! { |i| (100 * i).round }
195
+ line_z ||= Array.new(n, 0)
196
+ raise ArgumentError if n != equal_length(linewidth, line_z)
197
+
198
+ color = to_rgb_color(line_z)
199
+ gdp(x, y, GDP_DRAW_LINES, linewidth.zip(color).flatten)
200
+ end
188
201
  end
189
202
 
190
203
  # Draw marker symbols centered at the given data points.
191
204
  #
192
- # @param x [Array, NArray] A list containing the X coordinates
193
- # @param y [Array, NArray] A list containing the Y coordinates
205
+ # @param x [Array, NArray] A list containing the X coordinates
206
+ # @param y [Array, NArray] A list containing the Y coordinates
207
+ # @param markersize [Array, NArray, Numeric] A list containing the marker sizes
208
+ # @param marker_z [Array, NArray] A list to be converted to colors
194
209
  #
195
210
  # The values for x and y are in world coordinates.
196
211
  # The attributes that control the appearance of a polymarker are marker type,
197
212
  # marker size scale factor and color index.
198
213
  #
199
- def polymarker(x, y)
214
+ def polymarker(x, y, markersize = nil, marker_z = nil)
215
+ # GR.jl - Multiple dispatch
200
216
  n = equal_length(x, y)
201
- super(n, x, y)
217
+ if markersize.nil? && marker_z.nil?
218
+ super(n, x, y)
219
+ else
220
+ markersize = Array.new(n, markersize) if markersize.is_a?(Numeric)
221
+ markersize.map! { |i| (100 * i).round }
222
+ marker_z ||= Array.new(n, 0)
223
+ raise ArgumentError if n != equal_length(markersize, marker_z)
224
+
225
+ color = to_rgb_color(marker_z)
226
+ gdp(x, y, GDP_DRAW_MARKERS, markersize.zip(color).flatten)
227
+ end
202
228
  end
203
229
 
204
230
  # Draw a text at position `x`, `y` using the current text attributes.
@@ -269,7 +295,9 @@ module GR
269
295
  def nonuniformcellarray(x, y, dimx, dimy, color)
270
296
  raise ArgumentError unless x.length == dimx + 1 && y.length == dimy + 1
271
297
 
272
- super(x, y, dimx, dimy, 1, 1, dimx, dimy, int(color))
298
+ nx = dimx == x.length ? -dimx : dimx
299
+ ny = dimy == y.length ? -dimy : dimy
300
+ super(x, y, nx, ny, 1, 1, dimx, dimy, int(color))
273
301
  end
274
302
 
275
303
  # Display a two dimensional color index array mapped to a disk using polar
@@ -318,6 +346,27 @@ module GR
318
346
  super(x_org, y_org, phimin, phimax, rmin, rmax, dimphi, dimr, 1, 1, dimphi, dimr, int(color))
319
347
  end
320
348
 
349
+ # Display a two dimensional color index array mapped to a disk using polar
350
+ # coordinates with nonuniform cell sizes.
351
+ #
352
+ # @param phi [Array, NArray] array with the angles of the disk sector in degrees
353
+ # @param r [Array, NArray] array with the radii of the disk in world coordinates
354
+ # @param ncol [Integer] total number of columns in the color index array and the angle array
355
+ # @param nrow [Integer] total number of rows in the color index array and the radii array
356
+ # @param color [Integer] color index array
357
+ #
358
+ # The mapping of the polar coordinates and the drawing is performed simialr
359
+ # to `gr_polarcellarray` with the difference that the individual cell sizes
360
+ # are specified allowing nonuniform sized cells.
361
+ #
362
+ def nonuniformpolarcellarray(phi, r, ncol, nrow, color)
363
+ raise ArgumentError unless (ncol..(ncol + 1)).include?(phi.length) && (nrow..(nrow + 1)).include?(r.length)
364
+
365
+ dimphi = ncol == phi.length ? -ncol : ncol
366
+ dimr = nrow == r.length ? -nrow : nrow
367
+ super(0, 0, phi, r, dimphi, dimr, 1, 1, ncol, nrow, int(color))
368
+ end
369
+
321
370
  # Generates a generalized drawing primitive (GDP) of the type you specify,
322
371
  # using specified points and any additional information contained in a data
323
372
  # record.
@@ -330,7 +379,7 @@ module GR
330
379
  def gdp(x, y, primid, datrec)
331
380
  n = equal_length(x, y)
332
381
  ldr = datrec.length
333
- super(n, x, y, primid, ldr, datrec)
382
+ super(n, x, y, primid, ldr, int(datrec))
334
383
  end
335
384
 
336
385
  # Generate a cubic spline-fit,
@@ -1423,7 +1472,15 @@ module GR
1423
1472
  # * .webm : WebM video file
1424
1473
  # * .ogg : Ogg video file
1425
1474
  #
1426
- # @!method beginprint
1475
+ # @note Ruby feature - you can use block to call endprint automatically.
1476
+
1477
+ def beginprint(file_path)
1478
+ super(file_path)
1479
+ if block_given?
1480
+ yield
1481
+ endprint
1482
+ end
1483
+ end
1427
1484
 
1428
1485
  # Open and activate a print device with the given layout attributes.
1429
1486
  #
@@ -2014,6 +2071,18 @@ module GR
2014
2071
  super(n, x, y, codes)
2015
2072
  end
2016
2073
 
2074
+ # @param z [Array, NArray]
2075
+ # @return [Array, NArray]
2076
+ def to_rgb_color(z)
2077
+ zmin, zmax = z.minmax
2078
+ return Array.new(z.length, 0) if zmax == zmin
2079
+
2080
+ z.map do |i|
2081
+ zi = (i - zmin) / (zmax - zmin).to_f
2082
+ inqcolor(1000 + (zi * 255).round)
2083
+ end
2084
+ end
2085
+
2017
2086
  # Define the border width of subsequent path output primitives.
2018
2087
  #
2019
2088
  # @param width [Numeric] The border width scale factor
@@ -2034,6 +2103,12 @@ module GR
2034
2103
  inquiry_int { |pt| super(pt) }
2035
2104
  end
2036
2105
 
2106
+ # @!method selectclipxform
2107
+
2108
+ def inqclipxform
2109
+ inquiry_int { |pt| super(pt) }
2110
+ end
2111
+
2037
2112
  # Set the projection type with this flag.
2038
2113
  #
2039
2114
  # @param flag [Integer] projection type
@@ -2190,6 +2265,20 @@ module GR
2190
2265
  super(encoding)
2191
2266
  end
2192
2267
  end
2268
+
2269
+ # Load a font file from a given filename.
2270
+ #
2271
+ # This function loads a font from a given absolute filename and assigns a
2272
+ # font index to it. To use the loaded font call `gr_settextfontprec` using
2273
+ # the resulting font index and precision 3.
2274
+ #
2275
+ # @param filename [String] The absolute filename of the font
2276
+ #
2277
+ def loadfont(str)
2278
+ inquiry_int do |font|
2279
+ super(str, font)
2280
+ end
2281
+ end
2193
2282
  end
2194
2283
 
2195
2284
  ASF_BUNDLED = 0
@@ -2398,6 +2487,10 @@ module GR
2398
2487
  PATH_CURVE4 = 0x04
2399
2488
  PATH_CLOSEPOLY = 0x4f
2400
2489
 
2490
+ GDP_DRAW_PATH = 1
2491
+ GDP_DRAW_LINES = 2
2492
+ GDP_DRAW_MARKERS = 3
2493
+
2401
2494
  MPL_SUPPRESS_CLEAR = 1
2402
2495
  MPL_POSTPONE_UPDATE = 2
2403
2496
 
data/lib/gr/ffi.rb CHANGED
@@ -184,6 +184,8 @@ module GR
184
184
  try_extern 'void gr_inqborderwidth(double *)'
185
185
  try_extern 'void gr_setbordercolorind(int)'
186
186
  try_extern 'void gr_inqbordercolorind(int *)'
187
+ try_extern 'void gr_selectclipxform(int)'
188
+ try_extern 'void gr_inqclipxform(int *);'
187
189
  try_extern 'void gr_setprojectiontype(int)'
188
190
  try_extern 'void gr_inqprojectiontype(int *)'
189
191
  try_extern 'void gr_setperspectiveprojection(double, double, double)'
@@ -204,6 +206,7 @@ module GR
204
206
  try_extern 'void gr_inqtext3d(double, double, double, char *, int axis, double *, double *)'
205
207
  try_extern 'void gr_settextencoding(int)'
206
208
  try_extern 'void gr_inqtextencoding(int *)'
209
+ try_extern 'void gr_loadfont(char *, int *)'
207
210
  # gr_setcallback(char *(*)(const char *));
208
211
  end
209
212
  end
data/lib/gr/plot.rb CHANGED
@@ -33,8 +33,8 @@ module GR
33
33
  # Plot kinds conform to GR.jl
34
34
  PLOT_KIND = %i[line step scatter stem hist contour contourf hexbin heatmap
35
35
  nonuniformheatmap wireframe surface plot3 scatter3 imshow
36
- isosurface polar polarhist polarheatmap trisurf tricont shade
37
- volume].freeze # the name might be changed in the future.
36
+ isosurface polar polarhist polarheatmap nonuniformpolarheatmap
37
+ trisurf tricont shade volume].freeze
38
38
 
39
39
  # Keyword options conform to GR.jl.
40
40
  KW_ARGS = %i[accelerate algorithm alpha ax backgroundcolor barwidth baseline
@@ -78,8 +78,7 @@ module GR
78
78
  zapfchancery_mediumitalic: 130,
79
79
  zapfdingbats: 131,
80
80
  cmuserif_math: 232, # original: cmuserif-math
81
- dejavusans: 233,
82
- pingfangsc: 234
81
+ dejavusans: 233
83
82
  }.freeze
84
83
 
85
84
  @last_plot = nil
@@ -159,7 +158,7 @@ module GR
159
158
  vp3 + 0.925 * (vp4 - vp3)]
160
159
 
161
160
  if %i[contour contourf hexbin heatmap nonuniformheatmap polarheatmap
162
- surface trisurf volume].include?(kind)
161
+ nonuniformpolarheatmap surface trisurf volume].include?(kind)
163
162
  viewport[1] -= 0.1
164
163
  end
165
164
 
@@ -193,7 +192,7 @@ module GR
193
192
  GR.restorestate
194
193
  end
195
194
 
196
- if %i[polar polarhist polarheatmap].include? kind
195
+ if %i[polar polarhist polarheatmap nonuniformpolarheatmap].include? kind
197
196
  xmin, xmax, ymin, ymax = viewport
198
197
  xcenter = 0.5 * (xmin + xmax)
199
198
  ycenter = 0.5 * (ymin + ymax)
@@ -204,7 +203,7 @@ module GR
204
203
 
205
204
  def set_window(kind)
206
205
  scale = 0
207
- unless %i[polar polarhist polarheatmap].include?(kind)
206
+ unless %i[polar polarhist polarheatmap nonuniformpolarheatmap].include?(kind)
208
207
  scale |= GR::OPTION_X_LOG if kvs[:xlog]
209
208
  scale |= GR::OPTION_Y_LOG if kvs[:ylog]
210
209
  scale |= GR::OPTION_Z_LOG if kvs[:zlog]
@@ -223,7 +222,7 @@ module GR
223
222
  end
224
223
 
225
224
  major_count = if %i[wireframe surface plot3 scatter3 polar polarhist
226
- polarheatmap trisurf volume].include?(kind)
225
+ polarheatmap nonuniformpolarheatmap trisurf volume].include?(kind)
227
226
  2
228
227
  else
229
228
  5
@@ -301,7 +300,7 @@ module GR
301
300
  end
302
301
 
303
302
  kvs[:window] = xmin, xmax, ymin, ymax
304
- if %i[polar polarhist polarheatmap].include?(kind)
303
+ if %i[polar polarhist polarheatmap nonuniformpolarheatmap].include?(kind)
305
304
  GR.setwindow(-1, 1, -1, 1)
306
305
  else
307
306
  GR.setwindow(xmin, xmax, ymin, ymax)
@@ -622,7 +621,12 @@ module GR
622
621
  font = FONTS[sym_name]
623
622
  GR.settextfontprec(font, font > 200 ? 3 : 0)
624
623
  else
625
- warn "Unknown font name: #{name}" # should raise error?
624
+ font = GR.loadfont(name)
625
+ if font >= 0
626
+ GR.settextfontprec(font, 3)
627
+ else
628
+ warn "Unknown font name: #{name}"
629
+ end
626
630
  end
627
631
  else
628
632
  # The following fonts are the default in GR.jl
@@ -636,7 +640,7 @@ module GR
636
640
  set_window(kind)
637
641
  if %i[polar polarhist].include?(kind)
638
642
  draw_polar_axes
639
- elsif !%i[imshow isosurface polarheatmap].include?(kind)
643
+ elsif !%i[imshow isosurface polarheatmap nonuniformpolarheatmap].include?(kind)
640
644
  draw_axes(kind)
641
645
  end
642
646
  end
@@ -757,7 +761,7 @@ module GR
757
761
  GR.fillarc(-ρ[i], ρ[i], -ρ[i], ρ[i], θ[i - 1], θ[i])
758
762
  end
759
763
 
760
- when :polarheatmap
764
+ when :polarheatmap, :nonuniformpolarheatmap
761
765
  w, h = z.shape
762
766
  cmap = colormap
763
767
  cmin, cmax = kvs[:zrange]
@@ -766,7 +770,15 @@ module GR
766
770
  data.reverse(axis: 1) if kvs[:yflip]
767
771
  colors = data * 255 + 1000
768
772
  colors = colors.transpose # Julia is column major
769
- GR.polarcellarray(0, 0, 0, 360, 0, 1, w, h, colors)
773
+ case kind
774
+ when :polarheatmap
775
+ GR.polarcellarray(0, 0, 0, 360, 0, 1, w, h, colors)
776
+ when :nonuniformpolarheatmap
777
+ ymax = y.max.to_f
778
+ ρ = y.map{|i| i / ymax}
779
+ θ = x.map { |i| i * 180 / Math::PI }
780
+ GR.nonuniformpolarcellarray(θ, ρ, w, h, colors)
781
+ end
770
782
  draw_polar_axes
771
783
  kvs[:zrange] = [cmin, cmax]
772
784
  colorbar
@@ -1023,7 +1035,7 @@ module GR
1023
1035
 
1024
1036
  def to_svg
1025
1037
  ## Need IRuby improvemend.
1026
- GR.show(false) if ENV['GKSwstype'] == 'svg'
1038
+ GR.show(false) if ENV['GKS_WSTYPE'] == 'svg'
1027
1039
  end
1028
1040
 
1029
1041
  private
@@ -1285,6 +1297,20 @@ module GR
1285
1297
  end
1286
1298
  end
1287
1299
 
1300
+ # (Plot) Draw a nonuniformpolarheatmap.
1301
+ def nonuniformpolarheatmap(*args)
1302
+ # FIXME
1303
+ args, kv = format_xyzc(*args)
1304
+ _x, _y, z = args
1305
+ ysize, xsize = z.shape
1306
+ z = z.reshape(xsize, ysize)
1307
+ create_plot(:nonuniformpolarheatmap, kv) do |plt|
1308
+ plt.kvs[:xlim] ||= [0.5, xsize + 0.5]
1309
+ plt.kvs[:ylim] ||= [0.5, ysize + 0.5]
1310
+ plt.args = [[(1..xsize).to_a, (1..ysize).to_a, z, nil, '']]
1311
+ end
1312
+ end
1313
+
1288
1314
  alias _contour_ contour
1289
1315
  # (Plot) Draw a contour plot.
1290
1316
  def contour(*args)
data/lib/gr3.rb CHANGED
@@ -823,6 +823,7 @@ module GR3
823
823
  IA_END_OF_LIST = 0
824
824
  IA_FRAMEBUFFER_WIDTH = 1
825
825
  IA_FRAMEBUFFER_HEIGHT = 2
826
+ IA_NUM_THREADS = 3
826
827
 
827
828
  # Error
828
829
  ERROR_NONE = 0
@@ -853,6 +854,11 @@ module GR3
853
854
  DRAWABLE_OPENGL = 1
854
855
  DRAWABLE_GKS = 2
855
856
 
857
+ # Projection
858
+ PROJECTION_PERSPECTIVE = 0
859
+ PROJECTION_PARALLEL = 1
860
+ PROJECTION_ORTHOGRAPHIC = 2
861
+
856
862
  # SurfaceOption
857
863
  SURFACE_DEFAULT = 0
858
864
  SURFACE_NORMALS = 1
data/lib/gr3/ffi.rb CHANGED
@@ -138,5 +138,7 @@ module GR3
138
138
  # try_extern 'void gr3_drawtrianglesurface(int n, const float *triangles)'
139
139
  try_extern 'void gr_volume(int nx, int ny, int nz, double *data, ' \
140
140
  'int algorithm, double *dmin_ptr, double *dmax_ptr)'
141
+ try_extern 'void gr3_setorthographicprojection' \
142
+ '(float left, float right, float bottom, float top, float znear, float zfar)'
141
143
  end
142
144
  end
@@ -16,9 +16,9 @@ module GRCommons
16
16
  args.map! do |arg|
17
17
  case arg
18
18
  when Array
19
- GRCommons::GRCommonUtils.public_send(default_type, arg)
19
+ GRCommonUtils.public_send(default_type, arg)
20
20
  when ->(x) { defined?(Numo::NArray) && x.is_a?(Numo::NArray) }
21
- GRCommons::GRCommonUtils.public_send(default_type, arg)
21
+ GRCommonUtils.public_send(default_type, arg)
22
22
  else
23
23
  arg
24
24
  end
@@ -8,7 +8,7 @@ module GRCommons
8
8
  # Sets the environment variable when the module is extended.
9
9
  def self.extended(_obj)
10
10
  require 'tmpdir'
11
- ENV['GKSwstype'] = 'svg'
11
+ ENV['GKS_WSTYPE'] = 'svg'
12
12
  ENV['GKS_FILEPATH'] = Dir::Tmpname.create('plot-') {}
13
13
  end
14
14
 
@@ -16,7 +16,7 @@ module GRCommons
16
16
  def show(display = true)
17
17
  emergencyclosegks
18
18
  sleep 0.5
19
- type = ENV['GKSwstype']
19
+ type = ENV['GKS_WSTYPE']
20
20
  case type
21
21
  when 'svg'
22
22
  data = File.read("#{ENV['GKS_FILEPATH']}.svg")
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GRCommons
4
- VERSION = '0.0.25'
4
+ VERSION = '0.0.26'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-gr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.25
4
+ version: 0.0.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - kojix2
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-04 00:00:00.000000000 Z
11
+ date: 2021-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: histogram