Я рисовал как обычно, но после сохранения одного из моих графиков в формате PGF и последующей компиляции LaTeX он больше не работал. Насколько мне известно, я ничего не менял, так получилось, что он перестал работать.
Код, который я использую для создания примера графика, следующий:< /p>
Конечно, я могу их закомментировать, но тогда (что более очевидно для других графиков) оси будут набраны странным шрифтом, и если у меня будет другой, скажем, логарифмический масштаб, это не будет выглядеть так: 10^{-21}, как в латексе, и шрифт тоже другой.
Я получаю следующие коды ошибок в латексе:
! Undefined control sequence.
\mathdefault
l.109 ...\catcode`\%=\active\def%{\%}$\mathdefault
{\ensuremath{-}4}$}}%
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
! Undefined control sequence.
\mathdefault
l.147 ...\catcode`\%=\active\def%{\%}$\mathdefault
{\ensuremath{-}2}$}}%
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
! Undefined control sequence.
\mathdefault
l.185 ...\catcode`\%=\active\def%{\%}$\mathdefault
{0}$}}%
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
! Undefined control sequence.
\mathdefault
l.223 ...\catcode`\%=\active\def%{\%}$\mathdefault
{2}$}}%
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
...
Я рисовал как обычно, но после сохранения одного из моих графиков в формате PGF и последующей компиляции LaTeX он больше не работал. Насколько мне известно, я ничего не менял, так получилось, что он перестал работать. Код, который я использую для создания примера графика, следующий:< /p> [code]import matplotlib . pyplot as plt import numpy as np from pathlib import Path import matplotlib .cm as cm import tikzplotlib import matplotlib as mpl mpl.rcParams['mathtext.fontset'] = 'cm' # Latex font mpl.rcParams['font.family'] = 'serif' mpl.rcParams['font.serif'] = ['cmr10'] mpl.rcParams['axes.formatter.use_mathtext'] = True
# Erzeuge eine Liste von x-Werten x = np.linspace(-5, 10, 100) a= [2,8,8,2] b=[2,2,8,2]
U_1=2 U_2=8 I_1=2 I_2=8
# Berechne die entsprechenden y-Werte für die Funktion y = x y = x
# Plotte die Funktion plt.plot(x, y) plt.plot(a,b, color = 'crimson', marker='', linestyle='dashed') plt.plot(U_1,I_1, color = 'green', marker='x', linestyle='',label='$(U_{1}, I_{1})$', markersize=14) plt.plot(U_2,I_2, color = 'orange', marker='x', linestyle='',label='$(U_{1}, I_{2})$', markersize=14) plt.plot(U_2,I_1, color = 'purple', marker='x', linestyle='',label='$(U_{2}, I_{2})$', markersize=14)
# Beschriftungen für die Achsen hinzufügen plt.xlabel('$I$ / arbitrary units') plt.ylabel('$U$ / arbitrary units')
# Titel für den Plot hinzufügen plt.title('Beispiel Fit') plt.legend(loc='upper left')
# Grid hinzufügen plt.grid(True)
# Den Plot anzeigen plt.savefig('example.pgf', format='pgf', bbox_inches='tight', pad_inches = 0) plt.show() [/code] Я попробовал несколько вещей и почти уверен, что проблема в командах [code]mpl.rcParams['font.serif'] = ['cmr10'] mpl.rcParams['axes.formatter.use_mathtext'] = True [/code] Конечно, я могу их закомментировать, но тогда (что более очевидно для других графиков) оси будут набраны странным шрифтом, и если у меня будет другой, скажем, логарифмический масштаб, это не будет выглядеть так: 10^{-21}, как в латексе, и шрифт тоже другой. Я получаю следующие коды ошибок в латексе: [code]! Undefined control sequence. \mathdefault l.109 ...\catcode`\%=\active\def%{\%}$\mathdefault {\ensuremath{-}4}$}}% The control sequence at the end of the top line of your error message was never \def'ed. If you have misspelled it (e.g., `\hobx'), type `I' and the correct spelling (e.g., `I\hbox'). Otherwise just continue, and I'll forget about whatever was undefined. ! Undefined control sequence. \mathdefault l.147 ...\catcode`\%=\active\def%{\%}$\mathdefault {\ensuremath{-}2}$}}% The control sequence at the end of the top line of your error message was never \def'ed. If you have misspelled it (e.g., `\hobx'), type `I' and the correct spelling (e.g., `I\hbox'). Otherwise just continue, and I'll forget about whatever was undefined. ! Undefined control sequence. \mathdefault l.185 ...\catcode`\%=\active\def%{\%}$\mathdefault {0}$}}% The control sequence at the end of the top line of your error message was never \def'ed. If you have misspelled it (e.g., `\hobx'), type `I' and the correct spelling (e.g., `I\hbox'). Otherwise just continue, and I'll forget about whatever was undefined. ! Undefined control sequence. \mathdefault l.223 ...\catcode`\%=\active\def%{\%}$\mathdefault {2}$}}% The control sequence at the end of the top line of your error message was never \def'ed. If you have misspelled it (e.g., `\hobx'), type `I' and the correct spelling (e.g., `I\hbox'). Otherwise just continue, and I'll forget about whatever was undefined. ... [/code] Я также разместил это на https://tex.stackexchange.com/q/718364/36296 в надежде найти решение
Я пытаюсь добавить supylabel к двум подграфикам в matplotlib и экспортировать результат как .pgf. Однако supylabel явно не центрирован.
Это код Python:
fig, axes = pyplot.subplots(
2,
1,
figsize=(3, 3),
squeeze=True,
sharex=True,
sharey=True,...
Смотрите консольный вывод фрагмента кода ниже. В этом примере я использую множитель 0,5, потому что он упрощает умножение и показывает, что можно как вдвое уменьшить размер шрифта, так и увеличить его вдвое.
Я использую matplotlib для создания диаграмм с текстом, отображаемым с помощью латекса. Теперь есть эта сложная проблема, которую я, похоже, не могу решить самостоятельно.
Вторичная ось Y, сгенерированная с помощью Twinx(), показывает неправильный...