首页 > 解决方案 > 使用给定两个向量的条件在 R 图上绘制曲线

问题描述

给定以下空图:

plot(1, type="n", xlab="x1", ylab="x2", xlim=c(0, 10), ylim=c(0, 10), axes = F)
axis(1, seq(0,10,1), pos = 0)
axis(2, seq(0,10,1), pos = 0)
lines(x = c(0,10), y = c(10,10))
lines(x = c(10,10), y = c(0,10))

我想绘制一条平滑曲线,其中 x1*x2 = 38,假设 x1 和 x2 都在 0 和 10 之间。

我可以使用什么样的功能来实现这一点?

标签: rplot

解决方案


你可以试试

plot(1, type="n", xlab="x1", ylab="x2", xlim=c(0, 10), ylim=c(0, 10), axes = F)
axis(1, seq(0,10,1), pos = 0)
axis(2, seq(0,10,1), pos = 0)
lines(x = c(0,10), y = c(10,10))
lines(x = c(10,10), y = c(0,10))
t <- seq(from = 3.8, to = 10, by = .1)
lines(x = t, y = 38/t)

在此处输入图像描述


推荐阅读