透明なインパルス (ycomb) を pgfplots と重ね合わせますか?

透明なインパルス (ycomb) を pgfplots と重ね合わせますか?

次の MWE を検討してください。

\documentclass[%
  12pt,
  journal,
  twoside,
  draftcls,
  letterpaper,
]{IEEEtran}

\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usepackage{tikz}
\usetikzlibrary{intersections} %% named intersections "I do not know the key '/tikz/name path global'"


\begin{document}

\pgfplotstableread[col sep=&,row sep=\\]{
  0.0159779999812599 & 0.00398599999607541 \\
  0.0240009999834001 & 0.00802300000214018 \\
  0.0240489999996498 & 4.80000162497163e-05 \\
  0.0280280000006314 & 0.00397900000098161 \\
}\mytable


\begin{tikzpicture}

\begin{scope}
\begin{axis}[
  title={\small my data},
  title style={at={(0.5,0.9)},anchor=center},
  clip=true,
  axis x line=middle,
  axis y line=middle,
  y axis line style=-,
  xmin = 2e-3,
  xmax = 38e-3,
  ymin = 0,
  ymax = 1.5,
  xlabel={$t$\,[ms]},
  xlabel style={at={(axis description cs:1.01,+0.0)},anchor=west},
  ylabel={}, %{$U$\,[V]},
  ylabel style={at={(axis description cs:-0.02,1.01)},anchor=south},
  xtick=data,
  scaled x ticks=base 10:3,
  xtick scale label code/.code={},
  x tick label style={
    rotate=-45,
    anchor=west,
    /pgf/number format/fixed,
    /pgf/number format/fixed zerofill,
    /pgf/number format/precision=3,
  },
  ymajorticks=false,
  yminorticks=false,
  tick label style={font=\small,},
  legend cell align=left,
  legend pos=outer north east,
]

\addplot[
  name path global=afunc,
  ycomb,
  draw=black,
%   opacity=0.2, % global
  mark=*, mark options={
    draw=black,
    fill=black,
    opacity=0.2, % on mark
  },
  line width=2pt,
]
  table[x index = 0,y expr=1] \mytable ;

\end{axis}
\end{scope}

\end{tikzpicture}
\end{document}

コードをそのまま使用すると、evincePDF は次のようにレンダリングされます (クリックするとフルサイズの画像が表示されます)。

テスト1.png

「% global」不透明度を有効にすると、PDF は次のようにレンダリングされます。

テスト2.png

...しかし、私が望んでいるのは、「インパルス」が透明で、重なり合ったときにより強い色になることです。そして、上記の画像のどちらにもそれが示されていません。グローバルなものは、まさにグローバルですが、マーク スタイルに適用された「ローカル」なものは無視されているようです。

また、インパルスのマーク(円)を完全に埋める方法はありますか?(フルサイズの画像をよく見ると、内部に穴があるように見えます)

希望どおりの結果を得る方法はありますか? ログ ファイルには次のように書かれています:

パッケージ: pgfplots 2011/12/29 v1.5.1 (git show 1.5.1-4-g53e640f)

答え1

さて、私はある種のハックを機能させました。まず、ybar似たようなスタイルを試しましたが、これも個々のバー/線ではなく、グラフ全体に不透明度/透明度を適用するようです。

そこで、テーブル データをループして、不透明度のある個別の線を描画してみました。そして、ようやくうまくいったようです。上記の MWE の関連する変更点は次のとおりです。

...
\usepackage{pgfplotstable}
...
]

\def\opac{0.4}

\addplot[
  name path global=afunc,
  only marks, %ycomb,
  draw=none, %black,
  %opacity=\opac, % global
  mark=*, mark options={
    draw=none, %black,
    %fill=black,
    opacity=\opac, % on mark; both stroke and fill (and stroke will overlap fill - twice the opacity!? even with draw=none?)
  },
  %line width=2pt, % also changes the line around the mark!
]
  table[x index = 0,y expr=1] \mytable ;


% \addplot[
%   name path global=afuncb,
%   ybar,
%   bar width=2pt,
%   %fill=black,
%   %draw=none,
%   opacity=0.4,
% ]
%   table[x index = 0,y expr=1] \mytable ;


\pgfplotstableforeachcolumnelement{0}\of\mytable\as\cx{%
  % \node{I have now cell element ‘\cx’ at row index ‘\pgfplotstablerow’;\par};
  \edef\temp{ %
    \noexpand\draw[%
      line width=2pt, %semithick,
      draw=black,%
      fill=none,%
      opacity=\opac,%
    ] ({axis cs:\cx,0}) -- ({axis cs:\cx,1}); %
  }
  \temp
}

\end{axis}
...

...出力は次のようになります。

テスト3.png

重ね合わせた色を視覚的に比較しやすくするために、「マークのみ」スタイルを残しました。唯一気になるのは、円形のマークの周りに線が見えることですが、これは大した問題ではありません...

関連情報