Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error message when a list containing empty vectors is passed to legend.grob() #167

Open
tyamaguchi-ucla opened this issue Oct 27, 2023 · 0 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@tyamaguchi-ucla
Copy link
Contributor

when print(legend.empty) is

$levels
character(0)

$colours
character(0)

due to a user error,

legend.test<- list(
    legend = list(
        colours = legend.empty$colours,
        labels = legend.empty$levels,
        title = expression(bold(underline('Test'))),
        lwd = 0.5
        ),
     legend = list(...   
        );

bitmap.type = getOption('bitmapType')
if (capabilities('cairo')) {
    bitmap.type <- 'cairo';
    }

# create a legend grob using defaults
legend.grob1 <- legend.grob(
    legends = legend.test
    );

tiff(
    filename = "test.png",
    type = bitmap.type,
    width = 2,
    height = 10,
    units = 'in',
    res = 800,
    compression = 'lzw'
    );
grid.draw(legend.grob1);

will fail. The getCharCE error message is not helpful to identify the issue. Maybe consider making the warning an error here?

Warning messages:
1: In FUN(X[[i]], ...) : 'x' is NULL so the result will be NULL
2: In FUN(X[[i]], ...) : 'x' is NULL so the result will be NULL
3: In FUN(X[[i]], ...) : 'x' is NULL so the result will be NULL
4: In FUN(X[[i]], ...) : 'x' is NULL so the result will be NULL
5: In FUN(X[[i]], ...) : 'x' is NULL so the result will be NULL
6: In FUN(X[[i]], ...) : 'x' is NULL so the result will be NULL
7: In FUN(X[[i]], ...) : 'x' is NULL so the result will be NULL
8: In FUN(X[[i]], ...) : 'x' is NULL so the result will be NULL
Error in grid.Call.graphics(C_setviewport, vp, TRUE) :
  'getCharCE' must be called on a CHARSXP
Calls: grid.draw ... lapply -> FUN -> push.vp.viewport -> grid.Call.graphics
Execution halted
@tyamaguchi-ucla tyamaguchi-ucla added documentation Improvements or additions to documentation enhancement New feature or request labels Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant