### Convert points to raster with scattermore Source: https://cran.r-project.org/web/packages/scattermore/refman/scattermore.html Generates a raster scatterplot from point coordinates. Use the example to visualize a large dataset. ```R scattermore( xy, size = c(512, 512), xlim = c(min(xy[, 1]), max(xy[, 1])), ylim = c(min(xy[, 2]), max(xy[, 2])), rgba = c(0L, 0L, 0L, 255L), cex = 0, output.raster = TRUE ) ``` ```R library(scattermore) plot(scattermore(cbind(rnorm(1e6), rnorm(1e6)), rgba = c(64, 128, 192, 10))) ``` -------------------------------- ### Render Lines into a Histogram Source: https://cran.r-project.org/web/packages/scattermore/refman/scattermore.html Renders lines defined by start and end coordinates into a histogram. 'xlim' and 'ylim' define the rendering area. 'skip_end_pixel' is TRUE by default to prevent double-counting pixels when connecting lines. ```r scatter_lines_histogram( xy, xlim = c(min(xy[, c(1, 3)]), max(xy[, c(1, 3)])), ylim = c(min(xy[, c(2, 4)]), max(xy[, c(2, 4)])), out_size = c(512L, 512L), skip_start_pixel = FALSE, skip_end_pixel = TRUE ) ``` -------------------------------- ### Initialize scattermore environment Source: https://cran.r-project.org/web/packages/scattermore/vignettes/low_level_interface.html Load the package and set the random seed for reproducibility. ```R library(scattermore) set.seed(2023) ``` -------------------------------- ### Initialize RGBWT layers Source: https://cran.r-project.org/web/packages/scattermore/vignettes/low_level_interface.html Prepare two RGBWT layers with identical bitmap size and coordinate systems for subsequent merging or blending. ```R rgbwt1 <- scatter_lines_rgbwt(cbind(pts, pts2), out_size=c(512,512), xlim=c(-3,7), ylim=c(-5,2), RGBA=as.vector(col2rgb('#ffcc0010', alpha=T))) rgbwt2 <- scatter_points_rgbwt(pts, out_size=c(512,512), xlim=c(-3,7), ylim=c(-5,2), palette=col2rgb(rainbow(4, alpha=0.5), alpha=T), map=clusters) rgbwt2 <- apply_kernel_rgbwt(rgbwt2, 'circle', radius=3) ``` -------------------------------- ### Generate random point data Source: https://cran.r-project.org/web/packages/scattermore/vignettes/low_level_interface.html Create sample datasets for plotting points and lines. ```R n <- 10000 pts <- matrix(rnorm(n*2), n, 2) pts2 <- cbind(5+rnorm(n), -5*rexp(n)) ``` -------------------------------- ### Plot point density histograms Source: https://cran.r-project.org/web/packages/scattermore/vignettes/low_level_interface.html Convert point data into an integer density map and visualize it. ```R pdens <- scattermore::scatter_points_histogram(pts, out_size=c(128,128)) par(mar = c(0,0,0,0), bg='white') image(pdens) ``` -------------------------------- ### scattermore Source: https://cran.r-project.org/web/packages/scattermore/refman/scattermore.html Convert points to raster scatterplot rather quickly. ```APIDOC ## scattermore ### Description Convert points to raster scatterplot rather quickly. ### Parameters #### Arguments - **xy** (2-column float matrix) - Required - Point coordinates. - **size** (2-element vector) - Optional - Integer size of the result raster, defaults to c(512, 512). - **xlim** (Float limits) - Optional - Position of the first pixel on the left and last on the right. - **ylim** (Float limits) - Optional - Position of the first pixel on the top and last on the bottom. - **rgba** (4-row matrix or 4-item vector) - Optional - Color values 0-255. - **cex** (numeric) - Optional - Additional point radius in pixels, 0=single-pixel dots. - **output.raster** (boolean) - Optional - Output R-style raster, default TRUE. ### Value Raster with the result. ``` -------------------------------- ### Export to PNG Source: https://cran.r-project.org/web/packages/scattermore/vignettes/low_level_interface.html Save RGBA data directly to a PNG file to maintain pixel-perfect quality and transparency. ```R png::writePNG(rgba_float_to_rgba_int(rgba)/255, "myPicture.png") ``` -------------------------------- ### Create complex composite graphic Source: https://cran.r-project.org/web/packages/scattermore/vignettes/low_level_interface.html Generate a multi-layered graphic combining lines, points, and a density background using RGBWT and RGBA blending. ```R # lines rgbwt1 <- scatter_lines_rgbwt(cbind(pts, pts2), out_size=c(512,512), xlim=c(-3,7), ylim=c(-5,2), RGBA=as.vector(col2rgb('#fff0c018', alpha=T))) # points rgbwt2 <- scatter_points_rgbwt(pts, out_size=c(512,512), xlim=c(-3,7), ylim=c(-5,2), palette=col2rgb(rainbow(4, alpha=0.5), alpha=T), map=clusters) rgbwt2 <- apply_kernel_rgbwt(rgbwt2, 'circle', radius=3) # background density of the line endpoints pdens <- scatter_points_histogram(pts2, out_size=c(512,512), xlim=c(-3,7), ylim=c(-5,2)) pdens <- apply_kernel_histogram(pdens, 'gauss', radius=10) rgbwt3 <- histogram_to_rgbwt(sqrt(pdens), RGBA=col2rgb(topo.colors(100)[20:100], alpha=T)) rgba <- blend_rgba_float(list( rgbwt_to_rgba_float(merge_rgbwt(list(rgbwt1, rgbwt2))), rgbwt_to_rgba_float(rgbwt3) )) rstr <- rgba_int_to_raster(rgba_float_to_rgba_int(rgba)) par(mar=c(2,2,0.5,0.5), bg='white') plot(c(), xlim=c(-3,7), ylim=c(-5,2)) rasterImage(t(rstr), xleft=-3, xright=7, ybottom=-5, ytop=2) # a trick is required to flip the bitmap vertically contour(seq(-3,7,length.out=512), y=seq(-5,2,length.out=512), pdens[,ncol(pdens):1], add=T, levels=c(2,10)) ``` -------------------------------- ### Render colored points with scatter_points_rgbwt Source: https://cran.r-project.org/web/packages/scattermore/refman/scattermore.html Creates an RGBWT bitmap from point coordinates, supporting individual point coloring via RGBA matrices or palette lookups. ```R scatter_points_rgbwt( xy, xlim = c(min(xy[, 1]), max(xy[, 1])), ylim = c(min(xy[, 2]), max(xy[, 2])), out_size = c(512, 512), RGBA = c(0, 0, 0, 255), map = NULL, palette = NULL ) ``` -------------------------------- ### Create scatterplot layer with scattermoreplot Source: https://cran.r-project.org/web/packages/scattermore/refman/scattermore.html Provides a base-graphics-like interface for rendering scatterplots, limited to linear axes. ```R scattermoreplot( x, y, xlim, ylim, size, col = grDevices::rgb(0, 0, 0, 1), cex = 0, pch = NULL, xlab, ylab, ... ) ``` -------------------------------- ### Render Lines into an RGBWT Bitmap Source: https://cran.r-project.org/web/packages/scattermore/refman/scattermore.html Renders lines into an RGBWT bitmap. 'xlim' and 'ylim' define the rendering area. 'RGBA' specifies the color, and 'skip_end_pixel' is TRUE by default. ```r scatter_lines_rgbwt( xy, xlim = c(min(xy[, c(1, 3)]), max(xy[, c(1, 3)])), ylim = c(min(xy[, c(2, 4)]), max(xy[, c(2, 4)])), out_size = c(512L, 512L), RGBA = c(0, 0, 0, 255), skip_start_pixel = FALSE, skip_end_pixel = TRUE ) ``` -------------------------------- ### Plot line density histograms Source: https://cran.r-project.org/web/packages/scattermore/vignettes/low_level_interface.html Convert line data into a density map, with an optional log transformation for better visualization. ```R ldens <- scattermore::scatter_lines_histogram(cbind(pts, pts2), out_size=c(256,256)) par(mar = c(0,0,0,0), bg='white') image(ldens) ``` ```R ldens <- scattermore::scatter_lines_histogram(cbind(pts, pts2), out_size=c(256,256)) par(mar = c(0,0,0,0), bg='white') image(log1p(ldens)) ``` -------------------------------- ### Create a scatter plot with scattermoreplot Source: https://cran.r-project.org/web/packages/scattermore/refman/scattermore.html Generates a scatter plot using a large dataset with custom color mapping. ```R # plot an actual rainbow library(scattermore) d <- data.frame(s = qlogis(1:1e6 / (1e6 + 1), 6, 0.5), t = rnorm(1e6, pi / 2, 0.5)) scattermoreplot( d$s * cos(d$t), d$s * sin(d$t), col = rainbow(1e6, alpha = .05)[c((9e5 + 1):1e6, 1:9e5)], main = "scattermore demo" ) ``` -------------------------------- ### Blend RGBA Matrices Source: https://cran.r-project.org/web/packages/scattermore/refman/scattermore.html Blend a list of floating-point RGBA arrays with premultiplied alpha. ```R blend_rgba_float(fRGBA_list) ``` -------------------------------- ### Plot lines as RGBWT rasters Source: https://cran.r-project.org/web/packages/scattermore/vignettes/low_level_interface.html Render lines into RGBWT format using specific color and coordinate constraints. ```R #TODO as.vector rgbwt <- scatter_lines_rgbwt(cbind(pts, pts2), out_size=c(512,512), xlim=c(-3,7), ylim=c(-5,2), RGBA=as.vector(col2rgb('#8010f005', alpha=T))) rstr <- rgba_int_to_raster(rgbwt_to_rgba_int(rgbwt)) par(mar=c(0,0,0,0), bg='white') plot(rstr) ``` -------------------------------- ### Blend RGBA layers Source: https://cran.r-project.org/web/packages/scattermore/vignettes/low_level_interface.html Overlay layers in RGBA format where the order of elements determines which layer appears in the foreground. ```R rgbwt <- blend_rgba_float(list(rgbwt_to_rgba_float(rgbwt1), rgbwt_to_rgba_float(rgbwt2))) rstr <- rgba_int_to_raster(rgba_float_to_rgba_int(rgbwt)) par(mar=c(0,0,0,0), bg='white') plot(rstr) ``` ```R rgba <- blend_rgba_float(list(rgbwt_to_rgba_float(rgbwt2), rgbwt_to_rgba_float(rgbwt1))) rstr <- rgba_int_to_raster(rgba_float_to_rgba_int(rgba)) par(mar=c(0,0,0,0), bg='white') plot(rstr) ``` -------------------------------- ### scatter_points_rgbwt Source: https://cran.r-project.org/web/packages/scattermore/refman/scattermore.html Render colored points into a RGBWT bitmap. ```APIDOC ## scatter_points_rgbwt ### Description Render colored points into a RGBWT bitmap. ### Parameters #### Arguments - **xy** (2-column matrix) - Required - N point coordinates (X and Y) in rows. - **xlim** (2-element vector) - Optional - Rendered area limits for X-axis. - **ylim** (2-element vector) - Optional - Rendered area limits for Y-axis. - **out_size** (2-element vector) - Optional - Size of the result raster, defaults to c(512L, 512L). - **RGBA** (4-element vector or 4-by-N matrix) - Optional - Point colors in integer RGBA. - **map** (Vector) - Optional - N integer indices to palette, overrides RGBA. - **palette** (4-by-K matrix) - Optional - RGBA colors used as a palette lookup. ### Value A RGBWT array with the rendered points. ``` -------------------------------- ### Render 2D histogram with scatter_points_histogram Source: https://cran.r-project.org/web/packages/scattermore/refman/scattermore.html Counts points within pixels to generate a 2D histogram. ```R scatter_points_histogram( xy, xlim = c(min(xy[, 1]), max(xy[, 1])), ylim = c(min(xy[, 2]), max(xy[, 2])), out_size = c(512L, 512L) ) ``` -------------------------------- ### Apply Kernel to RGBWT Raster Source: https://cran.r-project.org/web/packages/scattermore/refman/scattermore.html Apply a blurring kernel to an RGBWT array with channels for red, green, blue, weight, and transparency. ```R apply_kernel_rgbwt( fRGBWT, filter = "circle", mask = default_kernel(filter, radius, sigma), radius = 2, sigma = radius/2, threads = 0 ) ``` -------------------------------- ### blend_rgba_float Source: https://cran.r-project.org/web/packages/scattermore/refman/scattermore.html Blend RGBA matrices, useful for compositing images. ```APIDOC ## blend_rgba_float ### Description Blend RGBA matrices. ### Usage ``` blend_rgba_float(fRGBA_list) ``` ### Arguments `fRGBA_list` | List of floating-point RGBA arrays with premultiplied alpha (each of the same size N-by-M-by-4). The "first" matrix in the list is the one that will be rendered on "top". ### Value Blended RGBA matrix. ``` -------------------------------- ### Colorizing density heat maps Source: https://cran.r-project.org/web/packages/scattermore/vignettes/low_level_interface.html Converts a density histogram into an RGBWT format for colorized visualization. ```R pdens <- scattermore::scatter_points_histogram(pts, out_size=c(512,512)) pdens <- apply_kernel_histogram(pdens, 'circle', radius=10) rgbwt <- histogram_to_rgbwt(log1p(pdens), col=topo.colors(100)[10:100]) rstr <- rgba_int_to_raster(rgbwt_to_rgba_int(rgbwt)) par(mar=c(0,0,0,0), bg='white') plot(rstr) ``` -------------------------------- ### Smoothing densities with Gaussian kernels Source: https://cran.r-project.org/web/packages/scattermore/vignettes/low_level_interface.html Uses a Gaussian kernel to smooth point density histograms. ```R pdens <- scattermore::scatter_points_histogram(pts, out_size=c(256,256), xlim=c(-3,3), ylim=c(-3,3)) pdens <- apply_kernel_histogram(pdens, 'gauss', radius=10) par(mar = c(0,0,0,0), bg='white') image(pdens, col=rainbow(100)) ``` -------------------------------- ### Create Raster from Integer RGBA Matrix Source: https://cran.r-project.org/web/packages/scattermore/refman/scattermore.html Generates a raster object from an integer RGBA matrix where all values are between 0 and 255. ```r rgba_int_to_raster(i32RGBA) ``` -------------------------------- ### scatter_points_histogram Source: https://cran.r-project.org/web/packages/scattermore/refman/scattermore.html Render a 2D histogram with given points. ```APIDOC ## scatter_points_histogram ### Description Render a 2D histogram with given points. ### Parameters #### Arguments - **xy** (2-column matrix) - Required - Point coordinates (X and Y). - **xlim** (2-element vector) - Optional - Rendered area limits for X-axis. - **ylim** (2-element vector) - Optional - Rendered area limits for Y-axis. - **out_size** (2-element vector) - Optional - Size of the result raster, defaults to c(512L, 512L). ### Value 2D histogram with the points counted in appropriate pixels. ``` -------------------------------- ### Plotting points with RGBWT Source: https://cran.r-project.org/web/packages/scattermore/vignettes/low_level_interface.html Generates an RGBWT plot from points and converts it to a raster for display. ```R rgbwt <- scatter_points_rgbwt(pts, out_size=c(512,512), palette=col2rgb(rainbow(4, alpha=0.5), alpha=T), map=clusters) rstr <- rgba_int_to_raster(rgbwt_to_rgba_int(rgbwt)) par(mar=c(0,0,0,0), bg='white') plot(rstr) ``` -------------------------------- ### Plot points as RGBWT rasters Source: https://cran.r-project.org/web/packages/scattermore/vignettes/low_level_interface.html Render points into RGBWT format and convert to standard R rasters, supporting custom area limits and color specifications. ```R # TODO xlim docs rgbwt <- scatter_points_rgbwt(pts, out_size=c(512,512), xlim=c(-3,3), ylim=c(-3,3)) rstr <- rgba_int_to_raster(rgbwt_to_rgba_int(rgbwt)) par(mar=c(0,0,0,0), bg='white') plot(rstr) ``` ```R rgbwt <- scatter_points_rgbwt(pts, out_size=c(128,128), RGBA=col2rgb('#8010f010', alpha=T)) rstr <- rgba_int_to_raster(rgbwt_to_rgba_int(rgbwt)) par(mar=c(0,0,0,0), bg='white') plot(rstr, interpolate=F) ``` ```R rgbwt <- scatter_points_rgbwt(pts, out_size=c(128,128), RGBA=col2rgb(rainbow(n, alpha=0.3), alpha=T)) rstr <- rgba_int_to_raster(rgbwt_to_rgba_int(rgbwt)) par(mar=c(0,0,0,0), bg='white') plot(rstr, interpolate=F) ``` ```R clusters <- 1 + (pts[,1] < 0) + 2 * (pts[,2] < 0) rgbwt <- scatter_points_rgbwt(pts, out_size=c(128,128), palette=col2rgb(rainbow(4, alpha=0.2), alpha=T), map=clusters) rstr <- rgba_int_to_raster(rgbwt_to_rgba_int(rgbwt)) par(mar=c(0,0,0,0), bg='white') plot(rstr, interpolate=F) ``` -------------------------------- ### Render Large Scatterplot with geom_scattermore Source: https://cran.r-project.org/web/packages/scattermore/refman/scattermore.html Use geom_scattermore for efficient rendering of large datasets in ggplot2. Requires 'ggplot2' and 'scattermore' libraries. Adjust 'pointsize', 'alpha', and 'pixels' for performance and visual quality. ```r library(ggplot2) library(scattermore) ggplot(data.frame(x = rnorm(1e6), y = rexp(1e6))) + geom_scattermore(aes(x, y, color = x), pointsize = 3, alpha = 0.1, pixels = c(1000, 1000), interpolate = TRUE ) + scale_color_viridis_c() ``` -------------------------------- ### Overlaying contours on density images Source: https://cran.r-project.org/web/packages/scattermore/vignettes/low_level_interface.html Adds contour lines to an existing density image. ```R par(mar = c(0,0,0,0), bg='white') image(pdens, col=topo.colors(100)[20:100]) contour(pdens-15, levels=c(-10,0,30), add=T) ``` -------------------------------- ### Convert Float RGBA Bitmap to Integer RGBA Source: https://cran.r-project.org/web/packages/scattermore/refman/scattermore.html Transforms an RGBA bitmap with pre-multiplied alpha from floating-point format to an integer RGBA format. The output is not pre-multiplied by alpha. ```r rgba_float_to_rgba_int(fRGBA) ``` -------------------------------- ### scatter_lines_histogram Source: https://cran.r-project.org/web/packages/scattermore/refman/scattermore.html Renders lines into a histogram format. ```APIDOC ## scatter_lines_histogram ### Description Render lines into a histogram. ### Parameters #### Arguments - **xy** (4-column matrix) - Required - Point coordinates (x_start, y_start, x_end, y_end). - **xlim** (vector) - Optional - Rendered area X limits. - **ylim** (vector) - Optional - Rendered area Y limits. - **out_size** (vector) - Optional - Size of the result raster. - **skip_start_pixel** (boolean) - Optional - Whether to omit the start pixel. - **skip_end_pixel** (boolean) - Optional - Whether to omit the end pixel. ### Response - **Histogram** (matrix) - Histogram with the rendered lines. ``` -------------------------------- ### Merge Multiple RGBWT Matrices Source: https://cran.r-project.org/web/packages/scattermore/refman/scattermore.html Combines a list of RGBWT matrices into a single merged matrix. The order of matrices in the list does not affect the final result, barring minor floating-point variations. ```r merge_rgbwt(fRGBWT_list) ``` -------------------------------- ### Expanding points with kernel functions Source: https://cran.r-project.org/web/packages/scattermore/vignettes/low_level_interface.html Applies a circular kernel to expand point sizes in an RGBWT plot. ```R rgbwt <- scatter_points_rgbwt(pts, out_size=c(512,512), palette=col2rgb(rainbow(4, alpha=0.1), alpha=T), map=clusters) rgbwt <- apply_kernel_rgbwt(rgbwt, 'circle', radius=10) rstr <- rgba_int_to_raster(rgbwt_to_rgba_int(rgbwt)) par(mar=c(0,0,0,0), bg='white') plot(rstr) ``` -------------------------------- ### Apply Kernel to Histogram Source: https://cran.r-project.org/web/packages/scattermore/refman/scattermore.html Apply a blurring kernel to a floating-point histogram matrix. ```R apply_kernel_histogram( fhistogram, filter = "circle", mask = default_kernel(filter, radius, sigma), radius = 2, sigma = radius/2, threads = 0 ) ``` -------------------------------- ### Convert RGBWT Matrix to Integer RGBA Source: https://cran.r-project.org/web/packages/scattermore/refman/scattermore.html Converts an RGBWT matrix into an integer RGBA matrix. The output is not pre-multiplied by alpha. ```r rgbwt_to_rgba_int(fRGBWT) ``` -------------------------------- ### Add Scattermore Layer to ggplot2 Source: https://cran.r-project.org/web/packages/scattermore/refman/scattermore.html Integrate rasterized scatterplots into ggplot2 workflows to optimize output size. ```R geom_scattermore( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, interpolate = FALSE, pointsize = 0, pixels = c(512, 512) ) ``` -------------------------------- ### apply_kernel_rgbwt Source: https://cran.r-project.org/web/packages/scattermore/refman/scattermore.html Apply a kernel to the given RGBWT raster for image processing. ```APIDOC ## apply_kernel_rgbwt ### Description Apply a kernel to the given RGBWT raster. ### Usage ``` apply_kernel_rgbwt( fRGBWT, filter = "circle", mask = default_kernel(filter, radius, sigma), radius = 2, sigma = radius/2, threads = 0 ) ``` ### Arguments `fRGBWT` | RGBWT array with channels `red`, `green`, `blue`, `weight` and `transparency`. The dimension should be N times M times 5. `filter` | Use the pre-defined filter, either `circle`, `square`, `gauss`. Defaults to `circle`. `mask` | Custom kernel used for blurring, overrides `filter`. Must be a square matrix of odd size. `radius` | Radius of the kernel (counted without the "middle" pixel"), defaults to 2. The generated kernel matrix will be a square with (2*radius+1) pixels on each side. `sigma` | Radius of the Gaussian function selected by `filter`, defaults to `radius/2`. `threads` | Number of parallel threads (default 0 chooses hardware concurrency). ### Value RGBWT matrix. ``` -------------------------------- ### Convert RGBWT Matrix to Float RGBA Source: https://cran.r-project.org/web/packages/scattermore/refman/scattermore.html Converts an RGBWT matrix into a floating-point RGBA matrix suitable for alpha-blending. The output RGBA matrix is pre-multiplied by alpha. ```r rgbwt_to_rgba_float(fRGBWT) ``` -------------------------------- ### apply_kernel_histogram Source: https://cran.r-project.org/web/packages/scattermore/refman/scattermore.html Apply a kernel to the given histogram for image processing. ```APIDOC ## apply_kernel_histogram ### Description Apply a kernel to the given histogram. ### Usage ``` apply_kernel_histogram( fhistogram, filter = "circle", mask = default_kernel(filter, radius, sigma), radius = 2, sigma = radius/2, threads = 0 ) ``` ### Arguments `fhistogram` | Matrix or array interpreted as histogram of floating-point values. `filter` | Use the pre-defined filter, either `circle`, `square`, `gauss`. Defaults to `circle`. `mask` | Custom kernel used for blurring, overrides `filter`. Must be a square matrix of odd size. `radius` | Radius of the kernel (counted without the "middle" pixel"), defaults to 2. The generated kernel matrix will be a square with (2*radius+1) pixels on each side. `sigma` | Radius of the Gaussian function selected by `filter`, defaults to `radius/2`. `threads` | Number of parallel threads (default 0 chooses hardware concurrency). ### Value 2D matrix with the histogram processed by the kernel application. ``` -------------------------------- ### Access GeomScattermost Source: https://cran.r-project.org/web/packages/scattermore/refman/scattermore.html Reference the GeomScattermost ggproto object. ```R GeomScattermost ``` -------------------------------- ### Access GeomScattermore Source: https://cran.r-project.org/web/packages/scattermore/refman/scattermore.html Reference the GeomScattermore ggproto object. ```R GeomScattermore ``` -------------------------------- ### geom_scattermore Source: https://cran.r-project.org/web/packages/scattermore/refman/scattermore.html ggplot2 geom for creating rasterized scatterplots, optimizing performance for large datasets. ```APIDOC ## geom_scattermore ### Description `ggplot2::ggplot()` integration. This cooperates with the rest of ggplot (so you can use it to e.g. add rasterized scatterplots to vector output in order to reduce PDF size). Note that the ggplot processing overhead still dominates the plotting time. Use `geom_scattermost()` to tradeoff some niceness and circumvent ggplot logic to gain speed. ### Usage ``` geom_scattermore( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, interpolate = FALSE, pointsize = 0, pixels = c(512, 512) ) ``` ### Arguments `mapping`, `data`, `stat`, `position`, `inherit.aes`, `show.legend`, `...` | passed to `ggplot2::layer()` `na.rm` | Remove NA values, just as with `ggplot2::geom_point()`. `interpolate` | Default FALSE, passed to `grid::rasterGrob()`. `pointsize` | Radius of rasterized point. Use `0` for single pixels (fastest). `pixels` | Vector with X and Y resolution of the raster, default `c(512,512)`. ### Details Accepts aesthetics `x`, `y`, `colour` and `alpha`. Point size is fixed for all points. Due to rasterization properties it is often beneficial to try non-integer point sizes, e.g. `3.2` looks much better than `3`. ``` -------------------------------- ### Applying custom kernels to points Source: https://cran.r-project.org/web/packages/scattermore/vignettes/low_level_interface.html Uses a custom mask function to define the shape of expanded pixels. ```R rgbwt <- scatter_points_rgbwt(pts, out_size=c(512,512), palette=col2rgb(rainbow(4, alpha=1), alpha=T), map=clusters) rgbwt <- apply_kernel_rgbwt(rgbwt, 'own', mask=outer(1:11, 1:11, Vectorize(function(x,y) 1/(x*y)))) rstr <- rgba_int_to_raster(rgbwt_to_rgba_int(rgbwt)) par(mar=c(0,0,0,0), bg='white') plot(rstr) ``` -------------------------------- ### GeomScattermost Source: https://cran.r-project.org/web/packages/scattermore/refman/scattermore.html The actual geom for scattermost, an alternative geom for scattermore. ```APIDOC ## GeomScattermost ### Description The actual geom for scattermost ### Usage ``` GeomScattermost ``` ### Format An object of class `GeomScattermost` (inherits from `Geom`, `ggproto`, `gg`) of length 4. ``` -------------------------------- ### Merge RGBWT layers Source: https://cran.r-project.org/web/packages/scattermore/vignettes/low_level_interface.html Combine RGBWT layers using an associative and commutative merge operation that avoids overplotting. ```R rgbwt <- merge_rgbwt(list(rgbwt1, rgbwt2)) rstr <- rgba_int_to_raster(rgbwt_to_rgba_int(rgbwt)) par(mar=c(0,0,0,0), bg='white') plot(rstr) ``` -------------------------------- ### Convert Histogram to RGBWT Matrix Source: https://cran.r-project.org/web/packages/scattermore/refman/scattermore.html Colorizes a given histogram matrix using a specified palette. The 'RGBA' argument can override the 'col' argument for custom palettes. 'zlim' defines the histogram value range for coloring. ```r histogram_to_rgbwt( fhistogram, RGBA = grDevices::col2rgb(col, alpha = T), col = grDevices::hcl.colors(10), zlim = c(min(fhistogram), max(fhistogram)) ) ``` -------------------------------- ### scattermoreplot Function Source: https://cran.r-project.org/web/packages/scattermore/refman/scattermore.html The scattermoreplot function is designed for plotting large datasets efficiently. It accepts arguments similar to `graphics::plot()` and forwards specific arguments to the `scattermore()` function for optimized rendering. ```APIDOC ## scattermoreplot Function ### Description This function creates scatter plots, optimized for large datasets, by leveraging the `scattermore` package. It accepts arguments for data, plot aesthetics, and specific `scattermore` parameters. ### Arguments - **x** (numeric vector) - The x-coordinates of the points. Used as in `graphics::plot()` or forwarded. - **y** (numeric vector) - The y-coordinates of the points. Used as in `graphics::plot()` or forwarded. - **xlim** (numeric vector) - The x-axis limits. Used as in `graphics::plot()` or forwarded. - **ylim** (numeric vector) - The y-axis limits. Used as in `graphics::plot()` or forwarded. - **xlab** (character) - The x-axis label. Used as in `graphics::plot()` or forwarded. - **ylab** (character) - The y-axis label. Used as in `graphics::plot()` or forwarded. - **...** - Additional arguments to be passed to `graphics::plot()`. - **size** (numeric) - The size of the points. If missing, it's auto-derived from the device and plot size. This estimate may not be pixel-perfect on all devices. - **col** (color) - The color of the points. Can be a single color or a vector of colors. - **cex** (numeric) - The magnification factor for point sizes. Forwarded to `scattermore()`. - **pch** (integer) - The plotting character. This argument is ignored to improve compatibility with `graphics::plot()`. ### Request Example ```R library(scattermore) d <- data.frame(s = qlogis(1:1e6 / (1e6 + 1), 6, 0.5), t = rnorm(1e6, pi / 2, 0.5)) scattermoreplot( d$s * cos(d$t), d$s * sin(d$t), col = rainbow(1e6, alpha = .05)[c((9e5 + 1):1e6, 1:9e5)], main = "scattermore demo" ) ``` ### Response This function generates a plot and does not return a specific value in the context of an API response. The output is the visual plot itself. ``` -------------------------------- ### histogram_to_rgbwt Source: https://cran.r-project.org/web/packages/scattermore/refman/scattermore.html Colorizes a given histogram using an input palette. ```APIDOC ## histogram_to_rgbwt ### Description Colorize given histogram with input palette. ### Parameters #### Arguments - **fhistogram** (matrix/2D array) - Required - Histogram of values. - **RGBA** (4-by-N matrix) - Optional - Floating-point R, G, B and A channels for the palette. - **col** (colors) - Optional - Colors to use for coloring. - **zlim** (vector) - Optional - Values to use as extreme values of the histogram. ### Response - **RGBWT matrix** (matrix) - The colorized RGBWT matrix. ``` -------------------------------- ### Expanding line data Source: https://cran.r-project.org/web/packages/scattermore/vignettes/low_level_interface.html Applies a circular kernel to thicken lines in an RGBWT plot. ```R rgbwt <- scatter_lines_rgbwt(cbind(pts, pts2)[1:30,], out_size=c(512,512), xlim=c(-3,7), ylim=c(-5,2), RGBA=as.vector(col2rgb('#8010f010', alpha=T))) rgbwt <- apply_kernel_rgbwt(rgbwt, 'circle', radius=5) rstr <- rgba_int_to_raster(rgbwt_to_rgba_int(rgbwt)) par(mar=c(0,0,0,0), bg='white') plot(rstr) ``` -------------------------------- ### GeomScattermore Source: https://cran.r-project.org/web/packages/scattermore/refman/scattermore.html The actual geom for scattermore, used for integrating rasterized scatterplots into ggplot2 visualizations. ```APIDOC ## GeomScattermore ### Description The actual geom for scattermore ### Usage ``` GeomScattermore ``` ### Format An object of class `GeomScattermore` (inherits from `Geom`, `ggproto`, `gg`) of length 6. ``` -------------------------------- ### geom_scattermost Source: https://cran.r-project.org/web/packages/scattermore/refman/scattermore.html A high-performance, non-ggplotish version of geom_scattermore that bypasses standard ggplot processing for faster rendering. ```APIDOC ## geom_scattermost ### Description Totally non-ggplotish version of geom_scattermore(), but faster. It avoids most of the ggplot processing by bypassing the largest portion of data around any ggplot functionality, leaving only enough data to set up axes and limits correctly. ### Parameters #### Arguments - **xy** (2-column object) - Required - Data coordinates. - **color** (vector/single color) - Optional - Color vector or single color. - **interpolate** (boolean) - Optional - Passed to grid::rasterGrob(). - **pointsize** (numeric) - Optional - Radius of rasterized point. Use 0 for single pixels. - **pixels** (vector) - Optional - X and Y resolution of the raster, default c(512,512). ``` -------------------------------- ### Render Large Scatterplot with geom_scattermost Source: https://cran.r-project.org/web/packages/scattermore/refman/scattermore.html Utilize geom_scattermost for maximum speed when ggplot2 overhead is not needed. This function bypasses much of the ggplot processing. Requires 'ggplot2' and 'scattermore' libraries. Ensure data is provided as a 2-column object. ```r library(ggplot2) library(scattermore) d <- data.frame(x = rnorm(1000000), y = rnorm(1000000)) x_rng <- range(d$x) ggplot() + geom_scattermost(cbind(d$x, d$y), color = heat.colors(100, alpha = .01) [1 + 99 * (d$x - x_rng[1]) / diff(x_rng)], pointsize = 2.5, pixels = c(1000, 1000), interpolate = TRUE ) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.