Open Mpedrosab opened 4 years ago
If the figure is saved before as png, minor xtickslabels and minor ytickslabels are added, and pgfplots package does not recognize these parameters.
Simplified Python code:
import matplotlib.pyplot as plt
from tikzplotlib import save as tikz_save
x=[.00404784042977909,.140660747273482,.294901125967985,.603381883356992,.779656601864995,.9779656601865]
y=[.763156,.92578,0.979844,.9997,1,1]
plt.figure()
plt.scatter(x,y)
plt.xscale('log')
plt.yscale('log')
plt.grid()
plt.savefig("test.png")
tikz_save("test.tikz",encoding ='utf-8')
Obtained tikz code:
% This file was created by tikzplotlib v0.9.1.
\begin{tikzpicture}
\definecolor{color0}{rgb}{0.12156862745098,0.466666666666667,0.705882352941177}
\begin{axis}[
log basis x={10},
log basis y={10},
minor ytick={0.02,0.03,0.04,0.05,0.06,0.07,0.08,0.09,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,2,3,4,5,6,7,8,9,20,30,40,50,60,70,80,90,200,300,400,500,600,700,800,900},
minor yticklabels={\(\displaystyle {2\times10^{-2}}\),\(\displaystyle {3\times10^{-2}}\),\(\displaystyle {4\times10^{-2}}\),\(\displaystyle {5\times10^{-2}}\),\(\displaystyle {6\times10^{-2}}\),\(\displaystyle {7\times10^{-2}}\),\(\displaystyle {8\times10^{-2}}\),\(\displaystyle {9\times10^{-2}}\),\(\displaystyle {2\times10^{-1}}\),\(\displaystyle {3\times10^{-1}}\),\(\displaystyle {4\times10^{-1}}\),\(\displaystyle {5\times10^{-1}}\),\(\displaystyle {6\times10^{-1}}\),\(\displaystyle {7\times10^{-1}}\),\(\displaystyle {8\times10^{-1}}\),\(\displaystyle {9\times10^{-1}}\),\(\displaystyle {2\times10^{0}}\),\(\displaystyle {3\times10^{0}}\),\(\displaystyle {4\times10^{0}}\),\(\displaystyle {5\times10^{0}}\),\(\displaystyle {6\times10^{0}}\),\(\displaystyle {7\times10^{0}}\),\(\displaystyle {8\times10^{0}}\),\(\displaystyle {9\times10^{0}}\),\(\displaystyle {2\times10^{1}}\),\(\displaystyle {3\times10^{1}}\),\(\displaystyle {4\times10^{1}}\),\(\displaystyle {5\times10^{1}}\),\(\displaystyle {6\times10^{1}}\),\(\displaystyle {7\times10^{1}}\),\(\displaystyle {8\times10^{1}}\),\(\displaystyle {9\times10^{1}}\),\(\displaystyle {2\times10^{2}}\),\(\displaystyle {3\times10^{2}}\),\(\displaystyle {4\times10^{2}}\),\(\displaystyle {5\times10^{2}}\),\(\displaystyle {6\times10^{2}}\),\(\displaystyle {7\times10^{2}}\),\(\displaystyle {8\times10^{2}}\),\(\displaystyle {9\times10^{2}}\)},
tick align=outside,
tick pos=both,
x grid style={white!69.0196078431373!black},
xmajorgrids,
xmin=0.0891250938133746, xmax=1.12201845430196,
xmode=log,
xtick style={color=black},
xtick={0.001,0.01,0.1,1,10,100},
xticklabels={\(\displaystyle {10^{-3}}\),\(\displaystyle {10^{-2}}\),\(\displaystyle {10^{-1}}\),\(\displaystyle {10^{0}}\),\(\displaystyle {10^{1}}\),\(\displaystyle {10^{2}}\)},
y grid style={white!69.0196078431373!black},
ymajorgrids,
ymin=0.744204651624659, ymax=1.02279350106431,
ymode=log,
ytick style={color=black},
ytick={0.01,0.1,1,10,100},
yticklabels={\(\displaystyle {10^{-2}}\),\(\displaystyle {10^{-1}}\),\(\displaystyle {10^{0}}\),\(\displaystyle {10^{1}}\),\(\displaystyle {10^{2}}\)}
]
\addplot [only marks, mark=*, draw=color0, fill=color0, colormap/viridis]
table{%
x y
0.00404784042977909 0.763156
0.0525233880194801 0.844144
0.449141504662488 0.99606
0.691519242610994 1
0.9779656601865 1
};
\end{axis}
\end{tikzpicture}
Expected output:
Obtained output:
and this warning in my Latex editor (TeXstudio):
! Package pgfkeys Error: I do not know the key '/tikz/minor yticklabels', to wh ich you passed '(\displaystyle {2\times 10^{-2}}),(\displaystyle {3\times 10 ^{-2}}),(\displaystyle {4\times 10^{-2}}),(\displaystyle {5\times 10^{-2}}\ ),(\displaystyle {6\times 10^{-2}}),(\displaystyle {7\times 10^{-2}}),(\di splaystyle {8\times 10^{-2}}),(\displaystyle {9\times 10^{-2}}),(\displayst yle {2\times 10^{-1}}),(\displaystyle {3\times 10^{-1}}),(\displaystyle {4\ times 10^{-1}}),(\displaystyle {5\times 10^{-1}}),(\displaystyle {6\times 1 0^{-1}}),(\displaystyle {7\times 10^{-1}}),(\displaystyle {8\times 10^{-1}} ),(\displaystyle {9\times 10^{-1}}),(\displaystyle {2\times 10^{0}}),(\di splaystyle {3\times 10^{0}}),(\displaystyle {4\times 10^{0}}),(\displaystyl e {5\times 10^{0}}),(\displaystyle {6\times 10^{0}}),(\displaystyle {7\time s 10^{0}}),(\displaystyle {8\times 10^{0}}),(\displaystyle {9\times 10^{0}} ),(\displaystyle {2\times 10^{1}}),(\displaystyle {3\times 10^{1}}),(\dis playstyle {4\times 10^{1}}),(\displaystyle {5\times 10^{1}}),(\displaystyle {6\times 10^{1}}),(\displaystyle {7\times 10^{1}}),(\displaystyle {8\times 10^{1}}),(\displaystyle {9\times 10^{1}}),(\displaystyle {2\times 10^{2}}\ ),(\displaystyle {3\times 10^{2}}),(\displaystyle {4\times 10^{2}}),(\disp laystyle {5\times 10^{2}}),(\displaystyle {6\times 10^{2}}),(\displaystyle {7\times 10^{2}}),(\displaystyle {8\times 10^{2}}),(\displaystyle {9\times 10^{2}})', and I am going to ignore it. Perhaps you misspelled it.
I've noticed that, when you do not save it as png before saving it as tikz, it does not insert the minor yticklabels and minor xticklabels:
Python code:
import matplotlib.pyplot as plt
from tikzplotlib import save as tikz_save
x=[.00404784042977909,.140660747273482,.294901125967985,.603381883356992,.779656601864995,.9779656601865]
y=[.763156,.92578,0.979844,.9997,1,1]
plt.figure()
plt.scatter(x,y)
plt.xscale('log')
plt.yscale('log')
plt.grid()
#plt.savefig("test.png")
tikz_save("test.tikz",encoding ='utf-8')
Tikz output:
% This file was created by tikzplotlib v0.9.1.
\begin{tikzpicture}
\definecolor{color0}{rgb}{0.12156862745098,0.466666666666667,0.705882352941177}
\begin{axis}[
log basis x={10},
log basis y={10},
tick align=outside,
tick pos=both,
x grid style={white!69.0196078431373!black},
xmajorgrids,
xmin=0.0891250938133746, xmax=1.12201845430196,
xmode=log,
xtick style={color=black},
y grid style={white!69.0196078431373!black},
ymajorgrids,
ymin=0.744204651624659, ymax=1.02279350106431,
ymode=log,
ytick style={color=black}
]
\addplot [only marks, mark=*, draw=color0, fill=color0, colormap/viridis]
table{%
x y
0.00404784042977909 0.763156
0.140660747273482 0.92578
0.294901125967985 0.979844
0.603381883356992 0.9997
0.779656601864995 1
0.9779656601865 1
};
\end{axis}
\end{tikzpicture}
Please provide a minimal working example (MWE) that shows what isn't working as expected. Needed is
Perhaps the Pgfplots manual is helpful here.