I want to make a scatter plot and vary the mark size dependent on a variable.
Furthermore, I want the mark color to be dependent on the meta value given in a file (which works in the given code).
As an example, I want a non-linear dependency like mark size = sqrt(y value of point), or alternatively to use a variable from a for loop.
Since mark size seems to expect a length, I just find no way to do some calculations, as my trials with \pgfmathresult or some \edef... macros were not successfull.
I managed to change the mark size with the code
scatter/@pre marker code/.style={/tikz/mark size={4-\pgfkeysvalueof{/data point/y}/4}},%\pgfmathparse{1}\pgfmathresult},
scatter/@post marker code/.style={}
However, the color mapping to the meta value gets lost then.
\documentclass[tikz, border=5mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usetikzlibrary{plotmarks}
\usepackage{amsmath}
\usepackage{filecontents}
\begin{filecontents*}{temp.dat}
1 1 100
2 2 200
3 3 300
4 4 400
5 5 500
6 6 600
7 7 700
8 8 800
9 9 900
10 10 1000
\end{filecontents*}
\begin{document}
\begin{tikzpicture}
\begin{axis}[%
width=4.5in,
height=3.5in,
scale only axis,
xmin=0,
xmax=10,
ymin=0,
ymax=10,
axis x line*=bottom,
axis y line*=left,
colorbar
]
\addplot[%
scatter=true,
only marks,
mark=*,
color=blue,
point meta=explicit symbolic,
%scatter/@pre marker code/.style={/tikz/mark size= f (yvalue)?},
%scatter/@post marker code/.style={}
] table [meta index=2] {temp.dat};
\end{axis}
\end{tikzpicture}%
\end{document}
The example code is copied from here: How to keep the same mark colour when using meta data for marker size?


append:) – crateane Mar 27 '16 at 10:14filecontentspackage is only needed if you want to overwrite the file on the system. Thefilecontentsenvironment also works without loading the package. – Jake Mar 28 '16 at 10:50yvalues in the first answer go up to 10, but the marks/colorbar has a max of 1. The plot didn't change when I tried to modify the data intemp.dat(after submitting my answer), so I figured the file wasn't actually being read. – erik Mar 28 '16 at 13:04