# Specify ticks as micro seconds

I am trying to create a tick which uses e-6 as x axis. Now it automatically scales to e-5.

\documentclass[tikz,border=10pt]{standalone}
\usepackage{tikz}
\usepackage{siunitx}
\usepackage{pgfplots}

\usetikzlibrary{calc}

\begin{document}

\begin{tikzpicture}

\begin{axis}[
width=15cm,
height=7cm,
title=Motor terminal voltage as function of rise time for various cable lenghts,
minor x tick num =5,
minor y tick num = 1,
anchor=origin,
grid=both,
grid style={line width=.1pt, draw=gray!10},
major grid style={line width=.5pt,draw=gray!75},
minor grid style={line width=.2pt,draw=gray!40},
xlabel = Rise time \lbrack\SI{}{\micro\second}\rbrack,
ylabel = Motor terminal voltage \lbrack p.u.\rbrack,
xmax=20e-6,
xmin=0,
%xtick= {0, 0.000001, ...,0.000004}
]

\addplot [black,thick, domain=-1e-6:3.715e-6, samples=10, forget plot]  {2 } ;

black,thick, dotted,variable=\X,
restrict y to domain = -1:2,
domain=0:20e-6, samples=500]
{((3 * 0.010 * 0.999) / (\X * 1/sqrt(0.2414e-3*0.615e-6))) +1 } ;

black, thick, dashed,variable=\X,
restrict y to domain = -1:2,
domain=0:20e-6, samples=500]
{((3 * 0.050 * 0.995) / (\X * 1/sqrt(0.2414e-3*0.615e-6))) +1 } ;

black,thick, solid,variable=\X,
restrict y to domain = -1:2,
domain=0:20e-6, samples=500]
{((3 * 0.10 * 0.9898) / (\X * 1/sqrt(0.2414e-3*0.615e-6))) +1 } ;

legend pos = north east,
\end{axis}

\end{tikzpicture}

\end{document}


What is the trick to solve this?

• Why don't you just name your units [ps] (picoseconds)? Or do you actually mean 10^-6 [s] (seconds)? – Sanchises Nov 17 '15 at 15:05
• I do mean micro seconds. I specify it in the axis label to emphasize it in case people doesnt notice the other one at the right hand side. – fluxmodel Nov 17 '15 at 15:08
• I would strongly advise against that, since it is not only confusing to people who do pay attention to your axis labels, but it's also plain wrong. I would leave out the $\cdot 10^-6$ altogether and specify the [µs] only - nobody's going to skip over your unit designation since it's right next to the axis label. – Sanchises Nov 17 '15 at 15:21
• I would also like to leave out the automatic dot-10^-6, but right now I'm not sure how as it appears automatically. – fluxmodel Nov 17 '15 at 16:47
• That's because your equation and plot range are in seconds. Multiplying everything by 10^6 should work. – Sanchises Nov 17 '15 at 17:13

If fixed it using the following options to the axis environment:

scaled x ticks=base 10:6,
/pgf/number format/sci subscript,


Full working example below with output:

\documentclass[tikz,border=10pt]{standalone}
\usepackage{tikz}
\usepackage{siunitx}
\usepackage{pgfplots}

\usetikzlibrary{calc}

\begin{document}

\begin{tikzpicture}

\begin{axis}[
scaled x ticks=base 10:6,
/pgf/number format/sci subscript,
width=15cm,
height=7cm,
title=Motor terminal voltage as function of rise time for various cable lenghts,
minor x tick num =5,
minor y tick num = 1,
anchor=origin,
grid=both,
grid style={line width=.1pt, draw=gray!10},
major grid style={line width=.5pt,draw=gray!75},
minor grid style={line width=.2pt,draw=gray!40},
xlabel = Rise time \lbrack\SI{}{\micro\second}\rbrack,
ylabel = Motor terminal voltage \lbrack p.u.\rbrack,
xmax=20e-6,
xmin=0,
%xtickten={-6}
%xtick={1e-6}
]

\addplot [black,thick, domain=-1e-6:3.715e-6, samples=10, forget plot]  {2 } ;

black,thick, dotted,variable=\X,
restrict y to domain = -1:2,
domain=0:20e-6, samples=500]
{((3 * 0.010 * 0.999) / (\X * 1/sqrt(0.2414e-3*0.615e-6))) +1 } ;

black, thick, dashed,variable=\X,
restrict y to domain = -1:2,
domain=0:20e-6, samples=500]
{((3 * 0.050 * 0.995) / (\X * 1/sqrt(0.2414e-3*0.615e-6))) +1 } ;

black,thick, solid,variable=\X,
restrict y to domain = -1:2,
domain=0:20e-6, samples=500]
{((3 * 0.10 * 0.9898) / (\X * 1/sqrt(0.2414e-3*0.615e-6))) +1 } ;