Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

compiling the following example in newest MikTeX or TexLive results in strange problems: Have a look at the plot:

ProblemPicture: Missing segments and axes

There are some missing parts and only the z-axis is drawn. Please try to help.

\documentclass{standalone}
\usepackage{tikz,tikz-3dplot}
\begin{document}
\tdplotsetmaincoords{70}{10}
\begin{tikzpicture}[scale=5,line join=bevel,tdplot_main_coords,fill opacity=.15]
\pgfsetlinewidth{.2pt}
\tdplotsetpolarplotrange{30}{100}{0}{360}
\tdplotsphericalsurfaceplot[parametricfill]%
{18}%
{36}%
{1}%
{black}%
{\tdplotphi+\tdplottheta+\tdplotr}%
{\draw[color=black,thick,->] (0,0,0) -- (1.3,0,0) node[right]{\(x\)};}
{\draw[color=black,thick,->] (0,0,0) -- (0,3.3,0) node[above right]{\(y\)};}
{\draw[color=black,thick,->] (0,0,0) -- (0,0,1.3) node[above]{\(z\)};};
\end{tikzpicture}
\end{document}

Any hints? Thanks in advance

share|improve this question
add comment

5 Answers

up vote 4 down vote accepted

The same with PSTricks ... Run it with xelatex or load package auto-pst-pdf

\documentclass{article}
\usepackage{pst-solides3d}

\begin{document}

\psset{unit=2.5}
\begin{pspicture}(-2,-2)(2,2)
\psset{viewpoint=20 20 20 rtp2xyz,
   Decran=20,lightsrc=viewpoint}
\psSolid[object=grille,base=-2 2 -2 2,action=draw,linecolor=red](0,0,0)
\axesIIID(2,2,1.5)(3,3,2)
\defFunction[algebraic]{sphere}(u,v)
   {2*cos(u)*cos(v)} {2*sin(u)*cos(v)} {2*sin(v)}
\psSolid[object=surfaceparametree,
   base=pi neg pi 0 0.75,hue=0.2 0.8,function=sphere,
   linewidth=0.2pt,opacity=0.8,ngrid=0.1]
%\gridIIID[Zmin=0,Zmax=1.5](-2,2)(-2,2)
\end{pspicture}

\end{document}

enter image description here

share|improve this answer
    
WOW! I used PSTRICKS for a long time - but never liked the way getting a pdf out of it. I do not really like auto-pst-pdf - and thus I always needed to compile a convert... But with your hint xelatex this is just what I ever wanted! THANKS! –  Bastian Ebeling Feb 25 '11 at 7:12
add comment

Thanks for pointing out the problem with drawing the axes. I have uploaded a modified version of tikz-3dplot to ctan, and it should be available soon.

It turned out to be a very subtle problem, which may be due to using an older version of pgf to develop this. If you're curious, it all had to do with a conditional statement, where \pgfmathresult returns a "1" for true, and a "0" for false. I had written tikz-3dplot to expect "1.0", and thus the condition was never met, and the x/y axes were never drawn.

The problem with drawing only a segment has been fixed as well. The problem was related to an incorrect order of operations involving squaring and square rooting a negative number.

Now, I notice that this output looks a bit boxy, and you can smooth it out a bit if you like by increasing the number of segments per revolution. Also, it couldn't hurt to spin the axes around a bit.

\tdplotsetmaincoords{70}{100}
\begin{tikzpicture}[scale=5,line join=bevel,tdplot_main_coords,fill opacity=.15]
\pgfsetlinewidth{.2pt}
\tdplotsetpolarplotrange{30}{100}{0}{360}
\tdplotsphericalsurfaceplot[parametricfill]%
{48}%
{48}%
{1}%
{black}%
{\tdplotphi+\tdplottheta+\tdplotr}%
{\draw[color=black,thick,->] (0,0,0) -- (1.3,0,0) node[below]{\(x\)};}
{\draw[color=black,thick,->] (0,0,0) -- (0,1.3,0) node[above right]{\(y\)};}
{\draw[color=black,thick,->] (0,0,0) -- (0,0,1.3) node[above]{\(z\)};};
\end{tikzpicture}
share|improve this answer
    
Thank you for the fast work! This is really great support! Sorry for my late answer - I've been in a meeting until now. I'm happy to have pgf/tikz-3dplot up working fine again! –  Bastian Ebeling Feb 28 '11 at 18:44
add comment

Solution of pgfplots:

\documentclass{article}
\usepackage{pgfplots}
\usetikzlibrary{pgfplots.external}
\tikzexternalize
\begin{document}
\begin{tikzpicture}
\begin{axis}[width=\textwidth,
  samples=25,domain=0:360,y domain=10:30,
  xmin=-1.2,xmax=1.2,ymin=-1.2,ymax=1.2,zmin=0,zmax=1.2,
  xlabel={$x$},ylabel={$y$},zlabel={$z$},
  axis lines=center]
\addplot3[surf,opacity=0.5]
  ({cos(x)*cos(y)}, {sin(x)*cos(y)}, {sin(y)});
\end{axis}
\end{tikzpicture}
\end{document}

(The labels are not at right place. It seems there's a bug of pgfplots. But we can put the labels manually.)

enter image description here

share|improve this answer
add comment

I am not sure what is the cause, and I am unable to fix the missing axes, but I noticed couple of things:

  1. With the most recent version of tikz-3dplot, even the examples from the manual will have only z-axis drawn. The pictures in the pdf manual that comes with the package have all three axes, however, recompiling the manual created pictures with only z-axis. So my guess is that there is a bug in the current version.

  2. The missing parts seem to have something to do with the second parameter in \tdplotsetmaincoords. If the second parameter is at least 90, the whole surface is drawn. If it is less then 90, parts are missing. Larger part is missing id the parameter is smaller. It happens with the examples from the manual, too, if you change the second parameter so it is smaller than 90. Again, it seems like a bug in tikz-3dplot.

share|improve this answer
    
Thank you for those great details. At night I planned to try exactly you way on compiling the manual on my own! Have you alerted the package maintainer - or should I? –  Bastian Ebeling Feb 25 '11 at 7:07
2  
@Bastian: It's a good idea to file a bug report, yes! –  Hendrik Vogt Feb 25 '11 at 7:47
    
and @Hendrik Vogt : Okay, I'll create this report on monday. Greets and have a nice weekend! –  Bastian Ebeling Feb 25 '11 at 11:30
    
Okay, bug report to Jeff Hein is out. –  Bastian Ebeling Feb 28 '11 at 7:20
    
The new version of tikz-3dplot is out (that was fast). It seems to have fixed the missing axes problem, but the problem with missing parts if the second argument of \tdplotsetmaincoords is less than 90 is still there. In your case it should not matter much, as your surface is rotationally symmetric. –  Jan Hlavacek Feb 28 '11 at 18:14
add comment

In ubuntu, following the route latex -> dvips -> ps2pdf, works for me, and also using the package auto-pst-pdf and viewing in Acrobat. So probably there is something wrong with your viewer. Though of course Herbert's code looks much more beautiful!

share|improve this answer
    
Compiling with TL2010 on Ubuntu, I get the same error (with both Evince and Acrobat). –  Caramdir Feb 25 '11 at 17:33
    
That's not a viewer problem. And it does the same whether I use latex -> dvips -> ps2pdf or pdflatex. The auto-pst-pdf does not even apply in this case, as it is tikz code, not pstricks. Texlive 2009 on Debian, with the latest version of tikz-3dplot from ctan. It seems to be a bug in the latest version of the package. Unfortunately, it does not seem to come with a changes log. –  Jan Hlavacek Feb 26 '11 at 1:36
    
I think you're right, was using the version of tikz-3dplot Created 2009-11-07 by Jeff Hein. Last updated: 2010-01-20, and I see there is a more recent version on CTAN. –  rvf0068 Feb 26 '11 at 4:33
add comment

Your Answer

 
discard

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.