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.
\documentclass[tikz]{standalone}
\usepackage{tikz-3dplot}
\usepackage{pgfplots}
\pgfplotsset{compat = 1.8}

\begin{document}
\tdplotsetmaincoords{60}{130}
\begin{tikzpicture}[tdplot_main_coords]
  \begin{axis}[
    samples = 1000,
    domain = -pi / 2:4 * pi,
    samples y = 0,                                                       
    no markers,
    axis lines = none
    ]
    \draw[-latex] (axis cs: 0, 0, 0) -- (axis cs: 3, 0, 0);
    \draw[-latex] (axis cs: 0, 0, 0) -- (axis cs: 0, 3, 0);
    \draw[-latex] (axis cs: 0, 0, 0) -- (axis cs: 0, 0, 5);
    \addplot3 ({cos(deg(x))}, {sin(deg(x))}, {.5 * x});
  \end{axis}
\end{tikzpicture}
\end{document}

enter image description here

How can I have the tdplot_main_coords passed into pgfplots so my axis isn't all crazy?

share|improve this question
    
If I am not mistaken, you would like to blend stuff of tikz-3dplot and pgfplots seamlessly on top of each other. To this end, you may want to study Section "TikZ Interoperability" of the pgfplots manual. Note that pgfplots also offers the view={<h>}{<v>} key which allows to specify the rotation angles. I do not know if the angles are the same, but they can be transformed into each other. –  Christian Feuersänger Aug 31 '13 at 7:56
    
Plus you can use the 3D (axis cs:1,2,0) syntax for drawing things in pgfplots for 3D axes. –  percusse Aug 31 '13 at 8:57
    
@percusse that is what I have used to draw those lines but pgfplots isn't respecting tdplotsetmaincoords. It has issued an entirely different rotation that isn't even the standard look without the rotation of axis. –  dustin Aug 31 '13 at 16:37
    
@ChristianFeuersänger I have tried using view but I still can't produce the desired results. How would I transform my tdplotsetmaincoords into the corresponding view angles? –  dustin Aug 31 '13 at 16:38
1  
However, I am still unsure of what you want to archieve. Do you want to rotate a pgfplots axis and tikz-3dplot is what you have at hand? Then you may want to read the pgfplots manual and its associated view sections and set the manual of tikz-3dplot aside. Or do you want to combine tikz-3dplot and pgfplots for some reason? Then you have much more work in front of you and you should study the pgfplots manual section "Tikz Interoperability". –  Christian Feuersänger Aug 31 '13 at 18:47
show 2 more comments

2 Answers

up vote 2 down vote accepted

It seems to be as if tikz-3dplot angles \tdplotsetmaincoords{h}{v} can be transformed into those of pgfplots by means of view={H}{V} where H=h+45, V=v-90. In your case, you would have view={115}{20}. At least it seems so.

Regarding the comment why the -latex arrow head is ignored: I suppose it is because pgfplots has clipping active. Adding the option clip=false might help here (please correct me if I'm wrong).

share|improve this answer
    
clip = false did it. Also, should 60 + 45 = 105? Or did you mean 70 + h? –  dustin Sep 1 '13 at 11:01
    
:-D advanced summation has never been by strength (apparently). I'd say go with 105 if it looks good enough. Perhaps my rule of thumb does not fit at all; it was merely a guess (motivated by the fact that a similar heuristics appeared to work for gnuplot's view). I fear you will have to experiment until you found a good view. –  Christian Feuersänger Sep 1 '13 at 18:00
add comment

Here is an alternative solution that doesn't use pgfplots

helix

\documentclass[tikz]{standalone}
\usepackage{tikz-3dplot}

\begin{document}

\tdplotsetmaincoords{60}{130}
\begin{tikzpicture}[tdplot_main_coords]
\draw[->] (0,0,0) -- (2,0,0) node[right] {x};
\draw[->] (0,0,0) -- (0,2,0) node[left] {y};
\draw[->] (0,0,0) -- (0,0,3) node[above] {z};
\draw[thick,blue] (1,0,0)
\foreach \a in {0,0.1,...,15.71}
{ -- ({cos(deg(\a))},{sin(deg(\a)},{.10*\a})
};
\end{tikzpicture}

\end{document}
share|improve this answer
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.