1

I am trying to create something similar to this plot:

enter image description here

I have managed to create the first 3 scatter plots and now I would like to try and replicate the image.

  1. Add horizontal and vertical lines
  2. colour backgrounds
  3. add circles (at the points "% Add circle around here")

Any help would be great

Tex document:

\documentclass[]{article}
\usepackage{tikz}
\usepackage{pgfplots}

\begin{document}

%%%%%%%%%%%%%%% basic scatter plot %%%%%%%%%%%%%%%%

% plot 1: base plot
\begin{tikzpicture}
  \pgfplotsset{
      scale only axis,
  }
  \begin{axis}[
    xlabel=$A$,
    ylabel=$B$,
  ]
    \addplot[only marks, mark=+, mark size=6pt, ultra thick, color = blue]
    coordinates{ % + data
      (0.05,0.50)
      (0.10,0.15)
      (0.30,0.85)
      (0.45, 0.95)
      (0.60, 0.75)
    }; %\label{plot_one}
    \addplot[only marks, mark=-, mark size=6pt, ultra thick, color = red]
    coordinates{ % + data
      (0.20,0.05)
      (0.25,0.60)
      (0.55,0.40)
      (0.90, 0.85)
      (0.90, 0.15)
    };
    % plot 1 legend entry
    %\addlegendimage{/pgfplots/refstyle=plot_one}
   \addlegendentry{D 1}
  \end{axis}
\end{tikzpicture}

% plot 2: adjusted plot
\begin{tikzpicture}
  \pgfplotsset{
      scale only axis,
  }
  \begin{axis}[
    xlabel=$A$,
    ylabel=$B$,
  ]
    \addplot[only marks, mark=+, mark size=4pt, ultra thick, color = blue]
    coordinates{ % + data
      (0.05,0.50)
      (0.10,0.15)
      };
    \addplot[only marks, mark=+, mark size=8pt, ultra thick, color = blue]
    coordinates{ % + data
      (0.30,0.85)
      (0.45, 0.95)
      (0.60, 0.75)
    }; %\label{plot_one}
    \addplot[only marks, mark=-, mark size=4pt, ultra thick, color = red]
    coordinates{ % + data
      (0.20,0.05)
      (0.25,0.60)
      (0.55,0.40)
      (0.90, 0.85)
      (0.90, 0.15)
    };
    % plot 1 legend entry
    %\addlegendimage{/pgfplots/refstyle=plot_one}
   \addlegendentry{D 2}
  \end{axis}
\end{tikzpicture}


% plot 3: adjusted plot
\begin{tikzpicture}
  \pgfplotsset{
      scale only axis,
  }
  \begin{axis}[
    xlabel=$A$,
    ylabel=$B$,
  ]
    \addplot[only marks, mark=+, mark size=4pt, ultra thick, color = blue]
    coordinates{ % + data
      (0.05,0.50)              % Add circle around here
      (0.10,0.15)              % Add circle around here
      };
    \addplot[only marks, mark=+, mark size=6pt, ultra thick, color = blue]
    coordinates{ % + data
      (0.30,0.85)
      (0.45, 0.95)
      (0.60, 0.75)
    }; %\label{plot_one}
    \addplot[only marks, mark=-, mark size=8pt, ultra thick, color = red]
    coordinates{ % - data
      (0.20,0.05)
      (0.25,0.60)
      (0.55,0.40)
      };
      \addplot[only marks, mark=-, mark size=2pt, ultra thick, color = red]
    coordinates{ % - data
      (0.90, 0.85)             % Add circle around here
      (0.90, 0.15)
    };
    % plot 1 legend entry
    %\addlegendimage{/pgfplots/refstyle=plot_one}
   \addlegendentry{D 3}
  \end{axis}
\end{tikzpicture}


\end{document}
2
  1. You can add lines within the axis environment using:

\draw (axis cs:x1,y1)--(axis cs:x2,y2);

With (x1,y1) and (x2,y2) the coordinates of your lines.

  1. In the axis environment, you can fill the area between paths. Start by creating paths:

\path[name path = name_of_your_path] (axis cs:x1,y1) -- (axis cs:x2,y2);

Then fill the area between two paths:

\addplot [your_color] fill between[of = name_of_your_path_1 and name_of_your_path_2, soft clip = {domain=x1:x2}];

Here, the two paths are defining the boundaries of the area on the y axis and the soft clip is defining the boundaries on the x axis.

  1. For the points you are trying to circle, simply use a different marker by loading in the preamble:

\usetikzlibrary{plotmarks}

Then select the appropriate marker. In your case use mark=oplus instead ofmark=+. A complete list of markers can be found in the Manual for Packagepgfplots, section "Markers, Linestyles, (Background-) Colors and Colormaps" (page 120 for the version 1.5.1 DEV).

| improve this answer | |

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.