I am a beginner in LaTeX, trying to use it for industrial documents, such a measurements report. One example is the true position graph of the MWE. The circle represents the true position tolerance. Data point outside of the circle do not meet the requirements.
I would like to improve it in the following way:
Specify the limits of the graph automatically (i.e. by extending the max value found either in X or Y columns of a certain factor, the same for the X axis and Y axis) fom the actual data, and not manually in the following lines:
xmin = -0.35, xmax = 0.35, ymin = -0.35, ymax = 0.35,In a similar way, the vertical and horizontal lines created by the following lines should adapt automatically to the graph size.
\addplot+[sharp plot, mark=none, black] coordinates {(-0.50,0) (0.5,0)}; \addplot+[sharp plot, mark=none, black] coordinates {(0,-0.5) (0,0.5)};If possible, assign the color of the dots, not on the Y value, but on the polar distance to the center.
Align vertically the color bar labels i.e. on the decimal separator, as opposed to the current position.
As a bonus, assign a neutral (i.e. blue) color to all dots that meet the tolerance, (are inside or on the circle) , and color code only the ones that do not meet the requirements...
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usepackage[active,tightpage]{preview} %produces the plot only when activated
\PreviewEnvironment{tikzpicture} %produces the plot only when activated
\pgfplotsset{compat=1.5.1}
\usepackage{filecontents}
\begin{document}
\thispagestyle{empty}
\begin{filecontents}{Data.dat}
X Y
0.059 0.207
-0.030 0.198
-0.035 0.042
0.064 0.130
-0.118 0.133
-0.128 0.195
-0.143 0.022
-0.148 0.182
-0.079 -0.005
-0.081 0.124
-0.091 0.126
-0.090 0.261
-0.049 -0.037
-0.045 0.063
-0.048 0.124
-0.051 0.199
-0.040 -0.063
-0.025 0.035
-0.028 0.117
-0.057 0.270
-0.020 -0.075
-0.022 0.025
-0.024 0.138
-0.33 0.288
0.012 -0.111
0.069 0.004
0.014 0.101
-0.021 -0.293
\end{filecontents}
\pgfplotstableread{Data.dat}\mytable % Creating a macro containin the data of external file
\tikzset{every mark/.append style={scale=0.7}} %Adjusting size of marks in plot
\begin{tikzpicture}
\begin{axis}[scale= 2, width=8cm,height=8cm,
%axis on top,
ticklabel style={/pgf/number format/.cd, fixed, precision=2,use comma},
xmin = -0.35, xmax = 0.35, %Plot X size
ymin = -0.35, ymax = 0.35, % Plot Y size
xlabel = {True position (mm), X axis},
ylabel = {True position (mm), Y axis},
title= Pin tip location (solder side),
colorbar, colorbar style={ticklabel style={/pgf/number format/.cd, fixed, fixed zerofill, precision=2,use comma}},
]
\addplot[scatter, only marks, mark=*]
table {\mytable};
\draw[red] (axis cs:0,0) circle[radius=0.1];
\addplot+[sharp plot, mark=none, black] coordinates {(-0.50,0) (0.5,0)};
\addplot+[sharp plot, mark=none, black] coordinates {(0,-0.5) (0,0.5)};
\end{axis}
\end{tikzpicture}
\end{document}

enlargelimits,axis equalinstead of the given options, the second issue is a wrong application and you can use one of the solutions in how-can-i-add-a-zero-line-to-a-plot. The third-fifth questions are also asked on this site before. Please search for items together with the[pgfplots]string which will search only in pgfplots tagged questions. Basically you want to create a new column or do some vector lenght calculation. If you get stuck on one of these ask them seperately. – percusse Jul 19 '12 at 12:30