小编Mot*_*oti的帖子

在mplot3d中绘制右手坐标系

我想从 Python 创建 3D 坐标变换图。例如,我想创建以下图像(由 TikZ 静态生成):

在此输入图像描述

经过一番搜索,我找到了以下程序:

import numpy as np
from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.patches import FancyArrowPatch
from mpl_toolkits.mplot3d import proj3d


class Arrow3D(FancyArrowPatch):
    def __init__(self, xs, ys, zs, *args, **kwargs):
        FancyArrowPatch.__init__(self, (0, 0), (0, 0), *args, **kwargs)
        self._verts3d = xs, ys, zs

    def draw(self, renderer):
        xs3d, ys3d, zs3d = self._verts3d
        xs, ys, zs = proj3d.proj_transform(xs3d, ys3d, zs3d, renderer.M)
        self.set_positions((xs[0], ys[0]), (xs[1], ys[1]))
        FancyArrowPatch.draw(self, renderer)


fig = plt.figure()
ax = fig.add_subplot(111, projection='3d') …
Run Code Online (Sandbox Code Playgroud)

matplotlib coordinate-systems mplot3d

6
推荐指数
1
解决办法
5003
查看次数

标签 统计

coordinate-systems ×1

matplotlib ×1

mplot3d ×1