简体   繁体   English

具有标准化x轴值的多列的箱形图

[英]box-plot for multiple columns with normalized x-axis values

I have the following data (in csv file) 我有以下数据(在csv文件中)

 product release_after_issue  release_before_issue
 P1                           40
 P1      100    
 P1                           10
 P2      50
 P2      300
 P2                           200
 P3      10
 P3      20
 P3      300    

I would like use the box-plot to show the distribution of days for each product release (P1, P2, etc.) based on release_after_issue and release_before_issue . 我想使用箱形图显示基于release_after_issuerelease_before_issue每个产品版本(P1,P2等)的天数分布。 The x-axis is the products names and y-axis is days. x轴为产品名称,y轴为天。

The issues that I am facing now are:the empty values in each column, and the big number for the days. 我现在面临的问题是:每列中的空值,以及几天中的大数字。

How could I normalize the days in y-axis to be in month (easy to read)? 如何将y轴上的天标准化为月(易于阅读)? And I wold like to have each product (Ps) has its own box plot based on the column's data ( release_after_issue or release_before_issue ) 而且我希望每个产品(Ps)都有基于列数据( release_after_issuerelease_before_issue )的自己的箱形图。

I tried to omit NA values and plot test example, but it did not work 我试图省略NA值并绘制测试示例,但是没有用

data <- read.csv("commons-fileupload.csv")
    ggplot(data[!is.na(data$release_after_issue),],aes(x=product,y=release_after_issue))
    + geom_point()

Any help ! 任何帮助!

Not sure what fails in your code, the dummy data below works fine for me. 不知道您的代码中有什么失败,下面的虚拟数据对我来说很好。 Also, ggplot removes the NAs for you. 另外,ggplot会为您删除NA。

data <- data.frame(product=c("P1","P2","P1","P1","P2"),release_after_issue=c(100,NA,50,10,30))
ggplot(data,aes(x=product,y=release_after_issue))+ geom_boxplot()

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM