在摩尔维德投影上叠加直线

Overlaying straight lines over a Mollweide Projection

我正在尝试在 Mollweide 投影上覆盖连接点的直线,而不是曲线。

我目前得到的(顶部)和想要的情节(底部):

这是创建顶部图像的代码:

import matplotlib.pyplot as plt

colorcycle = ["Red", "Black", "Blue", "DarkMagenta", "Magenta", "MidnightBlue", "Orange", "Green", "Pink"]
ra_data = [-2.831704208910444, -0.048424160096582486, -0.4534557382898992, -2.5592914739299166, -1.1679202302277936, -1.0466163565556836, -0.5471537391832145, 2.4131794902699597, 2.945867940612645]
de_data = [-1.5056972910247601, 0.4995935170663689, -0.2603176032642063, -0.523242728430892, -0.8540960680851971, 0.7025543651222854, 0.6495085731664219, 0.004916592502868027, 0.36081889758179575]

fig = plt.figure(figsize=(8, 6), dpi=100)
ax = fig.add_subplot(111, projection="mollweide")
ax.scatter(ra_data, de_data, marker='o', alpha=0.7, color=colorcycle)
ax.plot(ra_data, de_data, color='Blue', alpha=0.5)
ax.grid(True)

plt.show()

您想从数据坐标转换为轴坐标(比如 xy)并绘制线条,明确告诉 Matplotlib 使用与您的 [=13= 关联的坐标系统] — 所有这些都在 Transformations Tutorial.

中得到了很好的解释
import matplotlib.pyplot as plt

colorcycle = ["Red", "Black", "Blue", "DarkMagenta", "Magenta", "MidnightBlue", "Orange", "Green", "Pink"]
ra_data = [-2.831704208910444, -0.048424160096582486, -0.4534557382898992, -2.5592914739299166, -1.1679202302277936, -1.0466163565556836, -0.5471537391832145, 2.4    131794902699597, 2.945867940612645]
de_data = [-1.5056972910247601, 0.4995935170663689, -0.2603176032642063, -0.523242728430892, -0.8540960680851971, 0.7025543651222854, 0.6495085731664219, 0.004916    592502868027, 0.36081889758179575]

fig = plt.figure(figsize=(8, 6), dpi=100)
ax = fig.add_subplot(111, projection="mollweide")
ax.scatter(ra_data, de_data, marker='o', alpha=0.7, color=colorcycle)
ax.grid()
#################################################################
pos2ax = (ax.transData+ax.transAxes.inverted()).transform
x, y = zip(*[pos2ax((ra,de)) for ra, de in zip(ra_data,de_data)])
ax.plot(x, y, transform=ax.transAxes, color='Blue', alpha=0.5)
#################################################################