首页 > 解决方案 > 使用 tikzplotlib 保存箭袋图

问题描述

我想使用 tikzplotlib 保存一个箭袋图。这是一个MWE:

import matplotlib.pyplot as plt
import numpy as np
x,y = np.meshgrid(np.arange(-2, 2, .2), np.arange(-2, 2, .25))
z = x*np.exp(-x**2 - y**2)
v, u = np.gradient(z, .2, .2)
fig, ax = plt.subplots()
q = ax.quiver(x,y,u,v)
import tikzplotlib

tikzplotlib.save("2delete.tex")

我收到这样的错误:

 File "/usr/local/lib/python3.6/dist-packages/tikzplotlib/_patch.py", line 69, in <genexpr>
    yield tuple(seq[i % len(seq)] for seq in seqs)
ZeroDivisionError: integer division or modulo by zero

有人知道这个问题和解决方法吗?谢谢!

标签: pythonmatplotlibtikz

解决方案


来自 GitHub存储库

Of course, not all figures produced by matplotlib can be converted without error

您可以加载保存的图像,而不是将绘图直接加载到 tex 中。


推荐阅读