在图中填充图例标记

在图中填充图例标记

如何填充标记,例如斑马线:与我上传的图片中绘制的相同。谢谢 在此处输入图片描述

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepackage{etoolbox}
\begin{document}

\begin{tikzpicture}
% f1
\begin{axis}[
color=black,
scale only axis,
xmin=0,
xmax=168,
%xtick={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24},
xtick={0,12,24,48,72,168}, %%%<------------- here
xlabel=\ {Time},
ymin=0,
ymax=10,
ytick={0,1,2,3,4,5,6,7,8,9,10},% your code
yticklabels={0,1,2,3,4,5,6,7,8,9,10},% your code
ylabel=\ {log(Cfu/cm$^{2}$)},
y axis line style={black},
ytick style={black},
yticklabel style={black},
axis x line*=bottom,
axis y line*=left,
tick align = outside,]
\addplot [black, fill=white, mark=square*]
        table[row sep=crcr]{
            0 7.005\\
2 7\\
4 7.035\\
6 7.005\\
8 7.015\\
10 7.025\\
12 6.98\\
14 6.985\\
16 6.94\\
18 6.89\\
20 6.81\\
22 6.63\\
24 6.46\\
48 5.945\\
72 6.445\\
168 6.845\\};         
\end{axis}
\end{tikzpicture}%
\end{document} 

答案1

使用\usetikzlibrary{patterns}\pgfdeclareplotmark

  \documentclass[border=5mm]{standalone}
    \usepackage{pgfplots}
    \pgfplotsset{compat=newest}
    \usepackage{etoolbox}
    \usetikzlibrary{patterns}
    \pgfdeclareplotmark{*)}
      {\draw[pattern=north west lines, pattern color=blue] (-1,-1) rectangle (1,1);}
    \begin{document}

    \begin{tikzpicture}
    % f1
    \begin{axis}[
    color=black,
    scale only axis,
    xmin=0,
    xmax=168,
    %xtick={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24},
    xtick={0,12,24,48,72,168}, %%%<------------- here
    xlabel=\ {Time},
    ymin=0,
    ymax=10,
    ytick={0,1,2,3,4,5,6,7,8,9,10},% your code
    yticklabels={0,1,2,3,4,5,6,7,8,9,10},% your code
    ylabel=\ {log(Cfu/cm$^{2}$)},
    y axis line style={black},
    ytick style={black},
    yticklabel style={black},
    axis x line*=bottom,
    axis y line*=left,
    tick align = outside,]

    \addplot [black, fill=white, mark=*)]
            table[row sep=crcr]{
                0 7.005\\
    2 7\\
    4 7.035\\
    6 7.005\\
    8 7.015\\
    10 7.025\\
    12 6.98\\
    14 6.985\\
    16 6.94\\
    18 6.89\\
    20 6.81\\
    22 6.63\\
    24 6.46\\
    48 5.945\\
    72 6.445\\
    168 6.845\\};         
    \end{axis}
    \end{tikzpicture}%
    \end{document} 

在此处输入图片描述

相关内容