bugfix for x- and y-axes in polar plots

A problem with the x- and y-axes in the polar plot functionality was recently brought to my attention. It turned out to be a very subtle problem with the use of /pgfmathresult.

To draw the x and y axes, a comparison is made between the current plotted angle and the angle where these axes exist. This check is performed to ensure that the axes appear at the right depth when the plot is rendered. Basically, any part of the plot “behind” the axis from the current perspective is rendered first, then the axis is drawn at the appropriate time by using this comparison, and then the rest of the shape is drawn.

My code was written to expect a result of “1.0” when returning true on the comparison statement. The macro was returning “1”, and thus the conditional code was never executed, and the axes were never rendered.

After changing “1.0” to “1”, all was well. The latest version is available on CTAN.

Now, it appears that, for some orientations, the shape is not fully rendering in a quadrant. I will poke around and see if I can fix this issue, and will post an update.


~ by Jeff Hein on 2011/03/01.

8 Responses to “bugfix for x- and y-axes in polar plots”

  1. This is mostly stupidity on the user’s part, but maybe you want to amend the “how to use” documentation to say:


    is needed to get compiling, as opposed to just the first line. At least this was my experience.

    • Hi Peter,

      Thanks for pointing that out! It was a typo that has lasted since when I first wrote this documentation in a hurry. I’ll have that included in the next update.

      I hope the rest of the documentation is relatively helpful.


  2. Hi,

    first of all: thanks a lot for making your work available to other LaTeX/TikZ fans who want to draw some 3D sketches.

    Today, I had two little problems with the tikz-3dplot code:
    1. \tdplotgetpolarcoords caused an error when using negative coordinates because it tried to compute the square root of a negative value. I fixed this by changing \vxcalc^2 etc. to (\vxcalc)^2.
    2. Furthermore, the case selections with \ifthenelse{\equal{\pgfmathresult}{1.0}} did not work for me. I had to change the ‘1.0’ to ‘1’ which fixed the problem.

    I haven’t done any thorough testing so far, so I am just pointing this out. It may have to do with my installation and work for others — I don’t know. If you would like to look into this and want me to submit a minimal code example, please let me know.

    Best regards and thanks again,

    BTW: Is this the “proper” way to contact you about bug reports? I couldn’t find any contact info in the tikz-3dplot documentation. Maybe you want to take this as another suggestion for improvement. 😉

    • Hi Chris,

      I’m glad to know you have found this package useful. Thanks for the notes on the problem regarding the bad behaviour with negative values. It looks like this was the cause of a drawing issue that was brought to my attention at http://tex.stackexchange.com/questions/11975/strange-problems-in-3d-plots-tikz-missing-parts-and-axes, but I have been too lazy to trace out the source of the problem.

      I am preparing to upload a modified version to CTAN that includes this bugfix.


      PS. This is the easiest way to get in touch with me for bugs reports and suggestions regarding tixz-3dplot.

  3. I’m sorry, I just realized that point 2 of my previous comment was already mentioned in your post.

  4. Hi, just found your package today and it is exactly what I was looking for!

    Maybe I’m missing something, but I seem to be still running into this bug with the x and y axes not drawing. I downloaded the version on ctan today which is listed as changed on June 27, so I should be up to date.

    I do see comparisons between \pgfmathresult and 1.0, but not exactly sure what needs to be changed (just changing all of them to 1 in the .sty didn’t work for me). I’m not sure if I made a mistake somewhere, let me know if you have an idea.


    • Update to my comment – I found the comparison you changed from 1.0 to 1 I think (in \tdplotcheckdiff). Uncommented your typeout there and saw that my result WAS either 0.0 or 1.0. So changing back to 1.0 in the \equal comparison made the axes draw for me.

      Maybe its a pgf version issue or something where different people get different formats for the result?

      • Hi Matt,

        I’m glad you find this package useful, and I’m glad you found a way to make this work for you. I agree with you regarding the possible version issue in the PGF math functionality. When I first made this package, it worked perfectly fine for me, and it was only after some time when the issue was brought to my attention that I was able to reproduce it. Sure enough, I was using a newer version of PGF. I’m not knowledgeable enough with LaTeX to comment, but I believe it all stems from the fact that, at the core, there’s no real support for variables, arithmetic statements, and conditional statements. The work that has been done with PGFMath is wonderful, but it seems as if it is all built on a weak foundation.

        I’ve been hearing buzz words around LaTeX 3 every so often, and I believe things like this is one of the targets to be addressed in this development.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: