Überlappende transparente Impulse (Ycomb) mit PGFPlots?

Überlappende transparente Impulse (Ycomb) mit PGFPlots?

Betrachten Sie das folgende 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}

Mit dem vorliegenden Code evincewird das PDF wie folgt gerendert (klicken Sie, um das Bild in voller Größe anzuzeigen):

test-1.png

Wenn die Deckkraft „% global“ aktiviert ist, wird das PDF wie folgt gerendert:

test-2.png

... ich möchte jedoch, dass die „Impulse“ transparent sind, sodass sie bei Überlappung eine intensivere Farbe erhalten – und dies zeigt keines der obigen Bilder: Das globale ist, nun ja, global – und das „lokale“, das auf den Markierungsstil angewendet wird, scheint ignoriert zu werden?

Gibt es außerdem eine Möglichkeit, die Markierungen (Kreise) der Impulse vollständig auszufüllen? (Wenn man sich die Bilder in voller Größe genau ansieht, sieht es so aus, als wäre darin ein Loch.)

Gibt es eine Möglichkeit, das zu erreichen, was ich will? In der Protokolldatei steht:

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

Antwort1

Nun, ich habe eine Art Hack zum Laufen gebracht: Zuerst habe ich ybar„Stil“ ausprobiert, was ziemlich ähnlich ist – aber anscheinend wendet es auch hier Opazität/Transparenz auf das Diagramm als Ganzes an – nicht auf einzelne Balken/Linien.

Also habe ich versucht, die Tabellendaten zu durchlaufen und einzelne Linien mit Deckkraft zu zeichnen – und das scheint endlich funktioniert zu haben; die relevanten Änderungen im obigen MWE sind:

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

... und die Ausgabe ist:

test-3.png

Ich habe den Stil „nur Markierungen“ beibehalten, um den visuellen Vergleich der überlagerten Farben zu erleichtern. Das einzige, was mich jetzt stört, ist ein sichtbarer Strich um die kreisförmigen Markierungen, aber das ist keine große Sache ...

verwandte Informationen