在 pgfplots 中对曲线进行阴影处理

在 pgfplots 中对曲线进行阴影处理

我正在使用该pgfplots软件包绘制数据图。正如您在下面的图中看到的,我有很多数据点,这使得很难看到拟合度,所以我决定在曲线周围使用阴影。因为我真的不知道该怎么做,所以我只是绘制了两次相同的曲线,但如果有曲线就好了图例中的阴影,这就是为什么我想知道你们是否知道是否可以只用一个\addplot命令来制作像下面这样的阴影曲线?

在此处输入图片描述 这是我目前的代码:

\documentclass[12pt]{article}
\usepackage{tikz}        
\usepackage{pgfplots}

\begin{document}

\begin{figure}
    \begin{tikzpicture}
    \begin{semilogyaxis}[
        width=\textwidth,
        height=10cm,
        xlabel = {time ($\mu$s)},
        ylabel = {intensity (arbitrairy units)},
        xmin = 0, xmax = 40000,
        ymin = 1, ymax = 1000,
        grid = major,
        legend entries = {data points,, exponential fit}]
        \addplot[only marks, color = cyan!55!black, fill = cyan!55!black]
    table[x=x, y=y]{Cr_decay.txt};
        \addplot[line width = 10pt, purple!15!white, mark=none, domain=0:27000, samples=100]{60.8572906687*exp(-0.00104989494035*x) + 1103.66808067*exp(-0.0057771170945*x) + 68.7516215762*exp(-0.000121846421383*x)};
        \addplot[line width = 1pt, purple, mark=none, domain=0:27000, samples=100]{60.8572906687*exp(-0.00104989494035*x) + 1103.66808067*exp(-0.0057771170945*x) + 68.7516215762*exp(-0.000121846421383*x)};
    \end{semilogyaxis}
    \end{tikzpicture}
    \caption{Decay profile of ${\rm ZrGa_2O_4:Cr^{3+}}$}
\end{figure}

\end{document}

顺便说一句,如您所见,我没能找到一条真正适合所有数据点(包括最后几个数据点)的曲线。如果有人有想法,我将不胜感激!文件内容如下Cr_decay.txt

x   y
40  1000
140 620.4374803949
240 388.249619161
340 252.3436684492
440 188.0347927465
540 152.1900006459
640 129.2644173889
740 107.1655884737
840 99.1795604731
940 92.784484609
1040    76.6750671382
1140    80.1133327438
1240    72.2882865133
1340    71.912662383
1440    74.2453971309
1540    64.5611396361
1640    63.1726691299
1740    65.3716796716
1840    68.2282898981
1940    58.2672278979
2040    60.8124577059
2140    62.8980995693
2240    58.9817091229
2340    57.6688104317
2440    57.1085184971
2540    54.0380766257
2640    56.0532300783
2740    47.2908435532
2840    51.320032986
2940    50.0958090225
3040    52.8734950166
3140    51.4874347451
3240    47.8987924023
3340    49.7678418066
3440    46.5477900908
3540    46.9912951962
3640    46.7126501478
3740    46.8128720909
3840    46.7172295938
3940    42.4157712791
4040    43.4295598377
4140    42.4508073278
4240    41.2672725091
4340    40.6780358462
4440    40.2979199148
4540    39.6094034914
4640    39.9061033893
4740    38.8690889321
4840    40.3154050724
4940    39.3863472209
5200    36.9920145417
5700    34.0322517456
6200    31.2127427008
6700    30.2905047181
7200    26.317188909
7700    26.7495905011
8200    24.3472164024
8700    21.9988753845
9200    22.3431609852
9700    19.9922180093
8200    24.3472164024
8700    22.1559889787
9200    20.199760737
9700    19.9698093358
10200   18.3857139463
10700   17.7052309178
11200   16.1514680603
11700   14.8880282455
12200   14.6490907858
12700   15.4595965781
13200   13.8983331126
13700   12.6938528445
14200   12.2781834561
14700   12.0533119287
15400   10.0657425159
16400   9.5230946203
17400   8.2189332898
18400   7.0589248414
19400   6.5894399664
15400   10.0657425159
16400   9.3717119178
17400   8.4447657111
18400   8.2057706562
19400   7.0764500144
20400   6.9399757603
21400   6.5101047216
22400   5.7401233815
23400   5.2964000112
24400   4.9965596909
25400   4.8679345269
26400   4.7276923709
27400   4.3908165383
28400   4.3116313277
29400   4.0522896025
30400   3.7853866719
31400   3.789247713
32400   3.7238386292
33400   3.6726374992
34400   3.3370063442
35400   3.3159653639
36400   3.0725250315
37400   3.1029476642
38400   2.8954786321

提前谢谢您!

答案1

您可以使用double类似

postaction={double=purple,double distance=1pt},

或者简单地

double=purple,double distance=1pt

画出那条宽线。

\documentclass[12pt]{article}
\usepackage{tikz}
\usepackage{pgfplots}

\begin{document}

\begin{figure}
    \begin{tikzpicture}
    \begin{semilogyaxis}[
        width=\textwidth,
        height=10cm,
        xlabel = {time ($\mu$s)},
        ylabel = {intensity (arbitrairy units)},
        xmin = 0, xmax = 40000,
        ymin = 1, ymax = 1000,
        grid = major,
        legend entries = {data points, exponential fit}]
        \addplot[only marks, color = cyan!55!black, fill = cyan!55!black]
    table[x=x, y=y]{Cr_decay.txt};
        \addplot[line width=4pt,double=purple,double distance=1pt, purple!15!white, mark=none, domain=0:27000, samples=100]{60.8572906687*exp(-0.00104989494035*x) + 1103.66808067*exp(-0.0057771170945*x) + 68.7516215762*exp(-0.000121846421383*x)};
    \end{semilogyaxis}
    \end{tikzpicture}
    \caption{Decay profile of ${\rm ZrGa_2O_4:Cr^{3+}}$}
\end{figure}

\end{document}

在此处输入图片描述

相关内容