如何在 R 中绘制更平滑的曲线 [英] How to plot smoother curves in R

查看:89
本文介绍了如何在 R 中绘制更平滑的曲线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 R ,我绘制了一个阴影图.如果您看到曲线,则它们并不平滑.如何使它们光滑?甚至 excel 绘制出更平滑的曲线.设备特性:windows 7,屏幕分辨率=1366 x 768 (max)

Using R , I have drawn a hatched plot. If you see the curves, they are not smooth. How to make them smooth ? Even excel plots far more smoother curves. Device features: windows 7, screen resolution=1366 x 768 (max)

这是剧情.

以下代码用于绘制绘图.

Following code is used to draw the plot.

plot(NA,xlim=c(0,1),ylim=c(0,1),xlab="delta",ylab="K", xaxs="i",yaxs="i") # Empty plot
a1 <- curve((x+x^7-x^2-x^4)/(1+x-x^3-x^4), from=0, n=450000, add = TRUE) # First curve

完整代码在这里

推荐答案

我相当肯定,如果您将图形绘制为 pdf 格式,曲线将完全平滑.Rgui 的内部显示器显示曲线不平滑,使用复制粘贴可能会导致问题.最好直接绘图到文件中,像这样:

I'm fairly certain that if you plot your figure for example as pdf, the curves are completely smooth. It's the Rgui's internal display which shows the curve as non-smooth, and using copy paste on that might cause problems. It's better to directly plot into the file, like this:

# Open device:
pdf("D:/test.pdf") #change for appropriate file path
plot(NA,xlim=c(0,1),ylim=c(0,1),xlab="delta",ylab="K", xaxs="i",yaxs="i")
a1 <- curve((x+x^7-x^2-x^4)/(1+x-x^3-x^4), from=0, n=450000, add = TRUE)
dev.off() #close device

现在看看pdf,它看起来完全没问题.例如,如果您想要 jpg 图像,请使用函数 jpeg 等,有关如何保存为 tiff、jpeg、png 或 bmp 以及图像大小参数的更多详细信息,请参阅 ?jpeg、分辨率等.

Now look at the pdf, and it looks completely fine. If you want for example jpg image, use function jpeg etc, see ?jpeg for more details how to save as tiff, jpeg, png or bmp, and arguments for image size, resolution and such.

(注意,这里使用的术语设备等可能不完全正确,我对这个术语并不完全熟悉,如果合适的话,更聪明的人可以编辑).

(note, the terms device etc used here might not be totally correct, I'm not completely familiar with this terminology, someone more clever can edit if appropriate).

这篇关于如何在 R 中绘制更平滑的曲线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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