如何绘制一个看起来不规则的图形(像手绘的)

如何绘制一个看起来不规则的图形(像手绘的)

如何在乳胶中绘制如下所示的图形?看起来几乎是手绘的,但仍由乳胶生成。

期望输出

请注意,我并不关心这个问题中的轴标签。

我在下面包含了图形模板代码,我想在其中绘制这样的图形。

\documentclass[]{article}
\usepackage[margin=0.5in]{geometry}
\usepackage{pgfplots}
\renewcommand{\thesection}{\arabic{section}}
\usepackage{mathtools}
\usepackage{cancel}
\usepackage{pgfplots}
\usepackage{amsmath}
\newtheorem{theorem}{THEOREM}
\newtheorem{proof}{PROOF}
\usepackage{tikz}
\usepackage{amssymb}
\usetikzlibrary{patterns}
\usepgfplotslibrary{fillbetween}
\newenvironment{tightcenter}{
\setlength\topsep{0pt}
\setlength\parskip{0pt}
\begin{center}}{\end{center}}
\begin{document}
% !TeX spellcheck = en_GB 
\begin{tikzpicture}
\begin{axis}[
axis lines=middle,
grid=major,
%ticks=none,
xmin=-0.4,
xmax=6.5,
ymin=-1,
ymax=11,
xtick={0,1,2,3,4,5,6},
ytick={0,2.5,5,7.5,10},
height=9cm,
width=12cm,
axis line style={shorten >=-10pt, shorten <=-10pt},
ylabel style={
    anchor=south,
    at={(ticklabel* cs:1.0)},
    yshift=10pt
},
ylabel=y,
xlabel style={
    anchor=west,
    at={(ticklabel* cs:1.0)},
    xshift=10pt
},
xlabel=x,
axis line style={shorten >=-10pt, shorten <=-10pt},
yticklabel style={
    fill=white,
    %yshift=10pt,
},
xticklabel style={
    %xshift=10pt,
    fill=white
}
]
\end{axis}
\end{tikzpicture}
\end{document}

谢谢

答案1

建议:建立列表并平滑地绘制。当然,您可以调整步长(在下面的示例中为 0.5)和幅度(在下面的示例中为 1.5)。

\documentclass[]{article}
\usepackage[margin=0.5in]{geometry}
\usepackage{pgfplots}
\renewcommand{\thesection}{\arabic{section}}
\usepackage{mathtools}
\usepackage{cancel}
\usepackage{pgfplots}
\usepackage{amsmath}
\newtheorem{theorem}{THEOREM}
\newtheorem{proof}{PROOF}
\usepackage{tikz}
\usepackage{amssymb}
\usetikzlibrary{patterns}
\usepgfplotslibrary{fillbetween}
\newenvironment{tightcenter}{
\setlength\topsep{0pt}
\setlength\parskip{0pt}
\begin{center}}{\end{center}}
\begin{document}
% !TeX spellcheck = en_GB 
\foreach \X [count=\Y] in {0,0.5,...,6}
{\ifnum\Y=1
\pgfmathsetmacro{\myrnd}{10*rnd}
\xdef\myrnd{\myrnd}
\xdef\Lst{(\X,\myrnd)}
\else
\pgfmathsetmacro{\myrnd}{\myrnd+1.5*(rnd-0.5)}
\xdef\myrnd{\myrnd}
\xdef\Lst{\Lst (\X,\myrnd)}
\fi
}
\typeout{\Lst}
\begin{tikzpicture}
\begin{axis}[
axis lines=middle,
grid=major,
%ticks=none,
xmin=-0.4,
xmax=6.5,
ymin=-1,
ymax=11,
xtick={0,1,2,3,4,5,6},
ytick={0,2.5,5,7.5,10},
height=9cm,
width=12cm,
axis line style={shorten >=-10pt, shorten <=-10pt},
ylabel style={
    anchor=south,
    at={(ticklabel* cs:1.0)},
    yshift=10pt
},
ylabel=y,
xlabel style={
    anchor=west,
    at={(ticklabel* cs:1.0)},
    xshift=10pt
},
xlabel=x,
axis line style={shorten >=-10pt, shorten <=-10pt},
yticklabel style={
    fill=white,
    %yshift=10pt,
},
xticklabel style={
    %xshift=10pt,
    fill=white
}
]
\addplot[smooth] coordinates {\Lst};
\end{axis}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容