0

I want to plot multiple figures with the same settings, but different content. I would then like to be able to change the settings in all plots at the same time. To achieve this, I'd like to store the settings in their own file, so when it changes, the plots will all change! Say I wan't to plot $\sin(x)$ and $\cos(x)$ (here only $\sin(x)$ is shown) I could then store my xlabel in the file with the settings, and the ylabel in the file making the figure.

It would then looks like the following:

settings.tex:

xlabel={$x$},

main.tex for the $\sin(x)$ plot, change every "sin" to "cos" and it would be the cos file:

\documentclass[border=5pt,tikz]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
    \begin{axis}[
            \input{settings.tex}
            ylabel={$y=\sin(x)$}
        ]
        \addplot gnuplot[id=sin]{sin(x)};

    \end{axis}
\end{tikzpicture}
\end{document}

This however stuns LaTeX, and will not compile. If I move the xlabel to the main file, I get what I want:

enter image description here

The above is very much an MWE. I would offcourse like to use tens of settings across a multitude of figures, making it very tiresome to update the settings in every plot.

0 Answers0