简体   繁体   English

使用 matplotlib 绘制具有指定长度的线

[英]Plotting a line with a specified length using matplotlib

I'm trying to plot polarization vectors or lines using astropy and matplotlib.我正在尝试使用 astropy 和 matplotlib 的 plot 偏振矢量或线。 I had some success using an axline, but there doesnt seem to be any way to adjust the length.我使用 axline 取得了一些成功,但似乎没有任何方法可以调整长度。 The given data is the polarization (length), the angle, and the x/y coordinates for the center of the line.给定的数据是线中心的极化(长度)、角度和 x/y 坐标。

here's an example that I hard coded to test:这是一个我硬编码测试的例子:

x1 = 306 x1 = 306

y1 = 38.53802778 y1 = 38.53802778

angle = 32.2-90角度 = 32.2-90

sl = np.tan(np.radians(angle)) sl = np.tan(np.radians(角度))

plt.axline((x1, y1), transform=ax.get_transform('icrs'), slope=sl, color='red', label='1', pickradius=1) plt.show() plt.axline((x1, y1), transform=ax.get_transform('icrs'), slope=sl, color='red', label='1', pickradius=1) plt.show()

it ends up in the correct spot, but its an infinite line.它最终出现在正确的位置,但它是一条无限的线。 I need to be able to specify the length somehow.我需要能够以某种方式指定长度。

So first off, strain super hard.所以首先,用力过大。

Finally, Phone -> dykes room.最后,电话-> 堤坝房间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM