cm bug?

View: New views
5 Messages — Rating Filter:   Alert me  

cm bug?

by koslowj :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

First of all, thanks to Alain Matthes for his suggestions concerning my sample diagram!  

Concerning my initial suspicion that the coordinate transformation via cm may have a bug:  It does transform angles correctly, and this transformation also applies to out= and in= specifications for drawing curved arrows or lines.  On the other hand, specifying x and y separately also produces the correct angles, however, the out= and in= specifications are NOT AFFECTED by this.   This makes it easier to achieve certain desired effects, so I don't think this is bad.  But I couldn't find this in the manual.

Where the cm transformation does behave oddly is with regard to the targets of curved arrows.  These seem to be off, i.e., not at the center of B and C, respectively, while the sources seem to be correct.  In fact, the offset of the target seems to depend on the angle, otherwise the red and blue arrows should be symmetric.   The correct shape may be the one in the first diagram.  Also, the second green arrow ought to be straight.  Can someone please shed some light on this, or even better, fix this?

Thanks, -- Jürgen

\documentclass{article}
\usepackage{tikz}

\begin{document}
\centering

\[\begin{tikzpicture}
  [baseline=(A.base),scale=1.75,
% uncomment at most one of the following 4 lines:
%    x={(cos{30},-.5)},y={(2*cos{30}, 1)}
%    y={(cos{30}, .5)},x={(2*cos{30},-1)}
    x=(-30:1),y=( 45:sqrt(2))
%    y=( 30:1),x=(-30:2)
  ]
  \node (A) at (0,0) {$A$};
  \node (B) at (2,0) {$B$};
  \node (C) at (0,2) {$C$};
  \draw (A) circle [radius=1];
  \node at (  0:1){$_0$};
  \node at (-30:1){$_{-30}$};
  \node at (-60:1){$_{-60}$};
  \node at (-90:1){$_{-90}$};
  \node at (-120:1){$_{-120}$};
  \node at (-150:1){$_{-150}$};
  \node at (180:1){$_{180}$};
  \node at (30:1){$_{30}$};
  \node at (60:1){$_{60}$};
  \node at (90:1){$_{90}$};
  \node at (120:1){$_{120}$};
  \node at (150:1){$_{150}$};
  \draw[->,out=-60,in=-120](A) to node[auto,swap]{} (B);
  \draw[->,out= 60,in= 120](A) to node[auto,swap]{} (C);
  \draw[->](A) to node[auto,swap]{} (C);
  \draw[->,out=0,in=-180,green](A) to node[auto,swap]{} (B);
  \end{tikzpicture}
  \qquad
  \begin{tikzpicture}
  [baseline=(A.base),scale=1.75,
    cm={cos{30},-.5,cos{30},.5,(0,0)}]
  \node (A) at (0,0) {$A$};
  \node (B) at (2,0) {$B$};
  \node (C) at (0,2) {$C$};
  \node at (  0:1){$_0$};
  \node at (-30:1){$_{-30}$};
  \node at (-60:1){$_{-60}$};
  \node at (-90:1){$_{-90}$};
  \node at (-120:1){$_{-120}$};
  \node at (-150:1){$_{-150}$};
  \node at (180:1){$_{180}$};
  \node at (30:1){$_{30}$};
  \node at (60:1){$_{60}$};
  \node at (90:1){$_{90}$};
  \node at (120:1){$_{120}$};
  \node at (150:1){$_{150}$};
  \draw (A) circle [radius=1];
  \draw[->,out=-60,in=-120](A) to node[auto,swap]{} (B);
  \draw[->,out=-30,in=-60,red](A) to node[auto,swap]{} (B);
  \draw[->,out=110,in= 150,blue](A) to node[auto,swap]{} (C);
  \draw[->](A) to node[auto,swap]{} (C);
  \draw[->,out=0,in=-180,green](A) to node[auto,swap]{} (B);
  \end{tikzpicture}
  \]

\end{document}

Putting boxes around multiple nodes

by Evan Driscoll :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am using the automaton library to draw an automaton (surprise!) and
have a question.

I'd like to put a box around some nodes to emphasize those nodes. One
way to do this is to just use some \draw rectangle commands in the same
picture, then try to work out what the coordinates should be. However,
this seems like it'd be brittle to layout changes since if I changed the
node spacing or whatever then the coordinates would be wrong.

While that problem isn't the end of the world or anything, it'd be nice
to know whether there is a better way to do this.


And just in case it's not clear, there's a sufficient example of what I
want to draw at http://www.graphviz.org/Gallery/directed/cluster.html.

Thanks,
Evan Driscoll


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
pgf-users mailing list
pgf-users@...
https://lists.sourceforge.net/lists/listinfo/pgf-users

Re: Putting boxes around multiple nodes

by Mark Wibrow-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

Available from (I think) version 2.0 the fit library should do what
you want. If you use layers you can get the boxes behind the nodes a
lot more easily.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric,fit,chains,scopes}
\begin{document}

\pgfdeclarelayer{background}
\pgfsetlayers{background,main}

\tikzset{
        a-oval/.style={
                ellipse,
                fill=white,
                draw=none
        },
        b-oval/.style={
                ellipse,
                fill=gray!20,
                draw=black
        },
        a-enclosure/.style={
                rectangle,
                fill=gray!20,
                draw=none,
                inner sep=0.5cm
        },
        b-enclosure/.style={
                rectangle,
                fill=white,
                draw=black,
                inner sep=0.5cm
        },
        every join/.style=->,
        >=latex
}
\begin{tikzpicture}

{ [start chain=going below]
  \foreach \i in {0,...,3}
          \node [a-oval, on chain, join] (a-\i) {a-\i};
}

{ [start chain=going below, xshift=3cm]
  \foreach \i in {0,...,3}
          \node [b-oval, on chain, join] (b-\i) {b-\i};
}

\begin{pgfonlayer}{background}
        \node [a-enclosure, fit={(a-0) (a-3)}] {};
        \node [b-enclosure, fit={(b-0) (b-3)}] {};
\end{pgfonlayer}

\end{tikzpicture}
\end{document}


Regards

Mark

2009/10/8 Evan Driscoll <driscoll@...>:

> I am using the automaton library to draw an automaton (surprise!) and
> have a question.
>
> I'd like to put a box around some nodes to emphasize those nodes. One
> way to do this is to just use some \draw rectangle commands in the same
> picture, then try to work out what the coordinates should be. However,
> this seems like it'd be brittle to layout changes since if I changed the
> node spacing or whatever then the coordinates would be wrong.
>
> While that problem isn't the end of the world or anything, it'd be nice
> to know whether there is a better way to do this.
>
>
> And just in case it's not clear, there's a sufficient example of what I
> want to draw at http://www.graphviz.org/Gallery/directed/cluster.html.
>
> Thanks,
> Evan Driscoll
>
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> _______________________________________________
> pgf-users mailing list
> pgf-users@...
> https://lists.sourceforge.net/lists/listinfo/pgf-users
>

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
pgf-users mailing list
pgf-users@...
https://lists.sourceforge.net/lists/listinfo/pgf-users

Re: Putting boxes around multiple nodes

by Evan Driscoll :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Mark Wibrow wrote:
> Hi,
>
> Available from (I think) version 2.0 the fit library should do what
> you want. If you use layers you can get the boxes behind the nodes a
> lot more easily.

That's exactly what I wanted. Thanks very much!

Evan


>
> \documentclass{article}
> \usepackage{tikz}
> \usetikzlibrary{shapes.geometric,fit,chains,scopes}
> \begin{document}
>
> \pgfdeclarelayer{background}
> \pgfsetlayers{background,main}
>
> \tikzset{
> a-oval/.style={
> ellipse,
> fill=white,
> draw=none
> },
> b-oval/.style={
> ellipse,
> fill=gray!20,
> draw=black
> },
> a-enclosure/.style={
> rectangle,
> fill=gray!20,
> draw=none,
> inner sep=0.5cm
> },
> b-enclosure/.style={
> rectangle,
> fill=white,
> draw=black,
> inner sep=0.5cm
> },
> every join/.style=->,
> >=latex
> }
> \begin{tikzpicture}
>
> { [start chain=going below]
>   \foreach \i in {0,...,3}
>  \node [a-oval, on chain, join] (a-\i) {a-\i};
> }
>
> { [start chain=going below, xshift=3cm]
>   \foreach \i in {0,...,3}
>  \node [b-oval, on chain, join] (b-\i) {b-\i};
> }
>
> \begin{pgfonlayer}{background}
> \node [a-enclosure, fit={(a-0) (a-3)}] {};
> \node [b-enclosure, fit={(b-0) (b-3)}] {};
> \end{pgfonlayer}
>
> \end{tikzpicture}
> \end{document}
>
>
> Regards
>
> Mark
>
> 2009/10/8 Evan Driscoll <driscoll@...>:
>> I am using the automaton library to draw an automaton (surprise!) and
>> have a question.
>>
>> I'd like to put a box around some nodes to emphasize those nodes. One
>> way to do this is to just use some \draw rectangle commands in the same
>> picture, then try to work out what the coordinates should be. However,
>> this seems like it'd be brittle to layout changes since if I changed the
>> node spacing or whatever then the coordinates would be wrong.
>>
>> While that problem isn't the end of the world or anything, it'd be nice
>> to know whether there is a better way to do this.
>>
>>
>> And just in case it's not clear, there's a sufficient example of what I
>> want to draw at http://www.graphviz.org/Gallery/directed/cluster.html.
>>
>> Thanks,
>> Evan Driscoll
>>
>>
>> ------------------------------------------------------------------------------
>> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
>> is the only developer event you need to attend this year. Jumpstart your
>> developing skills, take BlackBerry mobile applications to market and stay
>> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
>> http://p.sf.net/sfu/devconference
>> _______________________________________________
>> pgf-users mailing list
>> pgf-users@...
>> https://lists.sourceforge.net/lists/listinfo/pgf-users
>>


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
pgf-users mailing list
pgf-users@...
https://lists.sourceforge.net/lists/listinfo/pgf-users

Re: Putting boxes around multiple nodes

by koslowj :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Please don't hijack other peoples threads!  Your question (and Mark's answer) are interesting in their own right, so they deserve their own thread, also for later reference.

-- Juergen