TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm new to pstricks. I was looking for an automatic way of resizing a plot.

I'm trying to fit a 3d plot, generated using pst-3dplot, into a beamer frame. However, I'm not able to make it look good automatically.

If I set some frame coordinates to the pspicture then just a part of the plot appears. And if I set no coordintaes, then there is no plot. I also try using \psset(unit=1mm) but it compresses the plot and doesn't look good. Is there a way to figure it out without having to recompile hundreads of times? Is there a way to make it resize automatically to the frame size?

This is an example of what I'm doing:


% For the figures
\usepackage{pst-node, pst-plot, pst-circ, pst-3dplot}



\begin{pspicture}%(-5,3)(5,-3)%<-uncomment this and just a part appears
\pstThreeDCoor[linecolor=black, IIIDticks,IIIDlabels,xMin=-20,xMax=20,yMin=-20, yMax=20,zMin=0,zMax=35]


The data.txt file is here

share|improve this question
You can use \resizebox. – Marco Daniel Oct 29 '11 at 10:47
@MarcoDaniel: thanks, that solve the resizing problem of the graphic. However, the text (ticks, legends, labels, etc.) is not readable if I just scale down. That's why I was asking for an automatic way using pstricks. Or should I just increase the size, or better do it somewhere else and just import as a figure. – adn Oct 29 '11 at 11:04
up vote 3 down vote accepted

I use PSTricks a lot, and have struggled with this issue as well. It seems that when you use \psset you don't really have complete control over the size of the resultant figure.

Below is a solution that I use to specify the size of the figure that will calculate the appropriate value of xunit and yunit.

The \setwindow command that I have defined takes 5 arguments, most of which should be self-explanatory: in order they are

  • \xmin
  • \ymin
  • \xmax
  • \ymax
  • \figurewidth

Here is the MWE


% For the figures
\usepackage{pst-node, pst-plot, pst-circ, pst-3dplot}

% setwindow command: takes 6 arguments (1st is optional)
%       [1]. aspect ratio (height = aspect ratio * width) default=1
%         2. xmin (number)
%         3. ymin (number)
%         4. xmax (number)
%         5. ymax (number)
%         6. figurewidth (length)
                           % set up xunit
                           \psset{xunit=\result pt}
                           % set up yunit
                           % set up aspect ratio
                           \psset{yunit=\result pt}%



%\begin{pspicture}(-5,3)(5,-3)%<-uncomment this and just a part appears
\pstThreeDCoor[linecolor=black, IIIDticks,IIIDlabels,xMin=\xmin,xMax=\xmax,yMin=\ymin, yMax=\ymax,zMin=0,zMax=35]



The \setwindow command takes an optional argument which you can use to tweak the aspect ratio. For example, if you use


then the height of the picture will be 1/4 the width.

The nice thing about this approach is that you choose the width and then calculate the values of xunit and yunit and not vice-versa. It removes the guess work involved with \psset.

share|improve this answer
Thanks this those the scaling of the figure. However, when reducing the size of the figure, the labels are all overlapped. Is there a way to automatically reduce the number of ticks that appear if the figure is smaller. Because all the time appear all the ticks (1 step apart). – adn Oct 30 '11 at 7:40
@adn I have struggled with that issue too. I don't think there is a way to do it automatically- you have to scale the picture and then check the ticks. – cmhughes Oct 30 '11 at 14:58
Thanks, I think I will do that then. By the way, this command is really useful. It would be great if it is in a package. – adn Oct 31 '11 at 1:28
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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