R - 在x轴上绘制多列为年,将行绘制为不同的线 [英] R - Plot multiple columns as years on x-axis, plot rows as different lines

查看:166
本文介绍了R - 在x轴上绘制多列为年,将行绘制为不同的线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我的数据框:

  2010 2011 2012 2013 2014 2015 
A 0 100 164 75 154 110
B 71 77 136 58 138 136
C 0 0 132 53 83 0

我想制作一个线图,其中沿x轴绘制年份并且沿y轴绘制计数,并且行A,B和C各自都有自己的线。是否有可能在不将多年融入单一变量的情况下做到这一点?

解决方案

有一个函数, matplot 。尝试

  matplot(yourData,type =l)


Here's my data frame:

            2010    2011   2012   2013   2014   2015
 A             0     100    164     75    154    110
 B            71      77    136     58    138    136
 C             0       0    132     53     83      0

I'd like to make a line graph in which the years are plotted along the x-axis and and counts are plotted along the y-axis, with rows A, B, and C each having their own line. Is it possible to do this without melting the years into a single variable?

解决方案

There is a function for this, matplot. Try

matplot(yourData, type="l")

这篇关于R - 在x轴上绘制多列为年,将行绘制为不同的线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆