# Overlapping transparent impulses (ycomb) with pgfplots?

Consider the following 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}

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,
]

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}

With the code as is, evince renders the pdf as (click for full size img):

with the "% global" opacity enabled, the pdf is rendered as:

... however, what I want is that the "impulses" are transparent, so they get a more intense color when they overlap - and neither of the above images shows that: the global one is, well, global - and the "local" one applied to the mark style seems ignored?

Also, any way to get the marks (circles) of the impulses to be completely filled? (it looks as if there is a hole inside, if you look closely at the full size images)

Any way to achieve what I want? The log file says:

Package: pgfplots 2011/12/29 v1.5.1 (git show 1.5.1-4-g53e640f )

-
Your pgfplots is quite outdated. Regardless of the solution, you should try an update. Also mark options is relevant here. –  percusse Mar 17 at 10:20
Thanks @percusse - an update is planned, but cannot be done in the near future. Also, I think I already use mark options in the code? Cheers! –  sdaau Mar 17 at 10:22

Well, I got a sort of a hack to work: first, I tried ybar style, which is sort of similar - but it seems it too applies opacity/transparency on the graph as a whole - not to individual bars/lines.

So I tried looping through the table data and drawing individual lines with opacity - and that finally seems to have worked; the relevant changes in the above MWE are:

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

\def\opac{0.4}

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 ;

%   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}
...

... and the output is:

I left the "only marks" style just for easier visual comparison of overlaid color. The only thing that bothers me now is a visible stroke around the circular marks, but that's no biggie ...

-