I would like to use PGFPlots to create a plot using three sets of metadata. I figure it would be best to have one set represented by the plot mark and the remaining two by the fill and draw colour respectively.
However, I am only able to the mark and one colour:
\documentclass[10pt,a4paper,landscape]{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot[
only marks,
scatter,
point meta = \thisrow{C1},
visualization depends on = {value \thisrow{Mark} \as \markshape},
visualization depends on = { \thisrow{C2} \as \col2},
scatter/@pre marker code/.append style = {
/tikz/draw = \col2,
/tikz/mark = \markshape
}
]
table[x=X,y=Y, row sep = \\]{
X Y C1 C2 Mark \\
1 1 0 6 * \\
2 2 6 0 otimes* \\
3 1 0 0 square* \\
4 5 6 6 diamond* \\
};
\end{axis}
\end{tikzpicture}
\end{document}
The row C2 has no effect on the plot whereas Mark, implemented in the same way, does. Having looked into the manual and corresponding forum entries, I have not been able to find a solution for this problem.
In addition, in my real data, all metadata is in the form of strings and I would, preferably, have something like the scatter classes, which translates a predefined string to a visualization style, e.g. "abc" to "fill = red" or to "mark = \otimes*", depending on the row.
Although I could code every combination of metadata as a seperate scatter class to get what I want, that would be very time consuming and I hope that you can help me getting PGFPlots to do the work for me.
Best Answer
The following code solves the plotting problem for tables like the one in your example. The solution applies
\addplot
twice for each point: once for the fill and another time for the draw colour.The following example code might help you solve the other part of the question, if I understood what you are after. The code accepts metadata in another format: a string consisting of comma-separated "visualization classes" in column
Meta
. Each class only affects one aspect of style (fill color, drawing color, or plot mark), but it would be easy to define more complex classes. If the style of some point should be left at the default settings, an unknown class name such asdefault
can be used as theMeta
value of the point.I used the following sources of information: