Open liboyue opened 4 years ago
I don't quite understand either of your points. What does filecontents
do? And what's hard to manage?
Also, I'm not sure why one would only want to keep a subset of options. You can style mpl to get all blue curves, too, right?
Hi, this is a great library that can save me tones of time! I wish I had discovered it earlier. I use pgfplots heavily, but inputing data is a nightmare when plotting a lot of curves.
tikzplotlib
easily solves this problem. But there are several easy improvements that could be included..tex
file. Imagine I have four 1 x 4 figures , each subfigure has 6 curves. Thats 4 x 4 x 6 = 96.tsv
files in total, which is hard to manage. It may be better to usefilecontents
like\begin{filecontents}{test1-001.tsv} ... \end{filecontents}
% main.tex ... \input{test1-data.tex} ...
test.py
import matplotlib.pyplot as plt import numpy as np import tikzplotlib
x = np.linspace(0, 2 * np.pi, 400) y = np.sin(x ** 2) fig, axs = plt.subplots(2, 2) axs[0, 0].plot(x, y) axs[0, 0].set_title('Axis [0,0]') axs[0, 1].plot(x, y, 'tab:orange') axs[0, 1].set_title('Axis [0,1]') axs[1, 0].plot(x, -y, 'tab:green') axs[1, 0].set_title('Axis [1,0]') axs[1, 1].plot(x, -y, 'tab:red') axs[1, 1].set_title('Axis [1,1]')
for ax in axs.flat: ax.set(xlabel='x-label', ylabel='y-label')
Hide x labels and tick labels for top plots and y ticks for right plots.
for ax in axs.flat: ax.label_outer()
def patch():
tikzplotlib.save("test1.tex", standalone=True, externalize_tables=True)
patch() tikzplotlib.save("test2.tex", standalone=True, externalize_tables=True)