在下图中,有可能吗:
1. 抛物线在其末端变得点状
2. 整个图像逐渐向边缘消失?
\documentclass[14pt,portrait,a4paper]{article}
\usepackage[UKenglish]{babel}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture} [scale=0.5]
\begin{axis}[
xmin=-3,xmax=3,
ymin=-1,ymax=4,
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},
ytick={-4, -3, ...,4}, xtick={-4, -3, ...,4},
axis line style={latex-latex},
ticklabel style={fill=white},
major tick length=4pt,major tick style={red,thick},
minor tick length=1pt,minor tick style={gray,thin}
]
\addplot [green, domain=-2:2] {x^2};
\end{axis}
\end{tikzpicture}
\end{document}
先感谢您 !
答案1
要淡出,您可以使用fadings
库,并绘制我实际使用的虚线图,only marks
因为标记密度远离抛物线中心而减小。
\documentclass[14pt,portrait,a4paper]{article}
\usepackage[UKenglish]{babel}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usetikzlibrary{fadings}
\begin{tikzfadingfrompicture}[name=fade left]
\shade[left color=transparent!00,right color=transparent!100] (-3,-3) rectangle (-1,3);
\end{tikzfadingfrompicture}
\begin{tikzfadingfrompicture}[name=fade right]
\shade[left color=transparent!100,right color=transparent!00] (1,-3) rectangle (3,3);
\end{tikzfadingfrompicture}
\begin{document}
\begin{tikzpicture} [scale=0.5]
\begin{axis}[
xmin=-3,xmax=3,
ymin=-1,ymax=4,
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},
ytick={-4, -3, ...,4}, xtick={-4, -3, ...,4},
axis line style={latex-latex},
ticklabel style={fill=white},
major tick length=4pt,major tick style={red,thick},
minor tick length=1pt,minor tick style={gray,thin}
]
\addplot [blue,only marks,mark size=0.6pt,mark=*,domain=-2:-1,samples=25] {x^2};
\addplot [blue,only marks,mark size=0.6pt,mark=*,domain=1:2,samples=25] {x^2};
\addplot [blue,domain=-1:1,thick] {x^2};
\end{axis}
\fill [path fading=fade left,white]
(current axis.south west) rectangle ([xshift=2cm]current axis.north west);
\fill [path fading=fade right,white]
([xshift=-2cm]current axis.south east) rectangle (current axis.north east);
\end{tikzpicture}
\end{document}