1

I'm writing my thesis in machine learning in latex and I would like to make a figure that shows 2D plot with some points with different shapes and a line that separates them. In other words, I want to show the idea of the decision boundary of a classifier. Are you aware of how to do that with latex? Because I have seen many theses with such figures but I'm unable to know how they did them.

I use OS X and writing with TextMate.

  • 1
    Here's somewhere to start: http://tex.stackexchange.com/questions/205/what-graphics-packages-are-there-for-creating-graphics-in-latex-documents – Thruston Dec 29 '14 at 11:05
  • Probably this can be done in TikZ. If you can craft a picture of what you are trying to do using some other software or pen and paper you are most likely to get help. As it stands now it's a bit to vague, i'd say: "[. . .] 2D plot with some points with different shapes and a line that separates them." – Ruben Dec 29 '14 at 12:35
  • @JackTwain In case you find my answer useful, I would kindly ask you to accept and/or upvote it such that your question no longer shows up as unanswered. Otherwise, please add any specific points that are left open. – cryingshadow Dec 06 '15 at 18:32

1 Answers1

0

Here is a code sample how this can be done using TikZ. It is taken (and slightly modified by adding the separating line you asked for) from http://www.texample.net/tikz/examples/scatterplot/

\documentclass{article}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}[only marks]
    \draw plot[mark=+] file {data1.txt};
    \draw plot[mark=*] file {data2.txt};
    \draw[->] (0,0) -- coordinate (x axis mid) (11,0);
    \draw[->] (0,0) -- coordinate (y axis mid)(0,17);
    \foreach \x in {0,2,4,6,8,10}
        \draw (\x cm,1pt) -- (\x cm,-3pt)
            node[anchor=north] {$\x$};
    \foreach \y in {0,4,8,12,16}
        \draw (1pt,\y cm) -- (-3pt,\y cm) node[anchor=east] {$\y$};
    \node[below=1cm] at (x axis mid) {Dimension 1};
    \node[left=2cm,rotate=90] at (y axis mid) {Dimension 2};
    \draw[red,thick] (1,0) -- (9,16);
\end{tikzpicture}

\end{document}

The sample data files contain the following entries (taken and modified from http://d.xav.free.fr/tikz/):

data1.txt: 2.045784 3.415896 2.405784 4.025693 2.785784 4.522530 3.125784 5.538449 3.485784 6.704992 3.805784 6.978939 4.145784 7.113496 4.425784 8.916397 5.065784 9.487712 5.365784 10.876397 5.685784 10.693497 6.025784 11.364131 6.345784 11.442530 6.665784 12.582530 7.005784 13.125693 7.225784 13.738450 7.585784 14.247891 7.865784 14.982530

data2.txt: 3.045784 2.415896 3.405784 3.025693 3.785784 3.522530 4.125784 4.538449 4.485784 5.704992 4.805784 5.978939 5.145784 6.113496 5.425784 7.916397 6.065784 8.487712 6.365784 9.876397 6.685784 9.693497 7.025784 10.364131 7.345784 10.442530 7.665784 11.582530 8.005784 12.125693 8.225784 12.738450 8.585784 13.247891 8.865784 13.982530

cryingshadow
  • 2,350
  • @ChristianHupfer I'm sorry if I did not understand the answer concept correctly, but as far as I understand this question it asks how to do plots for classification in machine learning. Scatter plots are commonly used for this and they match the description of the OP. Is the pointer to the code sample (which just shows how to do such plots, i.e., answers the question) not enough for an answer? – cryingshadow Dec 29 '14 at 20:44
  • 1
    I edited the answer to contain a code sample directly. – cryingshadow Dec 29 '14 at 21:17