gdtools: Utilities for Graphical Rendering
- CRAN: http://cran.r-project.org/web/packages/gdtools/index.html
- GitHub: https://github.com/davidgohel/gdtools
> library(gdtools)
バージョン: 0.0.7
関数名 | 概略 |
---|---|
font_family_exists |
Check if font family exists. |
raster_str |
Draw/preview a raster into a string |
raster_write |
Draw/preview a raster to a png file |
str_extents |
Compute string extents. |
str_metrics |
Get font metrics for a string. |
font_family_exists
フォントファミリーがコンピュータ内に存在するかを確認
> font_family_exists(font_family = "sans")
[1] FALSE
> font_family_exists("Arial")
[1] TRUE
> font_family_exists("Courier")
[1] TRUE
raster_str / raster_view
ラスターの生成と描画
> code <- as.raster(matrix(hcl(0, 80, seq(50, 80, 10)), nrow = 4, ncol = 5)) %>%
+ raster_str(width = 50, height = 50)
> raster_view(code = code)
raster_write
ラスターの保存
> as.raster(matrix(hcl(0, 80, seq(50, 80, 10)), nrow = 4, ncol = 5)) %>%
+ raster_write(path = "raster.png", width = 50, height = 50)
str_extents
> str_extents(letters)
[,1] [,2]
[1,] 6.673828 6.638672
[2,] 6.673828 8.835938
[3,] 6.000000 6.638672
[4,] 6.673828 8.859375
[5,] 6.673828 6.650391
[6,] 3.333984 8.730469
[7,] 6.673828 9.082031
[8,] 6.673828 8.636719
[9,] 2.666016 8.607422
[10,] 2.666016 11.138672
[11,] 6.000000 8.607422
[12,] 2.666016 8.607422
[13,] 9.996094 6.416016
[14,] 6.673828 6.427734
[15,] 6.673828 6.685547
[16,] 6.673828 8.929688
[17,] 6.673828 8.917969
[18,] 3.996094 6.416016
[19,] 6.000000 6.679688
[20,] 3.333984 8.126953
[21,] 6.673828 6.597656
[22,] 6.000000 6.275391
[23,] 8.666016 6.275391
[24,] 6.000000 6.275391
[25,] 6.000000 9.000000
[26,] 6.000000 6.427734
> str_extents("Hello World!", bold = TRUE, italic = FALSE, fontname = "Arial", fontsize = 12)
[,1] [,2]
[1,] 70.6582 8.730469
> str_extents("Hello World!", bold = TRUE, italic = FALSE, fontname = "Courier", fontsize = 12)
[,1] [,2]
[1,] 86.41406 7.816406
str_metrics
> str_metrics("Hello World!")
width ascent descent
65.3496094 8.6367188 0.2285156