4

The first code:

\documentclass[pstricks]{standalone}
\usepackage{pst-plot}
\def\m{1/((x-1)^2)^(1/3)}

\begin{document}    
\begin{pspicture}(-1,-1)(3.5,3.5)
 \psaxes[labelFontSize=\scriptstyle]{->}(0,0)(3,3)[$x$,-90][$y$,0]
 \psplot[ algebraic,
         % plotstyle=curve,
            plotpoints=1000, <<-- notice
            yMaxValue=3,
            linewidth=1.5pt,
            linecolor=red]{0}{3}{\m}
\psline[linestyle=dashed](1,0)(1,3)
\end{pspicture} 
\end{document}

enter image description here

The second code:

\documentclass[pstricks]{standalone}
\usepackage{pst-plot}
\def\m{1/((x-1)^2)^(1/3)}

\begin{document}    
\begin{pspicture}(-1,-1)(3.5,3.5)
\psaxes[labelFontSize=\scriptstyle]{->}(0,0)(3,3)[$x$,-90][$y$,0]
\psplot[ algebraic,
         plotstyle=curve,
         %plotpoints=1000,
          yMaxValue=3,
         linewidth=1.5pt,
         linecolor=red]{0}{3}{\m}
\psline[linestyle=dashed](1,0)(1,3)
\end{pspicture} 
\end{document}

The result of compiling is frustrating.

  1. What is the difference between them?
  2. Can you fix the picture to make it become equal?
3

The best way to explain is showing the animations, right?

With curve plotstyle

It needs at least 3 points. When N=2 there is no graph.

\documentclass[12pt,pstricks]{standalone}
\usepackage{pst-plot}
\def\m{1/((x-1)^2)^(1/3)}
\def\xl{3 -1.5 exp neg 1 add}
\def\xr{3 -1.5 exp 1 add}
\begin{document}
\multido{\i=2+1}{20}{%
\begin{pspicture}[algebraic,showpoints,plotstyle=curve](-1,-1)(3.5,4)
    \psaxes[labelFontSize=\scriptstyle]{->}(0,0)(3,3.5)[$x$,-90][$y$,0]
    \psplot[linecolor=red,plotpoints=\i]{0}{\xl}{\m}
    \psplot[linecolor=red,plotpoints=\i]{\xr}{3}{\m}
    \psline[linestyle=dashed](1,0)(1,3)
    \rput[t](2,3){$N=\i$}
\end{pspicture}} 
\end{document}

enter image description here

With line plotstyle

It needs at least 2 points.

\documentclass[12pt,pstricks]{standalone}
\usepackage{pst-plot}
\def\m{1/((x-1)^2)^(1/3)}
\def\xl{3 -1.5 exp neg 1 add}
\def\xr{3 -1.5 exp 1 add}
\begin{document}
\multido{\i=2+1}{20}{%
\begin{pspicture}[algebraic,showpoints,plotstyle=line](-1,-1)(3.5,4)
    \psaxes[labelFontSize=\scriptstyle]{->}(0,0)(3,3.5)[$x$,-90][$y$,0]
    \psplot[linecolor=red,plotpoints=\i]{0}{\xl}{\m}
    \psplot[linecolor=red,plotpoints=\i]{\xr}{3}{\m}
    \psline[linestyle=dashed](1,0)(1,3)
    \rput[t](2,3){$N=\i$}
\end{pspicture}} 
\end{document}

enter image description here

Final output

\documentclass[12pt,pstricks]{standalone}
\usepackage{pst-plot}
\def\m{1/((x-1)^2)^(1/3)}
\def\xl{3 -1.5 exp neg 1 add}
\def\xr{3 -1.5 exp 1 add}
\begin{document}
\begin{pspicture}[algebraic](-.5,-.6)(4,4)
    \psaxes[labelFontSize=\scriptstyle]{->}(0,0)(3.5,3.5)[$x$,0][$y$,90]
    \psplot[linecolor=red]{0}{\xl}{\m}
    \psplot[linecolor=red]{\xr}{3}{\m}
    \psline[linestyle=dashed](1,0)(1,3)
\end{pspicture}
\end{document}

enter image description here

My best practices

  • Split the graph into two or more invocation of \psplot when there are discontinuities in a single plot.
  • Increasing plotpoints blindly will waste more storage because the size of PDF (or SVG) increases as well.
  • You don't need to change plotstyle most of the time.

Explanation

  • \def\xl{3 -1.5 exp neg 1 add} is the value of xl<1 such that f(xl)=3.
  • \def\xr{3 -1.5 exp 1 add} is the value of xr>1 such that f(xr)=3.

  • plotstyle represents the type of curves is used to connect points.

  • plotpoints represents the number of points used to draw the curve.
  • 1
    Many compliments too for the animations. – Sebastiano Dec 1 '18 at 13:02
2
\documentclass[pstricks]{standalone}
\usepackage{pst-plot}
\begin{document}    

\begin{pspicture}(-1,-1)(3.5,3.5)
\psaxes[labelFontSize=\scriptstyle]{->}(0,0)(3,3)[$x$,-90][$y$,0]
\psclip{\psframe[linestyle=none](3,3)}
  \psplot[ algebraic,linewidth=1.5pt,linecolor=red]{0}{3}{1/((x-1)^2)^(1/3)}
\endpsclip
\psline[linestyle=dashed](1,0)(1,3)
\end{pspicture} 

\end{document}

enter image description here

  • Can you explain the difference between them (my title) to me ? Herbert ! – Trong Vuong Dec 1 '18 at 14:04
  • All curves are plotted by connecting points. With setting yMaxValue you have an internal if y > yMaxValue then do not plot. It depends to the number of points how near do you get with the calculated point to the maximal value. With clipping you have exactly the same y value. With plotpoints=5000 they are also nearly the same. – user2478 Dec 1 '18 at 14:10
  • So, when should we use plotstyle replace plotpoints and opposite? – Trong Vuong Dec 1 '18 at 14:16
  • plotstyle=curve or bezier only for curves with continuous bends and plotpoints > 100. plotstyle=line for a lot of plotpoints and a curve which has not too big slopes. Howver, for plotpoints > 1000 it doesn't really matter which plotstyle do you use. – user2478 Dec 1 '18 at 14:20
  • Why we use plotpoints > 500 will make file size bigger than plotstyle? – Trong Vuong Dec 1 '18 at 14:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.