概括:

概括:
\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}
% Definitions of functions
\def\f(#1){4-#1*#1/3}
\def\g(#1){#1*#1/4}  

% Shade the area bounded by the two graphs in [-1,2]
\fill[blue!30] 
plot[domain=-1:2] (\x,{\f(\x)})--(2,{\g(2)})--
plot[domain=2:-1] (\x,{\g(\x)})--(-1,0)--cycle;

% Draw axes
\draw[->] (-3,0)--(3.5,0) node[below]{$x$};
\draw[->] (0,-.5)--(0,4.5) node[left]{$y$};
\draw[dashed] 
%(2,{\f(2)})--(2,0) node[below]{$2$} 
%(-1,{\f(-1)})--(-1,0) node[below]{$-1$};
(2,8/3)--(2,0) node[below]{$2$}        %% <<<---
(-1,11/3)--(-1,0) node[below]{$-1$};   %% <<<---
% Draw the two graphs
\draw plot[domain=-3:3] (\x,{\f(\x)});
\draw plot[domain=-3:3] (\x,{\g(\x)});
\end{tikzpicture}
\end{document}

在此处输入图片描述

\documentclass[border=5pt,pstricks,12pt]{standalone}
\usepackage{pst-plot,pst-calculate}
\begin{document} 
\begin{pspicture}[algebraic](-3.2,-1.2)(4.2,5)
\pscustom[fillstyle=solid,fillcolor=blue!30,linestyle=none]{%
\psplot{-1}{2}{(x^2)/4}
\psplot{2}{-1}{4-(x^2)/3}
 }
\psaxes[labels=none,ticks=none]{->}(0,0)(-3,-1)(4,5)[$x$,-90][$y$,0]
\psplot{-3}{3}{(x^2)/4}
\psplot{-3}{3}{4-(x^2)/3}
\psLineSegments[linestyle=dashed](-1,0)(-1,\pscalculate{11/3})(2,0)(2,\pscalculate{8/3})   %% <<<---
\psxTick(-1){$-1$}
\psxTick(2){$2$}
\end{pspicture}
\end{document}

在此处输入图片描述

如何使用分数表示 PSTricks 的坐标?

答案1

  • (*{postfix constant} {infix expression in x})

    (*-1 11/3)等于 TikZ (-1,11/3)

    实际上你可以做更复杂的事情,例如(*{0 1 sub} {11/3+0*x})因为最后一个可以是任何表达式x

  • (+{infix constant},{infix expression in x})

    (+-1,11/3)等于 TikZ (-1,11/3)

    实际上你可以做更复杂的事情,例如(+0-1,11/3+0*x)因为最后一个可以是任何表达式x

我建议始终使用{...}横坐标和纵坐标,因为这是最安全的方法。当前的解析器不够聪明。

概括:

为了方便以后参考,我写下以下总结。最后一个功能尚未实现。如果您想要请求最后一个功能,请联系维护者。:-)

\documentclass[pstricks,border=1cm]{standalone}
\usepackage{pst-plot}
% the trailing spaces are intentionally added
\def\f{x/2 }
\def\F{2*y }
\pstVerb{/I2P {AlgParser cvx exec} def}% infix to postfix

\def\point[#1](#2){\pscircle*[linecolor=#1](#2){4pt}}

\begin{document}
\begin{pspicture}[showgrid](9,5)
    % postfix constant and infix f(x)
    \point[red](*{1 1 add} \f)              % (2,f(2))=(2,1)

    % infix constant and infix f(x)
    \point[green](+8/2,\f)                  % (4,f(4))=(4,2)

    % infix F(y) and postfix constant
    \point[blue](**\F 1 2 add)              % (F(3),3)=(6,3)

    % Unfortunately,
    % infix F(y) and infix constant
    %\point[black](++\F,8/2)                % (F(4),4)=(8,4)
    % has not been implemented yet  
    % but we can use I2P as follows
    \point[black](**\F {(8/2) I2P})         % (F(4),4)=(8,4)
\end{pspicture}
\end{document}

在此处输入图片描述

答案2

我正在尝试读懂你的想法。你正在寻找的可能是以下内容。

\documentclass[border=5pt,pstricks,12pt]{standalone}
\usepackage{pst-plot}
\def\f{x^2/4 }% adding a trailing space is a good practice here
\def\g{4-x^2/3 }
\def\G{sqrt(12-3*y) }% the inverse of the left part of g(x)
\pstVerb{/I2P {AlgParser cvx exec} def}% infix to postfix
\begin{document} 
\begin{pspicture}[algebraic](-3.2,-1.2)(4.2,5)
\pscustom[fillstyle=solid,fillcolor=blue!30,linestyle=none]{
    \psplot{-1}{2}{\f}
    \psplot{2}{-1}{\g}}
\psaxes[labels=none,ticks=none]{->}(0,0)(-3,-1)(4,5)[$x$,-90][$y$,0]
\psplot{-3}{3}{\f}
\psplot{-3}{3}{\g}
\psLineSegments[linestyle=dashed](-1,0)(*-1 \g)(2,0)(**\G {(8/3) I2P})
\psxTick(-1){$-1$}
\psxTick(2){$2$}
\end{pspicture}
\end{document}

在此处输入图片描述

相关内容