2

Situation and Problem

This question is a follow-up and based on marmots answer of this question. The general situation is described there. I modified the markers as in this answer, but could not make them dependant on the class-column.

Question

How to change the marker option in a scatter/classes-class

I tried variations, e.g. to move all the mark options inside the class part, resulting in only 'p's instead of other letters (or numbers). This seems to be related, but I couldn't figure out how to do the mapping.

For instance, in this example a and b should appear in a box and c, d in a triangle. However, the circle setting is not overwritten.

MWE

\documentclass[tikz,border=3mm]{standalone}

\usetikzlibrary{calc}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15} 
\usepgfplotslibrary{polar}

\usepackage{filecontents}
\begin{filecontents*}{radar.csv}
    angle,radius,class,name
    130,    4,  1,  a
    348,    3,  1,  b
    212,    5,  2,  c
    56,     2,  2,  d
\end{filecontents*}

\begin{document}
\begin{tikzpicture}
    \begin{polaraxis}[
        width=8cm, height=8cm,
        visualization depends on={value \thisrow{name} \as \labelname}
        ]
        \addplot[
            scatter, only marks,
            point meta=explicit symbolic,
            mark options={
                text mark=\labelname,
                text mark as node=true,
                text mark style={circle,inner sep=1pt,draw}
            },
            scatter/classes={
                1={
                    mark = text,
                    mark options={
                        text mark style={square,inner sep=2pt,draw}
                        },
                    blue
                    },
                2={
                    mark = text,
                    mark options={
                        text mark style={*triangle}
                        },
                    red
                    }
                }
            ]
            table[ x=angle, y=radius, meta=class, col sep=comma
            ] {radar.csv};
    \end{polaraxis}
\end{tikzpicture}
\end{document}
BadAtLaTeX
  • 1,139

1 Answers1

2

What I can offer is the following, where I looked up some things in this answer:

\documentclass[tikz,border=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15} 
\usepgfplotslibrary{polar}

\usepackage{filecontents}
\begin{filecontents*}{radar.csv}
    angle,radius,class,name
    130,    4,  1,  a
    348,    3,  1,  b
    212,    5,  2,  c
    56,     2,  2,  d
\end{filecontents*}

\begin{document}
\begin{tikzpicture}
    \begin{polaraxis}[
        width=8cm, height=8cm,
        visualization depends on={value \thisrow{name} \as \labelname}
        ]
        \addplot[scatter/classes={
                1={mark=text,text mark=\labelname,blue,text mark as node=true,
                         text mark style={rectangle,inner sep=2pt,draw}
                         },
                2={mark=text,text mark=\labelname,red,text mark as node=true,
                         text mark style={circle,inner sep=2pt,draw}}
                },
                scatter,draw=none,
                scatter src=explicit symbolic]
         table[x=angle, y=radius, meta=class, col sep=comma]
            {radar.csv};
    \end{polaraxis}
\end{tikzpicture}
\end{document}

enter image description here

However, I am not sure I understand text mark style={square,...} nor text mark style={*triangle}, but this may just be me.

  • That's it. Thank you! I didn't know square wasn't a thing, but it is not relevant whether there are actually squares rather than boxes. *triangle was also meant to overwrite the circle setting, just for testing, whether a filled background would be possible - not really relevant either - can be found here. – BadAtLaTeX Jun 16 '19 at 09:29
  • 1
    I stumbled upon a peculiar behavior: When inserting the \legend{Class 1,Class 2}; it will cause an error: "! Undefined control sequence. \pgfmarktext@ ->\labelname". – BadAtLaTeX Jun 16 '19 at 11:04
  • @gr4nt3d This could be a bug, i.e. I think this should not happen. (You could add the legend by hand.) –  Jun 16 '19 at 13:20