1

I have a few graphs plotted using pgfplots:

\documentclass{article}

\usepackage{pgfplots}
\usepackage{lipsum}

\begin{filecontents}{data.csv}
0; 1
2; 3
\end{filecontents}

\begin{document}

\lipsum[1]

\begin{figure}
    \begin{tikzpicture}[trim axis left]
        \begin{axis}[
            height=5.5cm,
            scale only axis,
            width=\linewidth,
        ]
    \addplot table[col sep=semicolon] {data.csv};
        \end{axis}
    \end{tikzpicture}
\end{figure}
\end{document}

I personally love the fact that my graph axis is flush with the text. Gives me a very pleasant feeling.

However, I am now converting my document to two-column layout. When a figure gets into the right column, the labels of the left axis flow into the left column. I can of course manually throw my axis to the other side of the graph, but I'm wondering whether it's possible to have the correct options (ylabel near ticks, yticklabel pos=right) automatically inserted when my picture flows in the right column.

Example of the labels overflowing into text

MWE:

\documentclass[twocolumn]{article}

\usepackage{pgfplots}
\usepackage{lipsum}

\begin{filecontents}{data.csv}
0; 1
2; 3
\end{filecontents}

\begin{document}

\lipsum[1-4]

\begin{figure}
    \begin{tikzpicture}[trim axis left]
        \begin{axis}[
            height=5.5cm,
            scale only axis,
            width=\linewidth,
        ]
    \addplot table[col sep=semicolon] {data.csv};
        \end{axis}
    \end{tikzpicture}
\end{figure}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.