pgfplot:根据另一列将 expr 限制到域

pgfplot:根据另一列将 expr 限制到域

我有这个latency.csv文件:

LATENCY,AMNT,IS_MEDIAN,IS_MEAN
0,0,0,0
1,0,0,0
2,1181,0,0
3,11943,1,1
4,1428,0,0

为了突出显示,我想以特殊颜色显示中位数和平均值。我尝试这样做:

\documentclass[a4paper,12pt]{report}

\usepackage{float}
\usepackage{tikz}
\usepackage{pgf}
\usepackage{pgfplots, pgfplotstable}

\begin{document}

\pgfplotstableread[col sep=comma]{latency.csv}\datatable
\begin{figure}[H]
  \centering
  \begin{tikzpicture}
    \pgfplotsset{every tick label/.append style={font=\tiny}}
    \centering
    \begin{axis}[
        ybar,
        ylabel near ticks,
        axis line style = thin,
        grid=major, grid style={gray!30},
        legend style={font=\tiny},
        legend columns=-1,
        legend entries={Long plot title, B, C},
        legend style={/tikz/every even column/.append style={column sep=0.5cm}},
        bar width=.01cm,
        width=\textwidth,
        height=3.5cm,
        xmin = 0,
        xmax = 2000,
        ymin = 0,
        ymax = 350,
        xtick distance = {100},
        ytick distance = {50},
        xlabel={Latency in $\mu$s},
        ylabel = {Amount}],
        \addplot[
          draw=black,
          fill=black
        ] table [
            x={LATENCY},
            y={AMNT},
            restrict expr to domain={y}{3:65535}
          ]{\datatable};
        \addlegendentry{AF-XDP}

        \addplot[
          scatter,
          only marks,
          mark=x,
          color=red,
          scatter/use mapped color={draw=red}
        ] table [
            x={LATENCY},
            y={AMNT},
            restrict expr to domain={y}{1:3}
        ]{\datatable};
        \addlegendentry{Outliers}

        \addplot[
          draw=green,
          fill=green
        ] table [
            x={LATENCY},
            y={AMNT},
            restrict expr to domain={IS_MEDIAN}{1}
          ]{\datatable};
        \addlegendentry{Median}

    \end{axis}
  \end{tikzpicture}
\end{figure}

\end{document}

但是 pgfplot 崩溃了:

"message": "Paragraph ended before \\pgfplots@loc@TMPc was complete.\n<to be read again> \n",

绘制正常的 ybar 图和异常散点图可以正常工作,但不能选择中值。

有什么想法可以实现这一点吗?

我认为问题在于这IS_MEDIAN不是用于绘图的列。不知道如何解决这个问题

相关内容