[Tex/LaTex] How to prevent scientific notation on a plot and add a trend line

pgfplotstikz-pgf

I like to show the numbers in decimal 0.01, 0.02, 0.03, .. 0.10 rather than scientific notation. Is this possible?

Also, didn't mean to add a secondary question but each time I try adding a trend line, it doesn't work. Any advice on that is appreciated as well.

\documentclass{article}

\usepackage[letterpaper, portrait, margin=2cm]{geometry}
\usepackage[english]{babel}
\usepackage[protrusion=true,expansion=true]{microtype}
\usepackage{amsmath,amsfonts,amsthm,amssymb}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{colortbl} 
\usepackage[svgnames,table,xcdraw,dvipsnames]{xcolor}
\usepackage{multirow}
\usepackage{tabularx}
\usepackage{array} 
\usepackage{pgfplots}
\usepackage{booktabs}
\usepackage{cellspace}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage[svgnames,table,xcdraw,dvipsnames]{xcolor} 
\usepackage[version=3]{mhchem}
\usepackage{chemfig}
\usepackage{gensymb}
\usepackage[most]{tcolorbox}
\usepackage{xparse}
\usepackage{tikz}
\usepackage{makecell}
\usepackage{floatflt}
\usepackage{wrapfig}
\usepackage{fancyhdr}
\usepackage{epstopdf}
\usetikzlibrary{calc,shadings,patterns}
\pagenumbering{roman}

.. snip

\begin{center}
\includegraphics[scale=0.75]{exp24_fig2.eps}
\end{center}
\section*{Results}

\noindent
\begin{tabular}{@{}cc@{}}
\begin{tikzpicture}[baseline=(current bounding box.center)]
\begin{axis}[
title={Ballistic Galvanometer Calibration},
xlabel={Capacitance ($\mu$F)},
ylabel={Deflectance (cm)},
xmin=0.01, xmax=0.10,
ymin=2, ymax=17,
legend pos=north west,
ymajorgrids=true,
xmajorgrids=true,
yminorgrids=true,
xminorgrids=true,
grid style=dashed,
]

\addplot[
    color=blue,
    mark=square,
 ]
 coordinates {
  (0.01,2)(0.02,4)(0.03,5)(0.04,7)(0.05,8)(0.06,10)(0.07,12)(0.08,13)(0.09,15) (0.10,17)
 };
\end{axis}
\end{tikzpicture}

Best Answer

You have to use the xtick label style to get the desired format or to override the style chosen. An example is on page 23 of the pgfplots manual. The code below gives you the desired output:

\documentclass[x11names,svgnames,11pt]{article}
%
\usepackage{pgfplots}
  \pgfplotsset{compat=1.13}

\begin{document}

\begin{tikzpicture}[baseline=(current bounding box.center)]
\begin{axis}[
title={Ballistic Galvanometer Calibration},
xlabel={Capacitance ($\mu$F)},
ylabel={Deflectance (cm)},
xmin=0, xmax=0.12, 
xticklabel style={
  /pgf/number format/precision=3,
  /pgf/number format/fixed},
legend pos=north west,
ymajorgrids=true,
xmajorgrids=true,
yminorgrids=true,
xminorgrids=true,
grid style=dashed,
]

\addplot[only marks, color=blue, mark=square]
 coordinates {
  (0.01,2)
  (0.02,4)
  (0.03,5)
  (0.04,7)
  (0.05,8)
  (0.06,10)
  (0.07,12)
  (0.08,13)
  (0.09,15)
  (0.10,17)
 };
  \addplot[no marks] {163*x+0.3333 } ;
\end{axis}
\end{tikzpicture}


\end{document}

I calculated the linear regression coefficients outside pgfplots. Here is the graph: Graph

Related Question