我目前正在从 CSV 文件中读取一些数据,并将 xticklabels 作为该文件的一列:
\pgfplotstableread[col sep=comma]{data/test1_d4.csv}\dataTestOneFour
\begin{figure}[ht]
\centering
\begin{tikzpicture}
\begin{axis}[
minor y tick num = 3,
ylabel={$\mu(\Phi)$},
flexible xticklabels from table={data/test1_d4.csv}{N}{col sep=comma},
xticklabel style={text height=1.5ex},
xtick=data
]
\addplot[gray,thick,mark=x] table[x expr=\coordindex,y=wB]{\dataTestOneFour};
\addplot[light-gray,thick,mark=x] table[x expr=\coordindex,y=mu]{\dataTestOneFour};
\addplot[lighter-gray,thick,mark=x] table[x expr=\coordindex,y=uB]{\dataTestOneFour};
\legend{data 1, data 2, data 3};
\end{axis}
\end{tikzpicture}
\caption{\emph{$d = 4$ }}\label{fig:test1_d4}
\end{figure}
但是,一旦我生成大量数据,xticklabels 就会重叠,如果我可以自动省略其中一些,那就太好了。但我从未发现如何指定 xticks 的总数。这可能吗?
答案1
我不知道有没有自动的方法来执行此操作,我只是修改了“xticklabels”选项:这是示例:(手动方法)
\documentclass{memoir}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[a4paper]{geometry}
\usepackage{pgfplots}
\usepackage{vmargin}
\setmarginsrb { 1.5in} % left margin
{ 0.6in} % top margin
{ 1.0in} % right margin
{ 0.8in} % bottom margin
{ 20pt} % head height
{0.25in} % head sep
{ 9pt} % foot height
{ 0.3in} % foot sep
\raggedbottom
\begin{document}
\noindent
\begin{tikzpicture}
\begin{axis}[legend pos=north east,
legend style={draw=none},
scaled ticks=true,
]
\addplot[green, mark=o] table{Annexes/resultats/BET/GRAPbjh2.dat};\label{plotsplot22};
\end{axis}
\end{tikzpicture}\\
\begin{tikzpicture}
\begin{axis}[legend pos=north east,
legend style={draw=none},
scaled ticks=true,
xticklabels={,0,,40,,80,,120}
]
\addplot[green, mark=o] table{Annexes/resultats/BET/GRAPbjh2.dat};\label{plotsplot22}
\end{axis}
\end{tikzpicture}
\end{document}