如何在 Julia 中绘制形状

问题描述

我想绘制例如一个正方形(或者更一般地说是一个 n 边形)。
我知道我可以绘制形成形状的“函数”,如圆形:

n = 100
ϕ = range(0,stop=2*π,length=n)
x = cos.(ϕ)';
y = sin.(ϕ)';
plot(x,y)

enter image description here

但是当涉及到一个 n 边形时,结果证明这是非常困难的, 我想人们可以“缝合”可以形成 n 边形的线,但是当您想要绘制 32 边形时,这似乎非常不切实际。
我谈了很多关于 n-gons 的内容,但我更感兴趣的是 Julia 是否已经构建了一些方法来绘制不同类型的形状。

解决方法

您可以使用 <script type="text/javascript" src="https://ssl.gstatic.com/trends_nrtr/2578_RC01/embed_loader.js"></script> <script type="text/javascript"> trends.embed.renderExploreWidget("GEO_MAP",{"comparisonItem":[{"keyword":"covid","geo":"","time":"today 12-m"}],"category":0,"property":""},{"exploreQuery":"q=covid&date=today 12-m","guestPath":"https://trends.google.com:443/trends/embed/"}); </script> 库,它提供 Luxor 函数(来自 documentation 的示例)。

ngon

函数本身的文档可以在here找到。