Using R to plot a stacked bargraph with data in GridDB, but the legend not showing up [关闭]

问题描述 投票:0回答:0

我正在使用内存数据库 GridDB 来快速搜索大量数据。 从 GridDB 读取数据后,我将其存储在“tibble”中(不是完整的数据框,tibble 是一种简单的数据结构,可以轻松地提供给 POST Web API)。
当我绘制堆叠条形图时,条形可见但图例不可见。 我使用了许多变体,但图例仍然不可见,即使在为 barplot() 函数明确指定 args.legend 参数之后也是如此。 附上条形图图像。 以下是我的代码中的相关片段。

.....
    `# Use GridDb's web API to return relevant data 
     qr1 <- GET (url = my_query_url, 
       add_headers("Content-Type" = "application/json; charset=UTF-8" ) ,      
       config = authenticate("my_user_name", "mypass"), 
       body = query_request_body
       ) 
    #Copy data returned into an R tibble  
    my_global_health__data <- qr1  
    # Plot the bars 
    barplot( matrix(c(my_global_health__data$Percent, my_global_health__data$otherCol), nrow=2, ncol=20, byrow=TRUE), main="Cause of death, by communicable diseases and maternal,     prenatal and nutrition conditions", names.arg = my_global_health_data$CountryCode  , xlab="CountryName",     ylab="Percent of Total", col=c("blue","red"),  args.legend="bottomright" )  

    print("EOP, R and GridDB") 
    #`
.................... 

你能告诉我一些关于我做错了什么的想法吗,或者只是发布一个适用于你并显示图例的 barplot() 函数。 谢谢 实践 enter image description here

用了R语言的barplot函数,图例不可见。 参数 args.legend 似乎对我不起作用。 barplot(H, xlab, ylab, main, names.arg, col, args.legend)

r database in-memory griddb
© www.soinside.com 2019 - 2024. All rights reserved.