1

I am trying to display these graphs as a 2 x 3 grid which I have managed to do successfully in the past, however this time around, the graphs (c) (d) (e) and (f), all have their y ticks missing, causing them to be misaligned in the grid, and their y labels appearing inside the graph.

Here is an image of how it looks.

enter image description here

\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{subcaption}
\numberwithin{figure}{section}
\usepackage{wrapfig}
\usepackage{refstyle}
\graphicspath{{F}}
\usepackage{pdfcolparallel}
\usepackage{booktabs}
\usepackage{array}
\usepackage{pdflscape}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usepackage{multirow}
\usepackage{verbatim}
\usepackage{float}


\begin{document}

\pgfplotsset{compat = 1.10}
\pgfplotstableread[col sep = comma]{tables/v1.csv}\vone
\pgfplotstableread[col sep = comma]{tables/v2.csv}\vtwo
\pgfplotstableread[col sep = comma]{tables/v3.csv}\vthree
\pgfplotstableread[col sep = comma]{tables/v4.csv}\vfour
\pgfplotstableread[col sep = comma]{tables/v5.csv}\vfive
\pgfplotstableread[col sep = comma]{tables/v6.csv}\vsix

\textbf{Velocity Profiles}
\begin{figure}[h]
\begin{subfigure}{0.3\linewidth}
\begin{tikzpicture}[scale=0.435]
  \begin{axis}
    [
    title={},
    scale only axis,
    %legend pos = outer north east,
    xlabel=r/R (mm), 
    ylabel=u/U (m/s),
    xmin = -0.006,
    xmax = 0.006,
    ymin = 0,
    ymax = 1.2,
    %x dir=reverse,
    y dir=reverse,
    %xmajorgrids=true,
    grid style=dashed,
    ]
    \addplot[domain=1:1e4,color=blue, smooth, thick] table[x = x, y = vz]{\vone};
    \addplot[domain=1:1e4,color=orange, smooth, thick] table[x = x, y = va]{\vone};
    \addplot[domain=1:1e4,color=green, smooth, thick] table[x = x, y = vb]{\vone};
    \addplot[domain=1:1e4,color=red, smooth, thick] table[x = x, y = vc]{\vone};
    \legend{Coarse, $M_{1}$, $M_{2}$, $M_{3}$}
    \legend{}
  \end{axis}
\end{tikzpicture}
\caption{} \label{fig:}
\end{subfigure}
\begin{subfigure}{0.3\linewidth}
\begin{tikzpicture}[scale=0.435]
  \begin{axis}
    [
    title={},
    scale only axis,
    %legend pos = outer north east,
    xlabel=r/R (mm), 
    ylabel=u/U (m/s),
    xmin = -0.006,
    xmax = 0.006,
    ymin = 0,
    ymax = 1.2,
    %x dir=reverse,
    y dir=reverse,
    %xmajorgrids=true,
    grid style=dashed,
    ]
    \addplot[domain=1:1e4,color=blue, smooth, thick] table[x = x, y = vz]{\vtwo};
    \addplot[domain=1:1e4,color=orange, smooth, thick] table[x = x, y = va]{\vtwo};
    \addplot[domain=1:1e4,color=green, smooth, thick] table[x = x, y = vb]{\vtwo};
    \addplot[domain=1:1e4,color=red, smooth, thick] table[x = x, y = vc]{\vtwo};
    \legend{Coarse, $M_{1}$, $M_{2}$, $M_{3}$}
    \legend{}
  \end{axis}
\end{tikzpicture}
\caption{} \label{fig:}
\end{subfigure}
\centering
\begin{subfigure}{0.3\linewidth}
\begin{tikzpicture}[scale=0.435]
  \begin{axis}
    [
    title={},
    scale only axis,
    legend pos = outer north east,
    xlabel=u/U (m/s), 
    ylabel=r/R (mm),
    xmin = 0,
    xmax = 1.4,
    ymin = -0.0265,
    ymax = -0.036,
    x dir=reverse,
    y dir=reverse,
    %xmajorgrids=true,
    grid style=dashed,
    ]
    \addplot[domain=1:1e4,color=blue, smooth, thick] table[x = vz, y = z]{\vthree};
    \addplot[domain=1:1e4,color=orange, smooth, thick] table[x = va, y = z]{\vthree};
    \addplot[domain=1:1e4,color=green, smooth, thick] table[x = vb, y = z]{\vthree};
    \addplot[domain=1:1e4,color=red, smooth, thick] table[x = vc, y = z]{\vthree};
    \legend{Coarse, $M_{1}$, $M_{2}$, $M_{3}$}
    %\legend{}
  \end{axis}
\end{tikzpicture}
\caption{} \label{fig:}
\end{subfigure}
\begin{subfigure}{0.3\linewidth}
\begin{tikzpicture}[scale=0.435]
  \begin{axis}
    [
    title={},
    scale only axis,
    %legend pos = outer north east,
    xlabel=u/U (m/s), 
    ylabel=r/R (mm),
    xmin = 0,
    xmax = 1.4,
    ymin = -0.031,
    ymax = -0.042,
    x dir=reverse,
    y dir=reverse,
    %xmajorgrids=true,
    grid style=dashed,
    ]
    \addplot[domain=1:1e4,color=blue, smooth, thick] table[x = vz, y = z]{\vfour};
    \addplot[domain=1:1e4,color=orange, smooth, thick] table[x = va, y = z]{\vfour};
    \addplot[domain=1:1e4,color=green, smooth, thick] table[x = vb, y = z]{\vfour};
    \addplot[domain=1:1e4,color=red, smooth, thick] table[x = vc, y = z]{\vfour};
    \legend{Coarse, $M_{1}$, $M_{2}$, $M_{3}$}
    \legend{}
  \end{axis}
\end{tikzpicture}
\caption{} \label{fig:}
\end{subfigure}
\begin{subfigure}{0.3\linewidth}
\begin{tikzpicture}[scale=0.435]
  \begin{axis}
    [
    title={},
    scale only axis,
    %legend pos = outer north east,
    xlabel=u/M (m/s), 
    ylabel=r/R (mm),
    xmin = 0,
    xmax = 1.4,
    ymin = -0.031,
    ymax = -0.042,
    x dir=reverse,
    y dir=reverse,
    %xmajorgrids=true,
    grid style=dashed,
    ]
    \addplot[domain=1:1e4,color=blue, smooth, thick] table[x = vz, y = z]{\vfive};
    \addplot[domain=1:1e4,color=orange, smooth, thick] table[x = va, y = z]{\vfive};
    \addplot[domain=1:1e4,color=green, smooth, thick] table[x = vb, y = z]{\vfive};
    \addplot[domain=1:1e4,color=red, smooth, thick] table[x = vc, y = z]{\vfive};
    \legend{Coarse, $M_{1}$, $M_{2}$, $M_{3}$}
    \legend{}
  \end{axis}
\end{tikzpicture}
\caption{} \label{fig:}
\end{subfigure}
\begin{subfigure}{0.3\linewidth}
\begin{tikzpicture}[scale=0.435]
  \begin{axis}
    [
    title={},
    scale only axis,
    %legend pos = outer north east,
    xlabel=u/U (m/s), 
    ylabel=r/R (mm),
    xmin = 0,
    xmax = 1.4,
    ymin = -0.031,
    ymax = -0.042,
    x dir=reverse,
    y dir=reverse,
    %xmajorgrids=true,
    grid style=dashed,
    ]
    \addplot[domain=1:1e4,color=blue, smooth, thick] table[x = vz, y = z]{\vsix};
    \addplot[domain=1:1e4,color=orange, smooth, thick] table[x = va, y = z]{\vsix};
    \addplot[domain=1:1e4,color=green, smooth, thick] table[x = vb, y = z]{\vsix};
    \addplot[domain=1:1e4,color=red, smooth, thick] table[x = vc, y = z]{\vsix};
    \legend{Coarse, $M_{1}$, $M_{2}$, $M_{3}$}
    \legend{}
  \end{axis}
\end{tikzpicture}
\caption{} \label{fig:}
\end{subfigure}
\caption{} \label{fig:}
\end{figure}
\end{document}

another clue might be that I also get the error, underneath those 4 problematic graphs, which is I am assuming is the problem

enter image description here

I have googled it, but can find nothing

sorry I would upload excel files, but there doesn't seem to be a way to upload these safely on here

5
  • I can't compile but it seems there's a x value missing?\addplot[domain=1:1e4,color=orange, smooth, thick] table[x = , y = va]{\vtwo}; Nov 16, 2017 at 2:21
  • ah my bad, copy paste error, same as others, just another x=x
    – nashc
    Nov 16, 2017 at 2:24
  • I opened it up in another text editor to get a better understanding of the error that pops up "Axis range for axis y is approximately empty; enlarging it (it is [-0.05:-1.0000000000])" "Tick computation for direction y failed; there are always too few tick labels (try min ticks has already been advanced to 18)"\ for those same lines 120/176 etc
    – nashc
    Nov 16, 2017 at 2:30
  • Maybe it's easiest to re-scale your data so the yrange is -.265 to -3.6 (image v3) Nov 16, 2017 at 2:38
  • Thanks man, just multiplied my axis by factors of 10^x, graph came out correctly
    – nashc
    Nov 16, 2017 at 3:56

1 Answer 1

1

Okay, I have found out that yes its better to rescale the offending axis, as pgfplots has an issue with small data ranges. I literally just multiplied my y-axis by 1000 bring it into non decimal numbers.

link to the known issue https://github.com/matlab2tikz/matlab2tikz/issues/970

credit goes to Henk, thanks

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .