LaTeX、Tikz 和 `miter`

LaTeX、Tikz 和 `miter`

因此,我想在我的文档中创建图形(为了简单起见,我在 Matlab 中创建并使用 导出matlab2tikz),这些图形具有与文档中正文相同的格式、字体等。

matlab2tikz创建此代码,使用表格绘制图形。问题在于,图形是一个分段定义的函数,图形的两个部分相交的地方存在一个“间隙”,我想消除这个间隙。

我尝试使用miter,但不幸的是我无法让它工作。

有人可以给我提示吗?

添加 MWE:

    \documentclass[11pt]{scrartcl}
    \usepackage[utf8x]{inputenc}
    \usepackage{amsmath}
    \usepackage{graphicx}
    \usepackage{lmodern}
    \usepackage{mathtools}
    \usepackage{amsfonts}
    \usepackage{tikz}
    \usepackage{pgfplots}

    \begin{document}


    \begin{figure}

    % This file was created by matlab2tikz.
    %
    \begin{tikzpicture}[%
    line join = miter
    ]

    \begin{axis}[%
    width=0.856\textwidth,
    height=0.54\textwidth,
    at={(0\textwidth,0\textwidth)},
    scale only axis,
    xmin=0,
    xmax=4,
    xlabel style={font=\color{white!15!black}},
    xlabel={Periodo $T\,[s]$},
    ymin=0,
    ymax=0.09,
    ylabel style={font=\color{white!15!black}},
    ylabel={$S_d\,[g]$},
    axis background/.style={fill=white},
    axis x line*=bottom,
    axis y line*=left,
    scaled y ticks = false,
    y tick label style={/pgf/number format/.cd, fixed, fixed zerofill,precision=2, /tikz/.cd}
    ]
    \addplot [color=black, line width=1.0pt, forget plot]
      table[row sep=crcr]{%
    0   0.036\\
    0.0109  0.0411876\\
    0.0218  0.0463752\\
    0.0327  0.0515628\\
    0.0436  0.0567504\\
    0.0545  0.061938\\
    0.0654  0.0671256\\
    0.0763  0.0723132\\
    0.0872  0.0775008\\
    0.0981  0.0826884\\
    0.109   0.087876\\
    };
    \addplot [color=black, line width=1.0pt, forget plot]
      table[row sep=crcr]{%
    0.109   0.087876\\
    0.327   0.087876\\
    };
    \addplot [color=black, line width=1.0pt, forget plot]
      table[row sep=crcr]{%
    0.327   0.087876\\
    0.3967  0.0724362288883287\\
    0.4664  0.0616111749571183\\
    0.5361  0.0536009177392277\\
    0.6058  0.0474338923737207\\
    0.6755  0.0425395292376018\\
    0.7452  0.0385607246376811\\
    0.8149  0.0352625500061357\\
    0.8846  0.0324841193759891\\
    0.9543  0.0301115498270984\\
    1.024   0.02806196484375\\
    1.0937  0.0262736143366554\\
    1.1634  0.0246995461578133\\
    1.2331  0.0233034238910064\\
    1.3028  0.0220566871354007\\
    1.3725  0.0209365770491803\\
    1.4422  0.0199247344335044\\
    1.5119  0.0190061855942853\\
    1.5816  0.0181685963581184\\
    1.6513  0.0174017150124145\\
    1.721   0.0166969506101104\\
    };
    \addplot [color=black, line width=1.0pt, forget plot]
      table[row sep=crcr]{%
    1.721   0.0166969506101104\\
    1.83599380839719    0.0146708906007282\\
    1.95098761679437    0.0129924147965453\\
    2.06598142519156    0.0115863349149064\\
    2.18097523358874    0.0103967460331488\\
    2.29596904198593    0.00938138258417489\\
    2.41096285038311    0.00850781163737593\\
    2.5259566587803 0.00775081041470584\\
    2.64095046717749    0.00709052498321459\\
    2.75594427557467    0.00651115507750974\\
    2.87093808397186    0.006\\
    };
    \addplot [color=black, line width=1.0pt, forget plot]
      table[row sep=crcr]{%
    2.87093808397186    0.006\\
    4   0.006\\
    };
    \end{axis}
    \end{tikzpicture}

    \end{figure}



    \end{document}

答案1

你不能只注释掉多余的\addplots 并使其成为一个单一的情节吗?

IE,

\documentclass[11pt]{scrartcl}
\usepackage[utf8x]{inputenc}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{lmodern}
\usepackage{mathtools}
\usepackage{amsfonts}
\usepackage{tikz}
\usepackage{pgfplots}

\begin{document}


\begin{figure}

% This file was created by matlab2tikz.
%
\begin{tikzpicture}[%
line join = miter
]

\begin{axis}[%
width=0.856\textwidth,
height=0.54\textwidth,
at={(0\textwidth,0\textwidth)},
scale only axis,
xmin=0,
xmax=4,
xlabel style={font=\color{white!15!black}},
xlabel={Periodo $T\,[s]$},
ymin=0,
ymax=0.09,
ylabel style={font=\color{white!15!black}},
ylabel={$S_d\,[g]$},
axis background/.style={fill=white},
axis x line*=bottom,
axis y line*=left,
scaled y ticks = false,
y tick label style={/pgf/number format/.cd, fixed, fixed zerofill,precision=2, /tikz/.cd}
]
\addplot [color=black, line width=1.0pt, forget plot]
  table[row sep=crcr]{%
0   0.036\\
0.0109  0.0411876\\
0.0218  0.0463752\\
0.0327  0.0515628\\
0.0436  0.0567504\\
0.0545  0.061938\\
0.0654  0.0671256\\
0.0763  0.0723132\\
0.0872  0.0775008\\
0.0981  0.0826884\\
0.109   0.087876\\
%};
%\addplot [color=black, line width=1.0pt, forget plot]
 % table[row sep=crcr]{%
0.109   0.087876\\
0.327   0.087876\\
%};
% \addplot [color=black, line width=1.0pt, forget plot]
 % table[row sep=crcr]{%
0.327   0.087876\\
0.3967  0.0724362288883287\\
0.4664  0.0616111749571183\\
0.5361  0.0536009177392277\\
0.6058  0.0474338923737207\\
0.6755  0.0425395292376018\\
0.7452  0.0385607246376811\\
0.8149  0.0352625500061357\\
0.8846  0.0324841193759891\\
0.9543  0.0301115498270984\\
1.024   0.02806196484375\\
1.0937  0.0262736143366554\\
1.1634  0.0246995461578133\\
1.2331  0.0233034238910064\\
1.3028  0.0220566871354007\\
1.3725  0.0209365770491803\\
1.4422  0.0199247344335044\\
1.5119  0.0190061855942853\\
1.5816  0.0181685963581184\\
1.6513  0.0174017150124145\\
1.721   0.0166969506101104\\
%   };
%\addplot [color=black, line width=1.0pt, forget plot]
%  table[row sep=crcr]{%
1.721   0.0166969506101104\\
1.83599380839719    0.0146708906007282\\
1.95098761679437    0.0129924147965453\\
2.06598142519156    0.0115863349149064\\
2.18097523358874    0.0103967460331488\\
2.29596904198593    0.00938138258417489\\
2.41096285038311    0.00850781163737593\\
2.5259566587803 0.00775081041470584\\
2.64095046717749    0.00709052498321459\\
2.75594427557467    0.00651115507750974\\
2.87093808397186    0.006\\
%  };
%\addplot [color=black, line width=1.0pt, forget plot]
  %table[row sep=crcr]{%
2.87093808397186    0.006\\
4   0.006\\
};
\end{axis}
\end{tikzpicture}

\end{figure}



\end{document}

这是结果(我截取了其中的一个片段)

在此处输入图片描述

相关内容