Rstudio的Plots不显示图形

本文描述了在Rstudio中使用plot方法绘制折线图时遇到的问题,即图形未在Plots窗口显示,而是空白的情况。通过调整代码中png文件设置的位置,成功解决了这一问题,确保了折线图能够正确显示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

问题描述:使用plot方法画折线图,在Rstudio的Plots中没有显示出来,显示的空白

05249bbf960e6df7b915abd1840bbe88958.jpg

代码如下:

# Get the data points in form of a R vector.
rainfall <- c(799,1174.8,865.1,1334.6,635.4,918.5,685.5,998.6,784.2,985,882.8,1071)
# Convert it to a time series object.
rainfall.timeseries <- ts(rainfall,start = c(2018,1),frequency = 12)
# Print the timeseries data.
print(rainfall.timeseries)
# Give the chart file a name.
png(file = "rainfall.png")
# Plot a graph of the time series.
plot(rainfall.timeseries,type = "o")
# Save the file.
dev.off()

解决办法:将

# Give the chart file a name.
png(file = "rainfall.png")

放置到plot后

# Get the data points in form of a R vector.
rainfall <- c(799,1174.8,865.1,1334.6,635.4,918.5,685.5,998.6,784.2,985,882.8,1071)
# Convert it to a time series object.
rainfall.timeseries <- ts(rainfall,start = c(2018,1),frequency = 12)
# Print the timeseries data.
print(rainfall.timeseries)
# Plot a graph of the time series.
plot(rainfall.timeseries,type = "o")
# Give the chart file a name.
png(file = "rainfall.png")
# Save the file.
dev.off()

b25fba0d85ff83dc5e34d5049cf4f2caae8.jpg

转载于:https://my.oschina.net/u/3822522/blog/3034723

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值