在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):texworld/tikzplotlib开源软件地址(OpenSource Url):https://github.com/texworld/tikzplotlib开源编程语言(OpenSource Language):Python 66.7%开源软件介绍(OpenSource Introduction):The artist formerly known as matplotlib2tikz. This is tikzplotlib, a Python tool for converting matplotlib figures into PGFPlots (PGF/TikZ) figures like for native inclusion into LaTeX or ConTeXt documents. The output of tikzplotlib is in PGFPlots, a TeX library that sits on top of PGF/TikZ and describes graphs in terms of axes, data etc. Consequently, the output of tikzplotlib
than raw TikZ output. For example, the matplotlib figure import matplotlib.pyplot as plt
import numpy as np
plt.style.use("ggplot")
t = np.arange(0.0, 2.0, 0.1)
s = np.sin(2 * np.pi * t)
s2 = np.cos(2 * np.pi * t)
plt.plot(t, s, "o-", lw=4.1)
plt.plot(t, s2, "o-", lw=4.1)
plt.xlabel("time (s)")
plt.ylabel("Voltage (mV)")
plt.title("Simple plot $\\frac{\\alpha}{2}$")
plt.grid(True)
import tikzplotlib
tikzplotlib.save("test.tex") import matplotlib as mpl
plt.close()
mpl.rcParams.update(mpl.rcParamsDefault) --> (see above) gives \begin{tikzpicture}
\definecolor{color0}{rgb}{0.886274509803922,0.290196078431373,0.2}
\definecolor{color1}{rgb}{0.203921568627451,0.541176470588235,0.741176470588235}
\begin{axis}[
axis background/.style={fill=white!89.8039215686275!black},
axis line style={white},
tick align=outside,
tick pos=left,
title={Simple plot \(\displaystyle \frac{\alpha}{2}\)},
x grid style={white},
xlabel={time (s)},
xmajorgrids,
xmin=-0.095, xmax=1.995,
xtick style={color=white!33.3333333333333!black},
y grid style={white},
ylabel={Voltage (mV)},
ymajorgrids,
ymin=-1.1, ymax=1.1,
ytick style={color=white!33.3333333333333!black}
]
\addplot [line width=1.64pt, color0, mark=*, mark size=3, mark options={solid}]
table {%
0 0
0.1 0.587785252292473
% [...]
1.9 -0.587785252292473
};
\addplot [line width=1.64pt, color1, mark=*, mark size=3, mark options={solid}]
table {%
0 1
0.1 0.809016994374947
% [...]
1.9 0.809016994374947
};
\end{axis}
\end{tikzpicture} (Use Tweaking the plot is straightforward and can be done as part of your TeX work flow. The fantastic PGFPlots manual contains great examples of how to make your plot look even better. Of course, not all figures produced by matplotlib can be converted without error. Notably, 3D plots don't work. Installationtikzplotlib is available from the Python Package Index, so simply do
to install. Usage
ContributingIf you experience bugs, would like to contribute, have nice examples of what tikzplotlib can do, or if you are just looking for more information, then please visit tikzplotlib's GitHub page. Testingtikzplotlib has automatic unit testing to make sure that the software doesn't
accidentally get worse over time. In To run the tests, just check out this repository and type
Licensetikzplotlib is published under the MIT license. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论