
pgfplot でスキップ座標と各 n 番目のコマンドを組み合わせた場合の予想される動作は何ですか。次のコードを使用すると、ポイント (250, 30) と (300, 40) を含むプロットと、ポイント (250, 14) と (300, 18) を含む別のプロットが得られると予想されます。
代わりに、最初のプロットは正しいですが、2 番目のプロットでは、2 つのオプションが一緒に機能しないかのように、ポイント (300, 40) のみが生成されます。
\usepackage{filecontents}
\begin{filecontents}{results.data}
Move Size Factor
A 250 30
B 250 14
C 250 10
A 300 40
B 300 18
C 300 7
\end{filecontents}
\begin{figure}[!ht]
\centering
\pgfplotsset{tick label style={font=\small}}
\begin{tikzpicture}
\begin{axis}[ scale only axis, yticklabel style={inner sep=0pt, align=right, xshift=-0.1cm} ]
\addplot+[color=blue,only marks,mark=*,mark options=solid, mark options={scale=0.4},each nth point={3}]table[x=Size,y=Factor]{results.data};
\end{axis}
\end{tikzpicture}
\end{figure}
\begin{figure}[!ht]
\centering
\pgfplotsset{tick label style={font=\small}}
\begin{tikzpicture}
\begin{axis}[ scale only axis, yticklabel style={inner sep=0pt, align=right, xshift=-0.1cm},
,skip coords between index={0}{1}
]
\addplot+[color=blue,only marks,mark=*,mark options=solid, mark options={scale=0.4},each nth point={3}]table[x=Size,y=Factor]{results.data};
\end{axis}
\end{tikzpicture}
\end{figure}
答え1
「期待していた」ではなく「期待していた」という意味だと思います。を追加しeach nth point
ます。これx filter
は、n番目以外のすべての入力座標を破棄します(マニュアルに記述されているように)。そして、次のものを追加しますx filter
。skip coords between index={0}{1}
加えて最初のポイントをフィルタリングします。したがって、最初に描画されたポイントがなくなることを除いて、前と同じ結果が得られます。
x filter
したがって、必要なことを行うには、独自のものを作成する必要があると思います。別の可能性としては、 および 機能を使用して、必要なことを実現することです。このアプローチmark repeat
のmark phase
欠点は、決定された軸制限 ( xmin
、、、) によって、「表示されない」ポイントも考慮されることです。これが気になる場合は、値を手動で設定する必要があります。xmax
ymin
ymax
% used PGFPlots v1.14
\begin{filecontents}{results.data}
Move Size Factor
A 250 30
B 250 14
C 250 10
A 300 40
B 300 18
C 300 7
\end{filecontents}
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
only marks,
]
\addplot+ [
each nth point={3},
] table [x=Size,y=Factor] {results.data};
\addplot+ [
mark=square,
mark repeat={3},
] table [x=Size,y=Factor] {results.data};
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}[
only marks,
]
\addplot+ [
each nth point={3},
skip coords between index={0}{1},
] table [x=Size,y=Factor] {results.data};
\addplot+ [
mark=square,
mark repeat={3},
mark phase=2,
] table [x=Size,y=Factor] {results.data};
\end{axis}
\end{tikzpicture}
\end{document}