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.

here's a drawing I just made (the sine function are replaced by external datas)

\documentclass[12pt]{article}
\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{through,calc,arrows,decorations.pathmorphing,backgrounds,positioning,fit}


\begin{document}
\begin{figure}
 \begin{tikzpicture}
 \def\decalx{-0.8};
 \def\decaly{-0.9};


 \foreach \pas in {340,320,...,0} 
{
\begin{scope}[xshift=\decalx*(340-\pas),yshift=\decaly*(340-\pas)]
    \begin{axis}[xmax=600,ymin=-1,ymax=1,xtick=\empty,ytick=\empty,axis x line=middle,axis y line = left]
       \addplot[fill=black!5!white,fill opacity=0.5, domain=0:360] expression {sin(\pas/100*\x)};
    \end{axis}
    \end{scope}
    }

\begin{scope}[xshift=-2.8cm,yshift=-10.8cm]
\begin{axis}[,x={(-\decalx,-\decaly)},anchor=south west,xmin=0,xticklabel style={xshift=5},xtick={90,270},axis x line=middle,hide y axis]
\addplot[blue,samples=19,domain=0:360,error bars/.cd, y dir=minus,y fixed relative=1, error mark=none, error bar style={dotted}]  {sin(x)};
\end{axis}
\end{scope}
\end{tikzpicture}
\end{figure}

\end{document}

The thing is the blue curve is placed by trial and error, depending on the width, height, y min and max values and a bunch of other stuffs... Is there any way to extract the coordinate of the foreground plot's x axis so that I can draw the final blue chart from it ??? the hard part is probably that this blue curved is skewed...

I've been doing this by hand so far and I can definitely keep on doing it, it's just that I have to make tens of these, and it takes forever to compile with my 300 points data tables...

thanks !!!!

//EDIT///

If I need a ymin or ymax parameter Ant's solution doesn't work anymore...

\documentclass[12pt]{article}
\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{through,calc,arrows,decorations.pathmorphing,backgrounds,positioning,fit}


\begin{document}
\begin{figure}
 \begin{tikzpicture}
 \def\decalx{-0.6};
 \def\decaly{-0.9};
\def\ymin{-0.5};

 \foreach \pas in {340,320,...,0} 
{
\begin{scope}[xshift=\decalx*(340-\pas),yshift=\decaly*(340-\pas)]
    \begin{axis}[xmax=600,ymin=\ymin,ymax=1,xtick=\empty,ytick=\empty,axis x line=middle,axis y line = left]
       \addplot[fill=black!5!white,fill opacity=0.5, domain=0:360] expression {sin(\pas/100*\x)};
    \end{axis}
    \end{scope}
    }


    \begin{scope}[xshift=\decalx*(340),yshift=\decaly*(340)]
    \begin{axis}[xmax=600,ymin=\ymin,ymax=1,xtick=\empty,ytick=\empty,axis x line=middle,axis y line = left]
       \addplot[fill=black!5!white,fill opacity=0.5, domain=0:360]
       expression {0};
       \node (start blue axis here) at (rel axis cs:1, 0) {};
     \end{axis}
  \end{scope}


  \begin{axis}[at=(start blue axis here), x={(-\decalx,-\decaly)},anchor=south
    west,xmin=0,xticklabel style={xshift=5},xtick={90,270},axis x
    line=middle,hide y axis]
    \addplot[blue,samples=19,domain=0:360,error bars/.cd, y
    dir=minus,y fixed relative=1, error mark=none, error bar
    style={dotted}] {sin(x)};
\end{axis}

\end{tikzpicture}
\end{figure}

\end{document}
share|improve this question
    
If I am not mistaken, you have data sets f(t;i) for i = 1,...,N and you'd like to visualize the N functions in some sort of 3D axis AND a slice with fixed t and varying i, something like F_t(i), right? I think pgfplots cannot do this on its own - at least not without considerable work using pgfplotstable (which might be inefficient, though). Pgfplots is neither matlab nor octave. However, its \addplot shell feature might be a help - if you are willing to use 3rd party tools. These could be plain text-based like sed/cat or table tools as matlab or octave or whatever you have at hand. –  Christian Feuersänger Aug 5 '11 at 14:42

1 Answer 1

up vote 0 down vote accepted

You can place a node, when drawing the last rectilinear axis, to which you align the skew axis. See below for an annotated version of your example:

\documentclass[12pt]{article}
\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{through,calc,arrows,decorations.pathmorphing,backgrounds,positioning,fit}


\begin{document}
\begin{figure}
 \begin{tikzpicture}
 \def\decalx{-0.8};
 \def\decaly{-0.9};


 \foreach \pas in {340,320,...,20} 
{
\begin{scope}[xshift=\decalx*(340-\pas),yshift=\decaly*(340-\pas)]
    \begin{axis}[xmax=600,ymin=-1,ymax=1,xtick=\empty,ytick=\empty,axis x line=middle,axis y line = left]
       \addplot[fill=black!5!white,fill opacity=0.5, domain=0:360] expression {sin(\pas/100*\x)};
    \end{axis}
    \end{scope}
    }

All of this is as before, except that I've taken the last axis out of the foreach loop and added it below.

\begin{scope}[xshift=\decalx*(340),yshift=\decaly*(340)]
    \begin{axis}[xmax=600,ymin=-1,ymax=1,xtick=\empty,ytick=\empty,axis x line=middle,axis y line = left]
       \addplot[fill=black!5!white,fill opacity=0.5, domain=0:360]
       expression {0};
       \node (start blue axis here) at (axis cs:\pgfkeysvalueof{/pgfplots/xmax}, 0) {};
     \end{axis}
  \end{scope}

The rel axis cs coordinate system makes it easy to put the node where the skew axis should start. And now we just use the at key in place of the scope you had before:

  \begin{axis}[at=(start blue axis here), x={(-\decalx,-\decaly)},
    anchor=left of origin,
    xmin=0,xticklabel style={xshift=5},xtick={90,270},axis x
    line=middle,hide y axis]
    \addplot[blue,samples=19,domain=0:360,error bars/.cd, y
    dir=minus,y fixed relative=1, error mark=none, error bar
    style={dotted}] {sin(x)};
\end{axis}

\end{tikzpicture}
\end{figure}

\end{document}

...which produces the same diagram as the original example.

Edited to align by x axes rather than bottom right corner, so that you can change the y axis scale, following discussion in comments.

share|improve this answer
    
You will see that this actually works by aligning the lower left corner of the skew graph with the lower right corner of the rectilinear one. If you prefer, you can align the ends of the respective x axes by using anchor=left of origin and (axis cs:\pgfkeysvalueof{/pgfplots/xmax}, 0). –  Ant Aug 5 '11 at 14:53
    
hey ant thanks a lot. however something doesn't work, if I add a ymin parameter the curve doesn't stick anymore to the axis tip... see my edited question –  ben paillard Aug 5 '11 at 15:07
    
Odd... your revised example still compiles well for me. It sounds like this might be solved by my earlier comment though - did you try that? –  Ant Aug 5 '11 at 15:43
    
oh sorry for that try changing the \ymin value to like 0.5 –  ben paillard Aug 5 '11 at 15:49
    
Yep, I see what you mean, but my comment does fix this. Answer now edited to include the changes described above. –  Ant Aug 5 '11 at 16:09

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.