Hi Ignasi
Since this is more a diagram i would suggest you look into tikz drawing.
There it would have been much easier without suppressing a lot of what
pgfplots does.
I have given a small example below. It needs the last polish to exactly
match yours but is good as a starting point. :)
\begin{tikzpicture}
\draw[->] (0,0) node[left] {Nivell 1} -- ++(0,3) node[left] {Amplitud};
\draw[->] (0,0) -- ++(9,0) node[below] {temps};
\node[left] at (0,1) {Nivell 2};
\draw[blue!50!green,very thick] (0,1)
\foreach \lvl [remember=\lvl as \lastlvl (initially 1),count=\xi] in
{ 0,1,1,0,0,0,1,0} {
-- (\xi,\lastlvl) -- (\xi,\lvl)
};
\foreach \lvl [count=\xi] in {1,0,1,1,0,0,0,1} {
\node at (\xi-.5 ,1.4) {\lvl };
\draw[dashed] (\xi,0) -- (\xi,1.5);
}
\draw[<->] (0,2) -- node[above] {8 bits ...} ++(8,0);
\end{tikzpicture}
As you see it is much shorter without as many options as in pgfplots.
It also removes your problem 1,2,3 as you can suit it much better with tikz.
Kind regards Nick
2011/10/19 Ignasi Furió <ignasi.fu...@uib.cat>
> Hi all,
>
> i will have to draw some plot for digital signals similar to the one
> attached.
> I'm already satisfied with the result but i would like to know if its
> possible to obtain same result
> with easiest code. I understand that pgfplots is not focused on this kind
> of plots but it's the tool I know (not so better as I would like).
>
> Questions:
>
> 1.- Node with velocity (Velocitat) is not completely drawn unless ymax
> overpasses it. Could it be independent?
> 2.- I've managed to show bit intervals with \draw[dashed] inside
> \pgfplotsforeachungrouped. Would it be possible to draw them with ticks or
> grid (not so large as plot)?
> 3.- Do you know a better way of labelig each bit (another
> \pgfplotsforeachungrouped)?
>
> Thank you,
>
> Ignasi
>
> %------------------------------------------------
> \documentclass[border=3mm]{standalone}
> \usepackage{pgfplots}
>
> \begin{document}
> \begin{tikzpicture}[font=\sffamily]
> \begin{axis}[x=1cm,y=1cm,
> every axis plot post/.append style={mark=none},
> cycle list name=exotic,
> axis y line=left,
> axis x line=middle,
> xmax=10,
> ymin=-0.2,
> ymax=2.8,
> xtick={8},
> xticklabels={1},
> ytick={0,1},
> yticklabels={Nivell 1, Nivell 2},
> xlabel={temps},
> every axis y label/.style={at={(current axis.above
> origin)},anchor=north
> east},
> every axis x label/.style={at={(current axis.right of
> origin)},anchor=north east},
> ylabel={Amplitud},
> every axis plot/.append style={line width=2pt},
> ]
> \addplot+[const plot] coordinates {(0,1) (1,0) (2,1) (4,0) (7,1) (8,0)};
> \pgfplotsforeachungrouped \i/\j in {1/0,0/1,1/2,1/3,0/4,0/5,0/6,1/7}
> {\edef\temp{\noexpand\node at ([xshift=.5cm]axis cs:\j,1.3)
> {\i};}\temp}
> \pgfplotsforeachungrouped \i in {1,2,...,8}
> {\edef\temp{\noexpand\draw[dashed] (axis cs:\i,0)--(axis
> cs:\i,1.5);}\temp}
> \draw[<->] (axis cs:0,1.7) -- (axis cs:8,1.7) node [midway,above,text
> width=3cm,font=\sffamily\small,align=center]{8 bits en 1 segon\\Velocitat
> = 8 bps};
> \node[font=\sffamily] at (axis cs:8.5,0.2) {\dots};
> %
> \end{axis}
> \end{tikzpicture}
> \end{document}
> %----------------------------------------------------
>
>
> ------------------------------------------------------------------------------
> All the data continuously generated in your IT infrastructure contains a
> definitive record of customers, application performance, security
> threats, fraudulent activity and more. Splunk takes this data and makes
> sense of it. Business sense. IT sense. Common sense.
> http://p.sf.net/sfu/splunk-d2d-oct
> _______________________________________________
> Pgfplots-features mailing list
> Pgfplots-features@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pgfplots-features
>
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct
_______________________________________________
Pgfplots-features mailing list
Pgfplots-features@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pgfplots-features