
私の質問は、これです、これはまだ答えが出されておらず、このより一般的な定式化ではさらに注目される可能性があります。
横軸、縦軸の点の束に欠損値や無限値が含まれていると仮定します。これらの値は、例えば、nan
以下で想定しているように縦軸に直接入力したり、範囲外の値をテストしたりすることで、何らかの方法でフラグ付けできます。上記の質問それを単純に修正して\listplot
プロットすることはできますか?欠損値や無限値のない連続した値の各グループごとに異なる曲線?
以下は図です。まず、欠損値のないデータを黒線でプロットします。次に、欠損値のある同じポイントを示します。再定義のトリックnan
(または任意のユーザー定義フラグ) を使用して、欠損値を簡単に取り除きます。ただし、赤のプロットは、線が周囲の値を接続しているため、満足のいくものではありません。青では、\listplot
自動的に取得したい結果を「手動で」(つまり、いくつかの を呼び出して) プロットします。孤立したポイントは単純に破棄できることに注意してください。
\begin{pspicture}
\psgrid[subgriddiv=1,griddots=10,gridlabels=7pt](0,0)(10,4)
\savedata{\data}[1 2 2 1 3 1 4 2 5 1 6 2 7 3 8 1 9 2 10 3]
\listplot[linecolor=black]{\data}
\savedata{\data}[1 2 2 1 3 1 4 nan 5 nan 6 2 7 3 8 nan 9 2 10 nan]
\pstVerb{/nan { pop } def} % nice trick to get rid of nan values
\pstScalePoints(1.,1.){}{.1 add} % some vertical shift to allow comparison
\listplot[linecolor=red]{\data}
\pstScalePoints(1.,1.){}{.2 add} % some vertical shift to allow comparison
\savedata{\data}[1 2 2 1 3 1]
\listplot[linecolor=blue]{\data}
\savedata{\data}[6 2 7 3]
\listplot[linecolor=blue]{\data}
% the following goes wrong because isolated point is completed with (0,0)
% \savedata{\data}[9 2]
% \listplot[linecolor=blue]{\data}
\end{pspicture}
答え1
pgfplots
には、オプション とともにこの機能が組み込まれていますunbounded coords=jump
。
データがどこから来たのか分かりません。もし、そのデータがdata.dat
次の形式のテキストファイルにあるなら、
1 2
2 1
3 1
4 nan
etc.
\addplot
これをコマンド内で直接 として使用できます\addplot [unbounded coords=jump] table {data.dat};
。ファイルに複数の列がある場合は、 を使用して、使用する列を選択できます (例: ) \addplot table[x index=0,y index=2] {data.dat};
。
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\pgfplotstableread{ % read in data
1 2
2 1
3 1
4 nan
5 nan
6 2
7 3
8 nan
9 2
10 nan
}\data
\begin{document}
\begin{tikzpicture}
\begin{axis}[
% axis limits
xmin=0,xmax=10,ymin=0,ymax=4,
% size of plot
% scale only axis means that 10cm is only the axis, not the ticks
width=10cm,height=4cm,scale only axis,
% add grid
grid=major
]
% plot data with gaps in line
\addplot [blue,very thick,unbounded coords=jump] table {\data};
% default setting, no gaps
\addplot [red,dashed] table {\data};
\end{axis}
\end{tikzpicture}
\end{document}
答え2
\documentclass{scrartcl}
\usepackage{pst-plot}
\begin{document}
\begin{pspicture}[showgrid](10,4)
\savedata{\data}[1 2 2 1 3 1 4 2 5 1 6 2 7 3 8 1 9 2 10 3]
\listplot{\data}
\listplot[linecolor=blue,linewidth=2pt,nStart=1,nEnd=3]{\data}
\listplot[linecolor=blue,linewidth=2pt,nStart=6,nEnd=7]{\data}
\end{pspicture}
\end{document}