# 3dplot in Beamer crop and ticks problem

I'm new to pstricks, and I've been struggling with several issues using it with beamer.

So my problem is that I'm trying to show a 3D plot in a beamer frame. However, for some reason, that I can't understand the figure, is cropped. I already play by changing the values of the width and height of the resize box. How can I show the entire plot?

Also, because I'm resizing the image I want to reduce the number of ticks that appear in the axes. However, I tried the Dx,Dy,Dz options of the 3D axes but that only changes the step between the ticks, but do not reduce their number. What I'm saying is that now I get a tick for every number: 1,2,3,...,100 And if I change the Dx=10 option I get the same number of ticks but with different step: 10,20,30,...,1000. However, what I'm looking for is to obtain, for example, just ten ticks: 10,20,30,...,100, instead of getting hundred. Is there I way of doing this?

\documentclass{beamer}

% For the figures
\usepackage[pdf]{pstricks}
\usepackage{auto-pst-pdf}
\usepackage{pst-node, pst-plot, pst-circ, pst-3dplot}
\usepackage{moredefs}

\begin{document}

\begin{frame}{3D}
\begin{center}
\resizebox{0.7\textheight}{0.7\textheight}{
\begin{pspicture}
\pstThreeDCoor[linecolor=black, IIIDticks,IIIDlabels,xMin=-20,xMax=20,yMin=-40, yMax=40,zMin=0,zMax=50]
\fileplotThreeD[linecolor=blue,plotstyle=line]{data.txt}
\end{pspicture}
}
\end{center}
\end{frame}

\end{document}


The data.txt is here

-
If you want 10 ticks for the x-axis labelled 10...100 then try xMin=0,xMax=11,Dx=10. If you want the negative axis as well up to -100 then xMin=-11 (rather than 0). –  DJP Oct 31 '11 at 3:04
Playing around a little more and I think a warning is in order. It seems your data is read as ticks rather than as actual numbers; so that a number 5 with Dx=1 is 5 ticks (and plotted at 5). Change Dx=10 and the number 5 is still 5 ticks (but now plotted at 50). Double check me on this... –  DJP Oct 31 '11 at 3:43
@DJP I try what you say, but it doesn't work. The ticks are renamed, e.g., for Dx=5,xMin=0,xMax=10 1 is 5 and 10 is 50, but the points are still plotted at their corresponding positions, that is, if you plot 11 it is plotted above 50, in the new axes. I think that the plotting is not checking the new axes. So we are just putting the data and then just trying to change the name of the labels. –  adn Oct 31 '11 at 4:24
That's what I was trying to say. If you plot 11 then it is getting plotted at the 11th tick mark. Since Dx=5 I think it gets plotted at 55 (you said it is plotted ''above 50''). So, if you adjust Dx you'd need to change data accordingly. –  DJP Oct 31 '11 at 4:55

I could not completely address the issues using PSTricks, but if you are open to other options then the pgfplots package works incredibly well here.

It provided an excellent window for your plot by default, and has a very intuitive key=value approach, including the requested xmin, xmax, ymin, ymax, zmin, zmax, and xticks, yticks, and so much more.

I have included some options to get you started, but there are many more to play with- see the documentation for more details.

\documentclass{beamer}
\usepackage{pgfplots}

\begin{document}

\begin{frame}{3D}

\begin{center}
\begin{tikzpicture}
\begin{axis}[
% view={120}{0}, % change this line as needed
width=6cm,
xlabel=$x$,
ylabel=$y$,
zlabel={$z$},
%xmin=-100,xmax=100,ymin=-100,ymax=100,zmin=-20,zmax=20 % change this line as appropriate
xtick={-10,0,10},
\end{axis}
\end{tikzpicture}
\end{center}
\end{frame}

\end{document}

-
To the moderators: I felt that this answer was significantly different from previous one. If you feel that they should be merged, please feel free to do so (or let me know that I should). –  cmhughes Nov 1 '11 at 2:39
No need to remove the commas: You can just say \addplot3+[no marks] table [col sep=comma] {data.txt}; to set the column separator, then it works with adn's original data.txt. –  Jake Nov 1 '11 at 2:44
@Jake Thank you, I have made the edit :) –  cmhughes Nov 1 '11 at 3:04
Hi, thanks for the other option. I think this is more suitable for what I'm trying to do. In other regards, I'm starting with pstricks. Do you thinks is worth to keep learning it or it is better to switch to tickz? I've seen that both have similarities and differences. –  adn Nov 2 '11 at 7:46
@adn: tough question; as with most choices, pick the one that you're most comfortable with. Ideally, you might learn about both :) –  cmhughes Nov 2 '11 at 13:15

The problem is that the pspicture environment will exceed its bounds. Even though you have told it to stay within a box using resizebox.

You can use the environment \begin{pspicture*}...\end{pspicture*} which will automatically clip the picture if it goes outside of the boundaries. If you combine this with \psgrid you can do some experimentation to see what would be an appropriate viewing window.

\documentclass{beamer}

% For the figures
\usepackage[pdf]{pstricks}
\usepackage{auto-pst-pdf}
\usepackage{pst-node, pst-plot, pst-circ, pst-3dplot}
\usepackage{moredefs}

\begin{document}

\begin{frame}{3D}
\begin{center}
\resizebox{0.7\textheight}{0.7\textheight}{
\begin{pspicture}(-10,-5)(10,50)
% \psgrid
\pstThreeDCoor[linecolor=black, IIIDticks,IIIDlabels,xMin=-20,xMax=20,yMin=-20, yMax=40,zMin=0,zMax=50]
\fileplotThreeD[linecolor=blue,plotstyle=line]{data.txt}
\end{pspicture}}
\end{center}
\end{frame}

\end{document}

-
Hi, thanks for the tip. Your bounds for the pspicture works. I was wondering, how do you come up with that one? I tried using from (-10,-10)(10,10) and didn't work. And somewhere (I don't remember where) I read that the size in a beamer frame was about (0,0)(10,10). I still don't understand quite well how the grid gets resized, and also why sometimes the images get clipped. Can you elaborate in this issue? –  adn Oct 31 '11 at 4:19
@adn Remember that even though we imagine in 3D, the pspicture is itself a 2D image. In your original code you did not specify a grid for your pspicture, so it went to the default; the resizebox that you applied did work, but the pspicture went beyond its bounds. Try uncommenting the \psgrid and experimenting for more details. The pspicture is resized either using \psset{unit=...} or 'by force' using resizebox. –  cmhughes Oct 31 '11 at 4:43
it is not the same using \psset{unit=..}or \resizebox{..} –  Herbert Oct 31 '11 at 6:40
Thanks, I got the general idea. So I would try to tweak it. So, there is no way that the 3D can set the size automatically to the data inside? Also, do you know about the tick problem? –  adn Oct 31 '11 at 8:18
@Herbert Thanks, yes, I know that; perhaps I should have said that \resizebox{...} will reduce everything in the picture, including the fontsize of ticks and text. Hence my solution to @adn's previous question –  cmhughes Oct 31 '11 at 15:41