3

I have this code

  \begin{tikzpicture}

\begin{axis}[%
width=\figurewidth,
height=\figureheight,
scale only axis,
xmin=0,
xmax=1.5e-05,
ymin=1.222e-07,
ymax=1.224e-07
]
\addplot [color=red,line width=4.0pt,only marks,mark=*,mark options={solid},forget plot]
  table[row sep=crcr]{
1e-06   1.22231e-07 \\
2e-06   1.22234e-07 \\
3e-06   1.22239e-07 \\
4e-06   1.22246e-07 \\
5e-06   1.22255e-07 \\
6e-06   1.22266e-07 \\
7e-06   1.22279e-07 \\
8e-06   1.22294e-07 \\
9e-06   1.22311e-07 \\
1e-05   1.2233e-07  \\
};
\end{axis}
\end{tikzpicture}%


    \documentclass[12pt]{report}
\usepackage{pgfplots}
\usetikzlibrary{plotmarks}
\begin{document}

I call this in latex.

 \documentclass[12pt]{report}
\usepackage{pgfplots}
\usetikzlibrary{plotmarks}
\begin{document}
\begin{figure}[htbp]
  \centering 
  \setlength\figureheight{3in} 
  \setlength\figurewidth{2.5in} 
  \input{fit12.tex}
  \caption{ Figure}
\label{fig:2}
\end{figure}

\end{document}

I got this enter image description here

How can I replace "." with "x" and as you can see in y-axis , the three-sigfig is not enough for precision. How can I change the label precision? It could be great if the labeling can be readjust automatically like in matlab.

4
  • please provide a full MWE beginning with \documentclass and ending with \end{document}
    – papabravo
    Mar 8 '14 at 0:25
  • @Aung did you see the answers provided below? Mar 8 '14 at 1:51
  • @ Gonzalo Medina Thanks. Can I apply tick scale binop={\times} for all figure as preamble?
    – Aung
    Mar 8 '14 at 1:55
  • @Aung Sure. Add \pgfplotsset{tick scale binop={\times}} to the preamble. Mar 8 '14 at 1:57
4

Since, from the question, only the \cdot for the multiplier of the y-axis must bechanged, you can use

ytick scale label code/.code={$\times 10^{#1}$},

(the only change from the default definition is that \cdot was replaced by \times). If the \cdot of both axis multiplier is to be changed, you can change the definition of tick scale binop instead, using

tick scale binop={\times}

This can be made global for all plots by adding

\pgfplotsset{tick scale binop={\times}}

to the preamble.

To change the precision, you can use

/pgf/number format/precision=<value>

(the default <value> is three). A complete example:

\documentclass[12pt,titlepage]{report}
\usepackage{pgfplots}

\usepackage{filecontents}
\begin{filecontents*}{data.dat}
1e-06   1.22229e-07 
2e-06   1.22234e-07 
3e-06   1.22239e-07 
4e-06   1.22246e-07 
5e-06   1.22255e-07 
6e-06   1.22266e-07 
7e-06   1.22279e-07 
8e-06   1.22294e-07 
9e-06   1.22311e-07 
1e-05   1.2233e-07  
\end{filecontents*}

\begin{document}

\begin{tikzpicture}
\begin{axis}[%
%width=\figurewidth,
%height=\figureheight,
scale only axis,
xmin=0,
xmax=1.5e-05,
ymin=1.22224e-07,
ymax=1.2234e-07,
ytick =data,
ytick scale label code/.code={$\times 10^{#1}$},
/pgf/number format/precision=5
]
\addplot [color=red,line width=4.0pt,only marks,mark=*,mark options={solid},forget plot]
  table {data.dat};
\end{axis}  
\end{tikzpicture}

\end{document}

enter image description here

1
  • Thanks. Now everything works out pretty well. I use like this pgfplotsset{ticklabel style={/pgf/number format/precision=4}, tick scale binop={\times}}.
    – Aung
    Mar 8 '14 at 3:12
0

The first questions is answered by adding tick scale binop=\times to the axis options. All the things you can with that number is described in the pgfplots manual section Tick Scaling - Common Factors In Ticks

working on the precision for the x ticks...

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.