2

The following tiki code (generated from matlab) prints nicely, but I would like to print only one x label out of two. That is, instead of printing:

10^−14 10^−13 10^−12 10^−11 10^−10 10^−9 10^−8 10^−7 10^−6 10^−5 10^−4

I would like to print:

10^−1 10^−1 10^−10 10^−8 10^−6 10^−4

I searched the pff/tikz manual but did not find anything.

\begin{tikzpicture}

\begin{axis}[%
width=3.149in,
height=2.649in,
at={(0.594in,0.521in)},
scale only axis,
separate axis lines,
every outer x axis line/.append style={black},
every x tick label/.append style={font=\color{black}},
every x tick/.append style={black},
xmode=log,
xmin=1e-14,
xmax=1e-4,
xminorticks=true,minor
xlabel={\large{\Lobj}},
every outer y axis line/.append style={black},
every y tick label/.append style={font=\color{black}},
every y tick/.append style={black},
ymin=50,
ymax=250,
ylabel={\large{\Cmax}},
axis background/.style={fill=white},
% title={lambda:Cmax}
]
\addplot [color=blue, line width=1.0pt, forget plot]
  table[row sep=crcr]{%
9e-05   59\\
7e-05   59\\
5e-05   59\\
3e-05   64\\
1e-05   99\\
7e-06   107\\
2e-06   138\\
1e-06   141\\
7e-07   159\\
5e-07   165\\
3e-07   166\\
7e-09   168\\
5e-10   185\\
4e-10   193\\
5e-11   202\\
5e-12   228\\
5e-13   237\\
1e-14   240\\
};
\end{axis}
\end{tikzpicture}%
0

You can use xticklabel to change the definition for the ticklabels of the x axis:

xticklabel={%
  \pgfmathMod{\ticknum}{2}%
  \ifdim \pgfmathresult pt >0pt\axisdefaultticklabellog\fi
}

enter image description here

Code:

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\begin{document}
\begin{tikzpicture}
\begin{axis}[%
width=3.149in,
height=2.649in,
at={(0.594in,0.521in)},
scale only axis,
separate axis lines,
every outer x axis line/.append style={black},
every x tick label/.append style={font=\color{black}},
every x tick/.append style={black},
xmode=log,
xmin=1e-14,
xmax=1e-4,
xminorticks=true,
xlabel={x Text},
every outer y axis line/.append style={black},
every y tick label/.append style={font=\color{black}},
every y tick/.append style={black},
ymin=50,
ymax=250,
ylabel={y Text},
axis background/.style={fill=white},
label style={font=\large},
xticklabel={%
  \pgfmathMod{\ticknum}{2}%
  \ifdim \pgfmathresult pt >0pt\axisdefaultticklabellog\fi
},
% title={lambda:Cmax}
]
\addplot [color=blue, line width=1.0pt, forget plot]
  table[row sep=crcr]{%
9e-05   59\\
7e-05   59\\
5e-05   59\\
3e-05   64\\
1e-05   99\\
7e-06   107\\
2e-06   138\\
1e-06   141\\
7e-07   159\\
5e-07   165\\
3e-07   166\\
7e-09   168\\
5e-10   185\\
4e-10   193\\
5e-11   202\\
5e-12   228\\
5e-13   237\\
1e-14   240\\
};
\end{axis}
\end{tikzpicture}%
\end{document}
| improve this answer | |
  • Many thanks Stephen! I have a followup question, the pff manual has no entry on xticklabel. Where can I find a manual about this? Is it because the code was generated by Matlab that ut has this particular format? Best regards. Alain – Alain Girault Jul 11 '17 at 21:23
  • xticklabel is described in the pgfplots manual in section "Tick Options", subsection "Tick Coordinates and Label Texts". Maybe you can accept my answer if it solves your problem. – esdd Jul 12 '17 at 8:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.