pgfplots の不完全なプロット

pgfplots の不完全なプロット

最大化問題の実行可能セットをプロットしようとしています。制約の 1 つは、x 軸まで拡張する必要があるため不完全です。ここに画像の説明を入力してください

また、環境によっては、図全体とキャプションがページに対して中央に配置されると思いますcenterが、図はキャプションに対しても中央に配置されると思っていました。

MWEは

\documentclass[a4paper]{article}
\usepackage[font=footnotesize,labelfont=bf]{caption}
\usepackage{pgfplots}

\pgfplotsset{compat = newest}

\begin{document}

\begin{center}
   \begin{figure}
      \begin{tikzpicture}
         \begin{axis}[
            ticks=none, 
            axis x line=bottom,
            axis y line=left,
            xmin=0,xmax=1.2,
            ymin=0,ymax=1.3]
         \addplot[
            domain = 0:sqrt(33/56),
            samples =200,
            smooth,
            blue,
            thick
            ] {sqrt((33/8-7*x^2)/3)};
         \end{axis}
      \end{tikzpicture}
      \caption{This is text just to show that the figure is not centered with respect to the caption.}
   \end{figure}
\end{center} 

\end{document}

答え1

@RaffaeleSantoro の回答を拡張します:

使用するとsamples = 800役立ちます。

figureまた、環境内に配置するのではなくcenter、次のように\centeringinsideを使用しますfigure

\documentclass[a4paper]{article}
\usepackage[font=footnotesize,labelfont=bf]{caption}
\usepackage{pgfplots}

\pgfplotsset{compat = newest}

\begin{document}

\begin{figure}
    \centering
    \begin{tikzpicture}
        \begin{axis}[
        ticks=none, 
        axis x line=bottom,
        axis y line=left,
        xmin=0,xmax=1.2,
        ymin=0,ymax=1.3]
        \addplot[
        domain = 0:sqrt(33/56),
        samples =800,
        smooth,
        blue,
        thick
        ] {sqrt((33/8-7*x^2)/3)};
        \end{axis}
    \end{tikzpicture}
    \caption{This is text just to show that the figure is not centered with respect to the caption.}
\end{figure}

\end{document}

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

答え2

これは、最後のポイントに「到達」していないからではありません。関数は の右側に定義されておらずsqrt(33/56)、コンピュータの有限精度では、どちらでも関数を評価することはできませんsqrt(33/56)。-ポイントは破棄されます - コンパイル ログを確認してください。1 つの可能性は、サンプル数を大幅に増やして、最後から 2 番目のポイントで許容できる結果が得られるようにすることです。別の方法は、次のようにポイントを個別に定義することですy filter

\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
ticks=none, 
axis x line=bottom,
axis y line=left,
xmin=0,xmax=1.2,
ymin=0,ymax=1.3]
\addplot[
domain=0:sqrt(33/56),
samples=200,
smooth,
blue, thick,
y filter/.expression={x==sqrt(33/56)?0:y},
] {sqrt((33/8-7*x^2)/3)};
\end{axis}
\end{tikzpicture}
\end{document}

グラフの四分の一円

関連情報