R中具有多列的条形图

编程入门 行业动态 更新时间:2024-10-27 06:21:40
本文介绍了R中具有多列的条形图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

R的新手,并试图找出该条形图。 我试图在R中创建一个条形图,以显示来自按第三列分组的2列的数据。

New to R and trying to figure out the barplot. I am trying to create a barplot in R that displays data from 2 columns that are grouped by a third column.

DataFrame名称: SprintTotalHours

DataFrame Name: SprintTotalHours

包含数据的列:

OriginalEstimate,TimeSpent,Sprint 178,471.5,16.6.1 210,226,16.6.2 240,195,16.6.3

我想要一个在 TimeSpent 每个冲刺。 我尝试了这个,但没有得到想要的东西:

I want a barplot that shows the OriginalEstimate next to the TimeSpent for each sprint. I tried this but I am not getting what I want:

colours = c("red","blue") barplot(as.matrix(SprintTotalHours),main='Hours By Sprint',ylab='Hours', xlab='Sprint' ,beside = TRUE, col=colours) abline(h=200)

我想使用基本图形,但是如果无法完成,我不反对在必要时安装软件包。

I would like to use base graphics but if it can't be done then I am not opposed to installing a package if necessary.

推荐答案

cols <- c('red','blue'); ylim <- c(0,max(SprintTotalHours[c('OriginalEstimate','TimeSpent')])*1.8); par(lwd=6); barplot( t(SprintTotalHours[c('OriginalEstimate','TimeSpent')]), beside=T, ylim=ylim, border=cols, col='white', names.arg=SprintTotalHours$Sprint, xlab='Sprint', ylab='Hours', legend.text=c('Estimated','TimeSpent'), args.legend=list(text.col=cols,col=cols,border=cols,bty='n') ); box();

数据

SprintTotalHours <- data.frame(OriginalEstimate=c(178L,210L,240L),TimeSpent=c(471.5,226, 195),Sprint=c('16.6.1','16.6.2','16.6.3'),stringsAsFactors=F);

更多推荐

R中具有多列的条形图

本文发布于:2023-07-18 04:30:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1141041.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:有多   条形图

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!