I'm doing a grouped plot using groupplot
. I liked the graphic but I can't put the legend correctly. Here is the code:
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{makeidx}
\usepackage{graphicx}
\usepackage{times}
\usepackage[brazil]{babel}
\usepackage{tikz}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots}
\usepackage{filecontents}
\begin{document}
\begin{filecontents*}{dose_sulfato.csv}
Dosagem SA, Turbidez, Cor, Potencial, Remocao T, Remocao C,
7.8, 2.75, 35, -5.43, 68.85617214, 79.76878613
8.4, 1.78, 39, -3.69, 79.8414496, 77.4566474
9, 1.57, 30, -5.04, 82.21970555, 82.65895954
9.6, 1.3, 27, -0.746, 85.27746319, 84.39306358
10.2, 1.67, 28, -2.71, 81.08720272, 83.8150289
\end{filecontents*}
%
\begin{filecontents*}{dose_quitosana.csv}
Dosagem Q, Turbidez, Cor, Potencial, Remocao T, Remocao C
0.5, 1.32, 22, -6.61, 85.05096263, 87.28323699
0.7, 0.7, 10, -2.48, 92.07248018, 94.21965318
\end{filecontents*}
\begin{tikzpicture}
\begin{groupplot}[
group style={group size=2 by 2},
width=0.4\textwidth,
xtick=data,
]
\nextgroupplot[title=Turbidez]
\addplot table[x=Dosagem SA, y=Remocao T, col sep=comma,] {dose_sulfato.csv};
\nextgroupplot[title=Cor Aparente]
\addplot table[x=Dosagem SA, y=Remocao C, col sep=comma,] {dose_sulfato.csv};
\nextgroupplot
\addplot[red, mark=*] table[x=Dosagem Q, y=Remocao T, col sep=comma,] {dose_quitosana.csv};
\nextgroupplot
\addplot[red, mark=*] table[x=Dosagem Q, y=Remocao C, col sep=comma,] {dose_quitosana.csv};
\end{groupplot}
\node[anchor=north] (title-x) at ($(group c1r2.south east)!0.5!(group c2r2.south west)-(0,0.5cm)$) {Dosagem de Coagulante $(mg/L)$};
\node[anchor=south, rotate=90] (title-y) at ($(group c1r1.south west)!0.5!(group c1r2.north west)-(0.85,0cm)$) {Remoção (\%)};
\end{tikzpicture}
\end{document}
I'm getting:
But I want to get something like that
I don't know how to put the legend that way. Anyone can help me?
EDIT 1: The legend can be placed anywhere in the graphic