隐藏刻度值导致 pgfplot 错位

隐藏刻度值导致 pgfplot 错位

我试图将这些图表显示为 2 x 3 网格,过去我已经成功做到了这一点,然而这一次,图表 (c) (d) (e) 和 (f) 的 y 刻度都缺失了,导致它们在网格中未对齐,并且它们的 y 标签出现在图表内部。

这是其外观的图像。

在此处输入图片描述

\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}

另一个线索可能是,我也得到了错误,在这 4 个有问题的图表下面,我假设这就是问题所在

在此处输入图片描述

我已经在谷歌上搜索过了,但什么也没找到

抱歉,我想上传 excel 文件,但这里似乎没有安全上传这些文件的方法

答案1

好的,我发现重新缩放有问题的轴是更好的选择,因为 pgfplots 在处理小数据范围时会出现问题。我实际上只是将 y 轴乘以 1000,将其转换为非十进制数字。

已知问题链接 https://github.com/matlab2tikz/matlab2tikz/issues/970

感谢 Henk

相关内容