格子消失了

格子消失了

我正在策划这件事

在此处输入图片描述

我得到的最远的结果是这样的:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T2A]{fontenc}
\usepackage[english, russian]{babel}
\usepackage{tikz}
\usetikzlibrary{calc,patterns,angles,quotes}
\usepackage{pgfplots}
\usepackage{graphicx}
\pgfplotsset{compat=newest}
\usepackage{amsmath,amsfonts,amsthm, mathtools}
\usepackage{amssymb}
\begin{document}
    \begin{tikzpicture}
        \begin{axis}
            [xmin=0,
            xmax=250,
            ymin=0,
            ymax=200,
            xlabel={$t,\text{ч}$},
            ylabel={$N, 10^{18}$},
            grid=both,
            grid style={line width=.1pt, draw=gray!10},
            major grid style={line width=.2pt,draw=gray!50},
            axis lines=middle,
            minor tick num=5,
            enlargelimits={abs=0.5},
            axis line style={-stealth},
            ticklabel style={font=\tiny},
            yticklabels={80,160},
            xticklabels={0,100,200},
            xtick={0},
            ytick={0},
            xlabel style={at={(ticklabel* cs:1)},anchor=north west},
            ylabel style={at={(ticklabel* cs:1)},anchor=south west}]
            
            \addplot[domain=0:250,red,line width=0.5mm] {160*2^(-0.02*x)};
            
        \end{axis}
    \end{tikzpicture}
\end{document}

在此处输入图片描述

为什么无法显示轴上的网格和具体值?

编辑

部分问题消失了(感谢 Teddy van Jerry),但现在我绘制了一个略有不同的函数,我的轴断了如下: 在此处输入图片描述

如何使轴从一个点开始并且刻度不与数字重叠?

答案1

\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmin=0, xmax=250,
ymin=0, ymax=200,
axis lines=middle,
x axis line style={thick, shorten >=-30pt},
y axis line style={thick, shorten >=-15pt},
xlabel={$t,$},
ylabel={$N, 10^{18}$},
xlabel style={at={(ticklabel* cs:1.1)}, anchor=north west},
ylabel style={anchor=south east},
grid=both,
grid style={black},
minor tick num=1,
xtick distance=100,
ytick distance=80,
hide obscured x ticks=false,
clip=false,
]
\addplot[domain=0:270, red, very thick] {160*2^(-0.02*x)};
\end{axis}
\end{tikzpicture}
\end{document}

带有红色曲线和网格的图形

相关内容