反映直线 $y=x$ 中的图形

反映直线 $y=x$ 中的图形

找到该图的逆图似乎很有挑战性,所以我现在想在线 y=x 中反映图的红色部分。

图形

在乳胶中怎样做到这一点?

谢谢你!

\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}
\usepackage{fancyhdr}
\usepackage{bigints}
\usepackage{color}
\usepackage{tcolorbox}
\usepackage{color,xcolor}
\usepackage{booktabs,array}
\usepackage{hyperref}
\usepackage{graphicx}
\usetikzlibrary{arrows}
\usepackage{polynom}
\usepackage{wallpaper}
\usetikzlibrary{shapes.geometric}
\usepgfplotslibrary{fillbetween}
\newenvironment{tightcenter}{
\setlength\topsep{0pt}
\setlength\parskip{0pt}
\begin{center}}{\end{center}}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines=middle,
axis line style=thick,
axis line style={->},
%minor tick num=5,
%grid=both,
%grid style={line width=.1pt, draw=gray!30},
%major grid style={line width=.2pt,draw=gray!50},
%ticks=none,
xmin=-0.5,
xmax=4.6,
ymin=-0.3,
ymax=1.1,
height=12cm,
width=15cm,
%label style={font=\normalsize},
xlabel=$x$,
ylabel=$y$,
ticks=none,
clip=false,
%every tick label/.append style={font=\tiny},
ylabel style={
    anchor=south,
    at={(ticklabel* cs:1.0)},
    yshift=1pt
},
xlabel style={
    anchor=west,
    at={(ticklabel* cs:1.0)},
    xshift=1pt
}
]
%\addplot[name path=func1,thick,color=black,samples=120,domain=-0.05:4.5] {2*x*exp(-2*x+1)};
\addplot[name path=func2,thick,color=black,samples=120,domain=-0.325:4.5] {2*x^2*exp(-2*x+1)};
\addplot[name path=func2,thick,color=red,samples=120,domain=1:4.5] {2*x^2*exp(-2*x+1)};
%
\node[below] at (axis cs:-0.07,0) {$O$};
%\addplot fill between[
%of = func1 and func2,
%soft clip={domain=0:1},
%every even segment/.style  = {gray,opacity=.3}
%];
\end{axis}
\end{tikzpicture}
\end{document}

答案1

首先,纯 Ti在这种情况下,Z 更短——不需要这么长的代码。这是你的图表

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}[x=15cm/5.1,y=12cm/1.4]
\draw[->] (-.5,0) -- (4.6,0) node[below] {$x$};
\draw[->] (0,-.3) -- (0,1.1) node[left] {$y$};
\path (0,0) node[below left] {$O$};
\draw[thick] plot[samples=120,domain=-0.325:4.5]      (\x,{2*\x*\x*exp(-2*\x+1)});
\draw[thick,color=red] plot[samples=120,domain=1:4.5] (\x,{2*\x*\x*exp(-2*\x+1)});
\end{tikzpicture}
\end{document}

其次,你的图表不平衡。看看线条的渐变=X(蓝色)见下文。应该如何在该行上反映某些内容?

在此处输入图片描述

所以我觉得我应该平衡一下。那么反射就不难了,这里我使用了手册第 368 页描述的技巧。

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}[scale=1.5,>=stealth]
\draw[->] (-.5,0) -- (4.6,0) node[below] {$x$};
\draw[->] (0,-.5) -- (0,4.6) node[left] {$y$};
\path (0,0) node[below left] {$O$};
\draw[thick] plot[samples=120,domain=-0.325:4.5]      (\x,{2*\x*\x*exp(-2*\x+1)});
\draw[thick,color=red] plot[samples=120,domain=1:4.5] (\x,{2*\x*\x*exp(-2*\x+1)});
\draw (0,0) -- (1.3,1.3);
\begin{scope}[x={(0cm,1cm)},y={(1cm,0cm)}]
\draw[thick] plot[samples=120,domain=-0.325:4.5]       (\x,{2*\x*\x*exp(-2*\x+1)});
\draw[thick,color=blue] plot[samples=120,domain=1:4.5] (\x,{2*\x*\x*exp(-2*\x+1)});
\end{scope}
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

如果你需要可见的反射,那么你可以使用包pst-optic。使用以下命令运行示例pdflatex --shell-escape <file>

\documentclass{article}
\usepackage{pst-plot,pst-optic}
\usepackage{auto-pst-pdf}
\begin{document}

\psset{xunit=1.5,yunit=5}
\def\f(x){2*x*x*Euler^(-2*x+1)}

\begin{pspicture}(-5,-0.5)(5,1.5)
  \psaxes[labels=none,arrows=->](0,0)(-4.5,-0.1)(4.75,1.25)[$x$,-90][$y$,0]
  \psplot[algebraic,plotpoints=500,linewidth=1.5pt]{-0.325}{1}{\f(x)}
  \psplot[algebraic,plotpoints=500,linecolor=red,linewidth=1.5pt]{1}{4.5}{\f(x)}
  \psline[linestyle=dashed](1,1)
  \symPlan(0,0)(1,1){% reflect to given line
    \psplot[algebraic,plotpoints=500,linewidth=1.5pt]{-0.325}{1}{\f(x)}%
    \psplot[algebraic,plotpoints=500,linecolor=red,linewidth=1.5pt]{1}{4.5}{\f(x)}}
\end{pspicture}

\end{document}

在此处输入图片描述

答案3

这使得您可以在任意行上反映该函数,而不受编译器选择的限制。a=b=1是该x=y行。

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{backgrounds}
\begin{document}
\begin{tikzpicture}[
declare function={ f(\x) = 2*\x*\x*exp(-2*\x+1); %<- enter your function right here
                   a=1;
                   b=1;
                   reflectedx(\x)        = -\x+2*a*(\x*a+f(\x)*b)/(pow(a,2)+pow(b,2));
                   reflectedy(\x)        = -f(\x)+2*b*(\x*a+f(\x)*b)/(pow(a,2)+pow(b,2));
                 },
]
\begin{scope}[local bounding box=plots]
 \draw [thick] plot [domain=-0.325:1,samples=51,smooth] ({\x}, {f(\x)});
 \draw [blue,thick] plot [domain=1:4,samples=51,smooth] ({\x}, {f(\x)});
 \draw [thick] plot [domain=-0.325:1,samples=51,smooth] ({reflectedx(\x)},{reflectedy(\x)});
 \draw [red,thick] plot [domain=1:4,samples=51,smooth] ({reflectedx(\x)},{reflectedy(\x)});
\end{scope}
\begin{scope}[on background layer]
\draw[thick,-latex] ([xshift=-2mm]plots.west |-0,0) -- ([xshift=4mm]plots.east
|-0,0) node[below left]{$x$};
\draw[thick,-latex] ([yshift=-2mm]plots.south -|0,0) -- ([yshift=4mm]plots.north
-|0,0) node[below left]{$y$};
\end{scope}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容