2

I am using this code to produce the following plot with pstricks:

\documentclass[pstricks]{standalone}
\usepackage{pst-func,amsmath,xfp}
\begin{document}
\definecolor{fillColor}{RGB}{125, 185, 250}
\psset{xunit=1cm,yunit=5cm}%
\begin{pspicture}(-2,-0.25)(7.5,2.1)%
    \rput(0,1.4)
    {
    \uput[-90](7,0){$x$} \uput[60](0,0.5){$P(X=x)={}^N\!C_x \\~\\ p^x(1-p)^{N-x}$}
    \psBinomial[markZeros,fillstyle=solid,opacity=0.5,fillcolor=fillColor,
    barwidth=0.01,linecolor=fillColor]{6}{0.5}
    \uput[90](6,0.5){$X \sim B(6,0.5)$}
    \psaxes[Dy=0.1,dy=0.1\psyunit,tickstyle=bottom]{->}(0,0)(0,0)(7,0.5)
   }
\end{pspicture}
    
\end{document}

and I am getting this plot:

https://i.stack.imgur.com/ipNgA.png

But for consistency with other plots in the paper I would like to displace the axes like the ones we get when using frame=FALSEe R base plot:

https://i.stack.imgur.com/xjDtQ.png

I have played with the \psaxes coordinates but got no luck. Any ideas? Thanks in advance!

2
  • 1
    Use a simple \psline and plot the ticks with \multido
    – user187802
    Aug 27, 2022 at 18:51
  • uhum... not sure how to do that....
    – JPMD
    Aug 28, 2022 at 9:08

2 Answers 2

2

for example with different \psaxes:

\documentclass[pstricks]{standalone}
\usepackage{pst-func,amsmath,xfp}
\begin{document}
    \definecolor{fillColor}{RGB}{125, 185, 250}
    \psset{yunit=5cm}%
    \begin{pspicture}(-2,-0.25)(7.5,2)%
            \uput[0](5,0){$x$} \uput[60](0,1.5){$P(X=x)={}^N\!C_x \\~\\ p^x(1-p)^{N-x}$}
            \rput(0.2,0){\psBinomial[markZeros,fillstyle=solid,opacity=0.5,fillcolor=fillColor,
                barwidth=0.01,linecolor=fillColor,xunit=0.2,yunit=4.5]{6}{0.5}}
            \uput[90](6,1.5){$X \sim B(6,0.5)$}
            \psaxes[yAxis=false,Dx=5,dx=1,tickstyle=bottom](5,0.5)
            \rput(0,0.5cm){\psaxes[xAxis=false,Dy=0.05,dy=0.25,Oy=0.05,tickstyle=bottom](0,1.25)}
    \end{pspicture}
    
\end{document}

enter image description here

4
  • perfect solution!
    – JPMD
    Aug 28, 2022 at 11:01
  • I guess the trick is the Dy and dy values... because one has to compensate for the displacement of the yaxis. For example, what if we want the y axis to vary from 0 to 1 with 0.1 ticks?
    – JPMD
    Aug 28, 2022 at 13:48
  • 1
    you already did it in your answer ... See also tug.org/PSTricks/main.cgi?file=pst-plot/psaxes
    – user187802
    Aug 28, 2022 at 16:42
  • I like your solution better (using psaxes).
    – JPMD
    Aug 29, 2022 at 12:05
1

So, this is the closest I can get:

enter image description here

Just add these lines and change the psaxes as below:

\psaxes[yAxis=false,Dy=0.1,dy=0.1\psyunit,tickstyle=bottom]{->}(0,0)(0,0)(7,0.5)
    \psline[linewidth=0.94pt]{->}(-0.3,0.0)(-0.3,.5)
    \multido{\n=0.1+0.1}{4}{%
        \psdots[dotstyle=|, dotangle=90,dotsize=4pt,fillcolor=black](-0.35,\n)
        \rput(-0.8, \n){\n}}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .