本文介绍了在轴上显示正确的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个 Data.Frame (mydf):

年总数1999 39672002 5802005 52032008 2406

为了显示它,我只需运行:

plot(mydf)

但是我可以在 x 轴(year)上看到标签:

2000 2002 2004 2006 2008

如何告诉 plot/axis 只显示四个预期值:1999,2002,2005,2008 而不尝试推断序列?

解决方案

正如

I have this Data.Frame (mydf):

year   total
1999   3967
2002   580
2005   5203
2008   2406

and to display it, I just run:

plot(mydf)

However I can see on the x-axis (year) the labels:

2000 2002 2004 2006 2008

How can I tell to plot/axis to display only the four expected values: 1999,2002,2005,2008 without trying to infer the sequence?

解决方案

As akrun suggest, you can use:

plot(mydf, xaxt = "n")
axis(1, at = mydf$year)

Data:

mydf <- structure(list(year = c(1999L, 2002L, 2005L, 2008L), total = c(3967L, 
580L, 5203L, 2406L)), .Names = c("year", "total"), class = "data.frame",
row.names = c(NA, -4L))

这篇关于在轴上显示正确的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 17:52