r-lib / ragg

Graphic Devices Based on AGG
https://ragg.r-lib.org
Other
172 stars 24 forks source link

odd bug with treemap package output #130

Closed dylanbeaudette closed 6 months ago

dylanbeaudette commented 1 year ago

Just noticed an odd error that only manifests when writing directly to a file with the ragg PNG device. Interactive use in RStudio works as expected.

Example.

z <- structure(list(series = c("AABAB", "AABERG", "AAGARD", "AARON", 
"AARUP", "AASTAD", "AAZDAHL", "ABAC", "ABAFT", "ABAJO"), taxorder = c("inceptisols", 
"vertisols", "mollisols", "alfisols", "mollisols", "mollisols", 
"mollisols", "inceptisols", "entisols", "mollisols"), taxsuborder = c("udepts", 
"usterts", "cryolls", "udalfs", "xerolls", "udolls", "udolls", 
"ustepts", "psamments", "ustolls"), taxgrtgroup = c("dystrudepts", 
"haplusterts", "argicryolls", "hapludalfs", "durixerolls", "argiudolls", 
"hapludolls", "haplustepts", "xeropsamments", "paleustolls"), 
    taxsubgrp = c("aquandic dystrudepts", "leptic udic haplusterts", 
    "calcic pachic argicryolls", "oxyaquic hapludalfs", "vitritorrandic durixerolls", 
    "pachic argiudolls", "aquic hapludolls", "typic haplustepts", 
    "typic xeropsamments", "udic paleustolls"), ac = c(7539L, 
    12196L, 28518L, 56767L, 12298L, 433230L, 212649L, 51826L, 
    7703L, 9293L), n_polygons = c(494L, 292L, 639L, 8356L, 1042L, 
    51245L, 25480L, 854L, 154L, 101L), log_ac = c(3.87731374331224, 
    4.08621741569334, 4.4551190646784, 4.75409594340857, 4.08983448870863, 
    5.63671852270707, 5.32766334474812, 4.714547690704, 3.8866598978612, 
    3.96815593714997)), row.names = c(NA, 10L), class = "data.frame")

agg_png(file='test.png', width=2000, height=1500, res=100, scaling = 2)

treemap(z, index=c('taxorder', 'taxsuborder'), vSize='log_ac', fontsize.labels=c(0, 10), type='index', title='Suborders -- Rectangle Area Proportional to Log10(acres mapped)')

dev.off()

Error

Error in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : 
polygon edge not found
dylanbeaudette commented 6 months ago

Thanks!