【问题标题】:(R) how to add own axis labels in plot(R) 如何在绘图中添加自己的轴标签
【发布时间】:2019-03-03 15:20:55
【问题描述】:

我有一个绘制时间序列与变量的图。但是,我想用另一个变量(对应的日期)替换图中的 x 轴值(时间序列值)。

变量已分别以日期和时间编码。我创建了另一个变量“day”来编码对应于日期的工作日。

然后我想绘制与时间序列的对比图,但在 x 轴上我希望显示“天”。

我无法针对工作日进行绘图,因为这会产生错误(变量不是数字)。

我该怎么做?我目前有这个:

 household$day <- weekdays(household$Date) #Where Date is 'Date' variable

 plot(as.numeric(household$Time), household$Global_active_power, type = "l", xaxt = 'n') # xaxt to remove the x-axis labels

 # Step 3: add the weekdays in household$day to the x-axis ...

提前致谢。

【问题讨论】:

  • 使用函数axis

标签: r date


【解决方案1】:

我的意思是使用 axis() 函数来替换 x 轴上的值。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-12
    • 2012-08-20
    • 2014-06-29
    • 2012-01-21
    相关资源
    最近更新 更多