0

Is it possible to draw this graph in latex ?

enter image description here

I want to rotate the given picture so that I can get a horizontal picture of this.

I tried using

  1. \includegraphics[angle=270,origin=c]{pic}

  2. \begin{sidewaysfigure} \includegraphics[scale=0.75]{pic}% \label{fig:fig1} \end{sidewaysfigure}

But in both cases the letters in the vertices are also getting rotated.

This is what I get when I use the above commands.

enter image description here

How can I make a horizontal graph with vertices $S,[0],T$ ?

Can someone please help me to draw it?

I want to draw this

enter image description here

2
  • It is very easy to do it either with TikZ or pstricks.
    – Bernard
    Commented Dec 26, 2019 at 17:26
  • @Bernard; can you please show how to do it
    – Charlotte
    Commented Dec 26, 2019 at 17:28

2 Answers 2

1

In TikZ, this is basically the difference between using transform shape and not using it. If you use it, the texts get rotated, otherwise they don't.

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[nodes={circle,draw,fill=red!20,font=\sffamily,inner sep=1pt}]
 \draw (0,0) node{T} -- (80:2) node{O} -- ++(80:2) node{S};
\end{tikzpicture}
\bigskip

\begin{tikzpicture}[nodes={circle,draw,fill=red!20,font=\sffamily,inner
sep=1pt},rotate=-90]
 \draw (0,0) node{T} -- (80:2) node{O} -- ++(80:2) node{S};
\end{tikzpicture}
\bigskip

\begin{tikzpicture}[nodes={circle,draw,fill=red!20,font=\sffamily,inner
sep=1pt},rotate=-90,transform shape]
 \draw (0,0) node{T} -- (80:2) node{O} -- ++(80:2) node{S};
\end{tikzpicture}
\end{document}

enter image description here

To just produce the figure, you could use

\documentclass{article}
\usepackage{tikz}
\usepackage{eqparbox}
\newbox\nodebox
\tikzset{equal size/.style={execute at begin
 node={\setbox\nodebox=\hbox\bgroup},
 execute at end
 node={\egroup\eqmakebox[#1][c]{\copy\nodebox}}}}
\begin{document}
\begin{tikzpicture}[nodes={equal size=S,
 circle,draw,fill=red!20,font=\sffamily,inner sep=1pt}]
 \draw (0,0) node{T} -- (2.5,0) node{[O]} -- ++(2.5,0) node{S};
\end{tikzpicture}
\end{document}

enter image description here

Note that there are no hard coded distances yet the nodes have the same size.

1
  • Thanks a lot for posting such a detailed code, +1
    – Charlotte
    Commented Dec 27, 2019 at 3:21
1

Here is a way with pstricks:

 \documentclass[svgnames]{standalone}
\usepackage[svgnames]{xcolor}
\usepackage{pst-node}
\usepackage{auto-pst-pdf} 


\begin{document}
\sffamily
\begin{pspicture}(-3.5,-0.5)(3.5,0.5)
\psset{fillcolor=MistyRose, fillstyle=solid, framesep=3.3pt}
    \cnodeput[](-3,0){S}{S}
    \cnodeput[framesep=0.6pt](0,0){O}{[0]}
    \cnodeput(3,0){T}{T}
    \ncline{S}{O}\ncline{O}{T}
\end{pspicture}

\end{document}

enter image description here

1
  • Thanks a lot for posting such a detailed code, +1
    – Charlotte
    Commented Dec 27, 2019 at 3:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .