这是我目前拥有的:
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{center}
\hspace*{\fill}
\begin{tikzpicture}
\begin{axis}[width=4in,axis equal image,
xmax=3,ymax=1.5,
axis lines=middle,
enlargelimits,
axis line style={shorten >=-0.25cm,shorten <=-0.25cm,latex-latex},
ticklabel style={fill=white},
extra x ticks={0},
xlabel=$x$,ylabel=$y$,
clip=false,
trig format=rad
]
\addplot[domain=0:4,samples=200] {(3*(2*x-sin((2*x)))/(8*pi(1-cos(x))-sin(x))} node[fill=white, right]{$y=\frac{3(2x-\sin{2x})}{8\pi(1-\cos{x})}-\sin{x}$};
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}
它看起来应该是这样的:
虽然很接近,但是我感觉好像有些不对劲,它没有击中 x 轴应在的位置。
答案1
主要问题在于您的函数定义;存在一些分组/括号问题。
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[width=4in,axis equal image,
xmax=3,ymax=1.5,
axis lines=middle,
enlargelimits,
axis line style={shorten >=-0.25cm,shorten <=-0.25cm,latex-latex},
ticklabel style={fill=white},
extra x ticks={0},
xlabel=$x$,ylabel=$y$,
clip=false,
trig format=rad
]
\addplot[domain=0:4,samples=200] {
3*(2*x - sin(2*x)) / (8*pi*(1 - cos(x))) - sin(x)} node[fill=white, right]
{$y = \frac{3 (2 x - \sin{2 x})}{8 \pi (1 - \cos{x})} - \sin{x}$};
\end{axis}
\end{tikzpicture}
\end{document}
在更大的域中它看起来是这样的(0:5.5
):
答案2
\documentclass[10pt,a4paper]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[italian]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx,tikz,pgfplots}
\begin{document}
\hspace*{\fill}
\begin{tikzpicture}[trig format=rad]
\begin{axis}[width=4in,axis equal image,
xmax=6,ymax=3,
axis lines=middle,
enlargelimits,
axis line style={shorten >=-0.25cm,shorten <=-0.25cm,-latex},
ticklabel style={fill=white},
extra x ticks={0},
xlabel=$x$,ylabel=$y$,
clip=false,
]
\addplot[domain=0:6,samples=200] {(3*(2*x-sin(deg(2*x)))/(8*pi(1-cos(x))-sin(x)} node[right]{$y=\frac{3}{8\pi}\frac{2x-\sin 2x}{1-\cos x}$};
\end{axis}
\end{tikzpicture}
\end{document}