如何使用gnuplot在对角线中绘制矩
我在gnuplot中绘制了一个矩形,但我希望它出现在对角线中
set object 1 rect from 53.1035,126.27 to 133.104,146.27
I have :
_____
| |
|_____|
I want :
_____
/ /
/____/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我所知,还没有(尚未)绘制旋转矩形的简单选择。
正如@Tomsolid已经指出的那样,在一般情况下,您可以“手动”绘制多边形。
因此,如果要旋转矩形,则必须将 a = atan(dy/dx),
但是请记住,矩形只会以矩形和相同的比例出现。如果X轴和Y轴具有相同的缩放因子。您可以通过
设置大小比例-1
(检查帮助> size
)来执行此功能。如果X和Y轴没有相同的缩放因素,则还可以保留旋转矩形的(视觉)比例,但这将需要更多的额外努力。
编辑:脚本更改为更通用的解决方案。旋转中心可以定义。
此外,旋转角坐标的功能(
x1r(n),y1r(n),...
)实际上不是n
的函数,而是这样的函数函数将在呼叫时采用x0,y0,x1,y1
的当前值。脚本:
结果:
As far as I know there is not (yet) a simple option to draw a rotated rectangle.
And as @TomSolid already pointed out that in the general case you can draw a polygon "by hand".
So, if you want to rotate your rectangle you have to apply the rotation matrix to your rectangle coordinates. In the example below the rotation angle is 45 degrees. If you want to rotate it by the angle of the diagonal, define the rotation angle as
a = atan(dy/dx)
However, keep in mind the rectangle will only appear as rectangle and in the same proportions if the x- and y-axes have the same scaling factors. You can enforce this by
set size ratio -1
(checkhelp size
).If x- and y-axes do not have the same scaling factors, you can also keep the (visual) proportions for your rotated rectangle, but it will require a bit more extra effort.
Edit: Script changed to a more general solution. Rotation center can be defined.
Furthermore, the functions for the rotated corner coordinates (
x1r(n), y1r(n), ...
) are actually not a function ofn
, but this way the functions will take the current values ofx0,y0,x1,y1
at the time of calling.Script:
Result:
您可以使用
You can use