同じ直交平面上で、ある線が別の線より長く描かれる

同じ直交平面上で、ある線が別の線より長く描かれる

なぜ 2 本の線の長さが異なるのでしょうか。斜めの線は少し短く (おそらく 2ex 程度)、垂直の線は斜めの線と同じ高さになるように長くする必要があります。

反対側の斜めの線の方程式を取得するにはどうすればよいでしょうか? 現在の位置では、曲線に y=(3/2)x + 5/2 というラベルを付けているように見えます。

x 軸より上のグラフをもう少し描画したい場合、コードのどこを変更すればよいですか? ymax=25の代わりにymax=15?

\documentclass{amsart}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}


\begin{document}



\begin{tikzpicture}
\begin{axis}[width=4in,axis equal image,clip=false,
    axis lines=middle,
    xmin=-15,xmax=15,
    domain=-15:15, samples=101,
    xlabel=$x$,ylabel=$y$,
    ymin=-15,ymax=15,
    restrict y to domain=-20:20,
    enlargelimits={abs=1cm},
    axis line style={latex-latex},
    ticklabel style={font=\tiny,fill=white},
    xtick={\empty},ytick={\empty}
]
\addplot[samples=251,domain=-25:1.5] {(3*x^2+5*x)/(2*x-3)};
\addplot[samples=251,domain=1.5:25] {(3*x^2+5*x)/(2*x-3)} node[above,pos=0.85]{$\scriptstyle{y}=\frac{3x^{2}+5x}{2x-3}$};
\addplot [dashed, latex-latex] {(3/2)*x+5/2} node [pos=0.15, anchor=south, font=\footnotesize, sloped] {$y=\frac{3}{2}x+\frac{5}{2}$};
\addplot [dashed, latex-latex] (1.5,x) node [pos=0.15, anchor=north, font=\footnotesize, sloped] {$x=\frac{3}{2}$};
\end{axis}
\end{tikzpicture}

\end{document}

ここに画像の説明を入力してください

答え1

\documentclass{amsart}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}


\begin{document}



\begin{tikzpicture}
\begin{axis}[width=4in,axis equal image,clip=false,
    axis lines=middle,
    xmin=-15,xmax=15,
    samples=101,
    xlabel=$x$,ylabel=$y$,
    ymin=-15,ymax=15,
    restrict y to domain=-20:25,
    enlargelimits={abs=1cm},
    axis line style={latex-latex},
    ticklabel style={font=\tiny,fill=white},
    xtick={\empty},ytick={\empty},
]
\addplot[samples=251,domain=-25:1.5] {(3*x^2+5*x)/(2*x-3)};
\addplot[samples=251,domain=1.5:15] {(3*x^2+5*x)/(2*x-3)} node[above right,anchor=south west,pos=0.95]{$\scriptstyle{y}=\frac{3x^{2}+5x}{2x-3}$};
\addplot [dashed, latex-latex,domain=-13:10] {(3/2)*x+5/2} node [pos=0.15, anchor=north, font=\footnotesize, sloped] {$y=\frac{3}{2}x+\frac{5}{2}$};
\addplot [dashed, latex-latex,domain=-17:17.5] (1.5,x) node [pos=0.15, anchor=north, font=\footnotesize, sloped] {$x=\frac{3}{2}$};
\end{axis}
\end{tikzpicture}

\end{document}

ここに画像の説明を入力してください

いくつかの説明:

破線プロットに適切なドメインを追加できます。斜めの線については、 を固定するとします,domain=-13:10。この場合、 の最大値と最小値はそれぞれとにyなります。ここで、垂直の破線では、のこれらの値を座標 のように固定します。17.5-17ydomain=-17:17.5{1.5,x}

斜めの線のラベルを下に移動するには、アンカーを に変更しますanchor=north,

上の曲線を延長するには、 の値を変更する必要がありますrestrict y to domain=-20:25,。軸線の長さが適切になるように、 、、のymax値を適宜変更します。(またはのの値を変更します)。xmaxyminxminabs=1cmenlargelimits

関連情報