6

I'd like to add markers to my plots only at certain y levels. How to do this for certain x levels is obvious, I didn't manage to do it inversley though.

What I have (equi-x):

enter image description here

What I want is something like this (equi-y):

enter image description here

My code:

\documentclass[10pt,a4paper,oneside]{scrreprt}
\usepackage{tikz}                   
\usepackage{pgfplots}           
\pgfplotsset{compat=1.8}

\begin{document}
\begin{tikzpicture} 
\begin{semilogyaxis}[
    cycle list name=exotic,
    xlabel=$E_S/N_0\;(dB)$,
    ylabel=$BER\;(\%)$,
    ytick={0.0001,0.01,1,100},
    xmin=0,
    xmax=40,
    ymin=1e-4,
    ymax=100,
    legend pos=outer north east,
    legend cell align=left,
    grid=major,                                             
    height=6cm,
    width=0.8\textwidth
]           

%% READ DATA
\pgfplotstableread[
    header=false,
    comment chars=!
]
{ber.dat}\berdata

%% PLOT DATA
% Workaround for line colors, doesn't work with \foreach
\addplot +[smooth, mark repeat={10}, line width = 1.0pt] table[x index=0,   y index=1]  {\berdata};
\addplot +[smooth, mark repeat={10}, line width = 1.0pt] table[x index=0,   y index=2]  {\berdata};
\addplot +[smooth, mark repeat={10}, line width = 1.0pt] table[x index=0,   y index=4]  {\berdata};
\addplot +[smooth, mark repeat={10}, line width = 1.0pt] table[x index=0,   y index=5]  {\berdata};
\addplot +[smooth, mark repeat={10}, line width = 1.0pt] table[x index=0,   y index=7]  {\berdata};
\addplot +[smooth, mark repeat={10}, line width = 1.0pt] table[x index=0,   y index=6]  {\berdata};
\addplot +[smooth, mark repeat={10}, line width = 1.0pt] table[x index=0,   y index=8]  {\berdata};
\addplot +[smooth, mark repeat={10}, line width = 1.0pt] table[x index=0,   y index=9]  {\berdata};
\addplot +[smooth, mark repeat={10}, line width = 1.0pt] table[x index=0,   y index=10] {\berdata};

%% LEGEND
\legend{BPSK,QPSK,16-QAM,16-QAM,32-QAM,64-QAM,256-QAM,1024-QAM,4096-QAM}
\end{semilogyaxis}
\end{tikzpicture}
\end{document}

ber.dat can be downloaded here, if you like: https://www.dropbox.com/s/8lqx7bjfokpx274/ber.dat

Edit1:

Managed to find a workaround:

enter image description here

By calculating the inverse function values with MATLAB and plotting them on top.

%% READ DATA
\pgfplotstableread[
    header=false,
    comment chars=!
]
{plotdata/ber_markers.dat}\bermarkers       

\pgfplotsset{cycle list shift=-9}

\addplot +[smooth, only marks, line width = 1.0pt] table[x index=1, y index=0]  {\bermarkers};                  
%\addplot +[smooth, only marks, line width = 1.0pt] table[x index=0,    y index=3]  {\bermarkers};
\addplot +[smooth, only marks, line width = 1.0pt] table[x index=2, y index=0]  {\bermarkers};
\addplot +[smooth, only marks, line width = 1.0pt] table[x index=4, y index=0]  {\bermarkers};
\addplot +[smooth, only marks, line width = 1.0pt] table[x index=5, y index=0]  {\bermarkers};
\addplot +[smooth, only marks, line width = 1.0pt] table[x index=7, y index=0]  {\bermarkers};
\addplot +[smooth, only marks, line width = 1.0pt] table[x index=6, y index=0]  {\bermarkers};
\addplot +[smooth, only marks, line width = 1.0pt] table[x index=8, y index=0]  {\bermarkers};
\addplot +[smooth, only marks, line width = 1.0pt] table[x index=9, y index=0]  {\bermarkers};
\addplot +[smooth, only marks, line width = 1.0pt] table[x index=10,y index=0]  {\bermarkers};  

Christian: Thanks for your work by the way, it is extremely useful.

Bobyandbob
  • 4,899
user37201
  • 263
  • 1
    If pgfplots doesn’t offer a good way to place marks at equi-y points, you can use intersections as in my answer to Align pinned nodes in PGFplots to place simple nodes. You will need to set the options (color) manually, though, I guess. — Or you add another series of plots where you explicitly use the values at equi-y. – Qrrbrbirlbel Oct 04 '13 at 19:48
  • 2
    To my knowledge, pgfplots has no builtin feature for this task. Aside from that: If I were to read and understand your plots, I would assume that every marker corresponds to some data point (measurement). If you interpolate and then place markers at visually appealing intersections, it might seem as if you want to hide information. After all, the interpolation between data points is always based on some assumption on your underlying function. In your case, this function is nonlinear and thus complicated. That said: are you sure that you really want to proceed in this direction? – Christian Feuersänger Oct 04 '13 at 21:21
  • 1
    Thanks for your hints so far. These graphs come from analytically given functions and can be calculated at any point. They have been calculated with MATLAB externally due to their complexity. – user37201 Oct 04 '13 at 21:50
  • 1
    I see. Perhaps the feature which allows to place nodes on X% of a plot could be modified to place marks at absolute x or y values. Hm... would be an interesting (and probably simple) feature request for pgfplots. – Christian Feuersänger Oct 05 '13 at 06:57

0 Answers0