# scatter plot - mark absolute size from data and custom colormap

I'm trying to implement a scatter plot that automatically scales the marks according to its absolute values. I don't want to use \pgfplotspointmetatransformed but rather \pgfplotspointmeta, as I need to compare it to another plot, though I just can't manage to do so...

Furthermore I tried creating a colormap, that maps from a color range for z > 0, and a different color range for z < 0. So you'd immediately notice whether a value is negative or positive - though I'm kind of confused so set the limits the way, that it changes from red to blue at 0, because I'm already using the meta data for the size...

\pgfplotstableread{
A B C
0    5 -10
0.5  2   0
1    7   5
1.5 11  20
}\mytable

\begin{tikzpicture}
\pgfplotsset{
colormap={test}{[2pt]
rgb255(0pt)=(255, 200, 0);
rgb255(500pt)=(255, 75, 0);
rgb255(502pt)=(0, 100, 255);
rgb255(1000pt)=(0, 255, 255)
}
}

\begin{axis}[
colorbar
]

scatter,
only marks,
scatter src=explicit,
mark=*,
scatter/use mapped color={
draw=mapped color,
fill=mapped color,
},
scatter/@pre marker code/.append style=
{/tikz/mark size={.6pt+abs(\pgfplotspointmetatransformed/200)}}]
table[meta expr=abs(\thisrow{C})] {\mytable};
\end{axis}
\end{tikzpicture}


I'd be happy for hints
Thx

I am not 100% sure if I have understood your question right. Do you mean something like the following?

% used PGFPlots v1.15
\documentclass[border=5pt]{standalone}
\usepackage{pgfplotstable}
\pgfplotsset{
colormap={test}{[2pt]
rgb255(0pt)=(255, 200, 0);
rgb255(500pt)=(255, 75, 0);
rgb255(502pt)=(0, 100, 255);
rgb255(1000pt)=(0, 255, 255)
},
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
colorbar,
% because you want the color change at zero but don't have "symmetric"
% data, you have to give the point meta min' and point meta max'
% values manually
point meta min=-20,
point meta max=20,
]
scatter,
only marks,
scatter src=explicit,
mark=*,
scatter/use mapped color={
draw=mapped color,
fill=mapped color,
},
% store the (original) of "C" in a macro ...
visualization depends on={\thisrow{C} \as \perpointmarksize},
scatter/@pre marker code/.append style={
% ... and use this macro here
% (please note that I have changed the values a bit )
/tikz/mark size={1pt+abs(\perpointmarksize/5)}
},
% because of a bug in PGFPlots (<https://sourceforge.net/p/pgfplots/bugs/109/>)
% you have to give the table explicitly like here or in a file to not get an
% error message
% (it is not allowed to give the table as a command)
] table [meta=C] {
A B C
0    5 -10
0.5  2   0
1    7   5
1.5 11  20
};
\end{axis}
\end{tikzpicture}
\end{document}