3

I hope the title is not misleading, I have no clue how I should name what I want to achieve. Also I'm quite new to pgfplots (or latex in general) so I'm sorry if this is a common question. I could not find any solution and as said I don't really know what to look for either.

So to make things easy here's a quick overview about what my table looks like:

Name  x  y
a     1  R
a     2  R
a     3  R
b     1  R
b     2  R
b     3  R
c     1  R
c     2  R
c     3  R

The R in the y column stands for random number - to emphasis that it is not a fixed value like in name and x.

What I want is one plot for each name. The plot should have 3 x points at the value of x - representing the value of y at that point.

  • Welcome to TeX.SX! On which platform do you work, which tools do you have available? Do you want to do everything in (La)TeX (which is possible, but not always the most elegant and most flexible approach), or is a script in some language (shell script, Perl, ...) that transforms the data (like splitting the table) before LaTeX typesets it also a possibility? – gernot Sep 20 '16 at 12:09
  • Maybe this helps: tex.stackexchange.com/q/314132 – Symbol 1 Mar 21 '17 at 21:13
2

There is an almost exact example in the manual

\documentclass[border=9,tikz]{standalone}
    \usepackage{pgfplots}
\begin{document}
    \begin{tikzpicture}
        \begin{axis}[legend pos=south east]
            \addplot[
                scatter,only marks,scatter src=explicit symbolic,
                scatter/classes={
                    a={mark=square*,blue},%
                    b={mark=triangle*,red},%
                    c={mark=o,draw=black,fill=black}%
                }]
            table[x=x,y=y,meta=label]{
                x    y    label
                0.1  0.15 a
                0.45 0.27 c
                0.02 0.17 a
                0.06 0.1  a
                0.9  0.5  b
                0.5  0.3  c
                0.85 0.52 b
                0.12 0.05 a
                0.73 0.45 b
                0.53 0.25 c
                0.76 0.5  b
                0.55 0.32 c
            };
            \legend{Class 1,Class 2,Class 3,Line}
        \end{axis}
    \end{tikzpicture}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.