1

I'm trying to make an image with 2 groupplots, and a single legend. Issue #1 should be evident: the legend is showing up to the right of the plots, not below them. < This has been solved using a tabular environment and a single column. The second issue is more subtle: the legend has no colors in the marks!

enter image description here

Here's a sort of template of my code, since it was generated by tikzplotlib (I'm using standalone to precompile the pdfs to then add into my main file):

\documentclass[tikz,border=2pt]{standalone}
\input{pre/fig-preamble}
\begin{document}
% This file was created by tikzplotlib v0.9.8.
\begin{tikzpicture}[
scale=1.0
]

\definecolor{color0}{rgb}{1,0.498039215686275,0.0549019607843137} \definecolor{color1}{rgb}{0.12156862745098,0.466666666666667,0.705882352941177} \definecolor{color2}{rgb}{0.83921568627451,0.152941176470588,0.156862745098039}

\begin{groupplot}[group style={group size=2 by 1, horizontal sep=2cm}] \nextgroupplot[ legend cell align={left}, legend columns=2, legend style={ fill opacity=0.8, draw opacity=1, text opacity=1, at={(0.97,0.03)}, anchor=south east, draw=white!80!black }, legend to name=namedleg1, tick align=outside, tick pos=left, x grid style={white!69.0196078431373!black}, xlabel={Applied force in X [N]}, xmajorgrids, xmin=-30, xmax=30, xtick style={color=black}, y grid style={white!69.0196078431373!black}, ylabel={Bridge Response [V/V]}, ymajorgrids, ymin=-0.0015, ymax=0.0015, ytick style={color=black} ] \addplot [draw=color0, mark=triangle, only marks] table{% % DATAPOINTS }; \addlegendentry{Bridge 0, Loading} \end{groupplot}

Here would be all other groupplots, datapoints, legend entries etc; I've removed them since it's just repetition

\end{tikzpicture}
\\
\ref{namedleg1}
\end{document}

How can I solve either (hopefully both) problems? Thanks in advance!

EDIT: Solved - moved colors up a few lines, before the tabular env.

Stefan Pinnow
  • 29,535
dartacao
  • 31
  • 2

0 Answers0