Drawing a Clockwise Rectangle on the Complex Plane with Tikz

Click For Summary

Discussion Overview

The discussion revolves around drawing a rectangle on the complex plane using the TikZ package in LaTeX. Participants explore various aspects of creating the rectangle, including its orientation, size adjustments, and the addition of arrows and labels on the axes.

Discussion Character

  • Technical explanation
  • Exploratory
  • Debate/contested

Main Points Raised

  • One participant inquires about drawing a rectangle oriented clockwise on the complex plane with specified vertices.
  • Another participant provides TikZ code for drawing the rectangle but questions the meaning of "oriented clockwise."
  • A participant clarifies that clockwise refers to the path taken around the rectangle.
  • There are requests for additional features, such as arrows along the path and labeled axes, as well as concerns about the rectangle's size in the PDF output.
  • Some participants express skepticism about the significance of specifying the orientation as clockwise, suggesting that the final drawing does not reveal the drawing order.
  • Multiple code examples are shared, demonstrating how to include arrows and scale the drawing, with mentions of the TikZ cycle option for proper joins between segments.
  • Discussion includes references to the TikZ manual and resources for further learning about TikZ.

Areas of Agreement / Disagreement

Participants express differing views on the importance of the clockwise orientation, with some questioning its relevance while others emphasize the need for arrows to indicate direction. The discussion remains unresolved regarding the necessity of specifying orientation.

Contextual Notes

Participants mention limitations related to the size of the rectangle in the PDF and the complexity of the TikZ syntax, particularly when using the decorations library.

Who May Find This Useful

This discussion may be useful for individuals interested in LaTeX graphics, particularly those looking to create diagrams using TikZ, as well as those seeking to understand the nuances of orientation and labeling in graphical representations.

Dustinsfl
Messages
2,217
Reaction score
5
How can I draw a rectangle oriented clockwise on the complex plane with vertices on (0,0), (0,4), (10,4), and (10,0)?

I am guessing the tikz package needs to be used but I am not skilled in making pictures.
 
Physics news on Phys.org
If you say \usepackage{tikz}, then you can do

Code:
\tikz\draw (0,0) -- (0,4) -- (10,4) -- (10,0) -- cycle;

or

Code:
\begin{tikzpicture}
\draw (0,0) -- (0,4) -- (10,4) -- (10,0) -- cycle;
\end{tikzpicture}
What do you mean by a rectangle "oriented clockwise"?

I am sure you can easily do this using other LaTeX packages, but I don't know them very well.
 
Clockwise is the path you would take around the rectangle.

Ok so that worked but I also want the rectangle on the coordinate axis with arrows along the path and the axes labeled at at 0, 10 and 4. Is there a way to make the rectangle not as big on the pdf?
 
Last edited:
Well, after a rectangle is finished being drawn, nobody can tell whether it was drawn clockwise or counterclockwise. So I don't see the meaning in stipulating that it is oriented clockwise.
 
Evgeny.Makarov said:
Well, after a rectangle is finished being drawn, nobody can tell whether it was drawn clockwise or counterclockwise. So I don't see the meaning in stipulating that it is oriented clockwise.

I need arrows on the rectangle showing its orientation of clockwise.
 
Evgeny.Makarov said:
If you say \usepackage{tikz}, then you can do

Code:
\tikz\draw (0,0) -- (0,4) -- (10,4) -- (10,0) -- cycle;

or

Code:
\begin{tikzpicture}
\draw (0,0) -- (0,4) -- (10,4) -- (10,0) -- cycle;
\end{tikzpicture}
What do you mean by a rectangle "oriented clockwise"?

I am sure you can easily do this using other LaTeX packages, but I don't know them very well.

Although I've used Tikz for complicated diagrams and images before, I never knew about the cycle option. Thanks for posting that! (Nod)
 
Chris L T521 said:
Although I've used Tikz for complicated diagrams and images before, I never knew about the cycle option.
Yes, and besides shortening the notation, this option causes TikZ to create a proper join between the first and last segment. Here is a picture from TikZ manual.

https://lh4.googleusercontent.com/-k6SyrvG_Yns/T1QBS2e8I6I/AAAAAAAABbA/UyiDOLix9_A/s800/join.png

Here is the code for a rectangle with arrows.

Code:
\usetikzlibrary{arrows}
\begin{tikzpicture}[>=stealth',scale=.5]
\draw[->] (-1,0) -- (11,0);
\draw[->] (0,-1) -- (0,5);
\node[below left] at (0,0) {0};
\node[below] at (10,0) {10};
\node[left] at (0,4) {4};
\draw[thick,->] (0,0) -- (0,2);
\draw[thick,->] (0,2) -- (0,4) -- (5,4);
\draw[thick,->] (5,4) -- (10,4) -- (10,2);
\draw[thick,->] (10,2) -- (10,0) -- (5,0);
\draw[thick] (5,0) -- (0,0);
\end{tikzpicture}

This example uses the scale= option, which can be used in each \draw instruction individually or can apply to the whole picture if specified after \begin{tikzpicture}. It affects the specified coordinates, not the line lengths. The option -> adds the arrow tip only to the end of the path, so the rectangle has to consist of several paths.

A more sophisticated way is to use the decorations library.

Code:
\usetikzlibrary{arrows,decorations.markings}
\begin{tikzpicture}[>=stealth',scale=.5]
\draw[->] (-1,0) -- (11,0);
\draw[->] (0,-1) -- (0,5);
\node[below left] at (0,0) {0};
\node[below] at (10,0) {10};
\node[left] at (0,4) {4};
\draw[
  thick,
  decoration={
    markings,
    mark=at position 1/14 with {\arrow{>}},
    mark=at position 9/28 with {\arrow{>}},
    mark=at position 4/7 with {\arrow{>}},
    mark=at position 23/28 with {\arrow{>}}},
  postaction={decorate}] (0,0) -- (0,4) -- (10,4) -- (10,0) -- cycle;
\end{tikzpicture}

square1.png


One advantage is that this allows using the cycle construction, which, as said above, create the correct join at (0, 0). I agree that the syntax of the decorations is rather confusing. (Smile)
 
Evgeny.Makarov said:
Yes, and besides shortening the notation, this option causes TikZ to create a proper join between the first and last segment. Here is a picture from TikZ manual.

https://lh4.googleusercontent.com/-k6SyrvG_Yns/T1QBS2e8I6I/AAAAAAAABbA/UyiDOLix9_A/s800/join.png

Here is the code for a rectangle with arrows.

Code:
\usetikzlibrary{arrows}
\begin{tikzpicture}[>=stealth',scale=.5]
\draw[->] (-1,0) -- (11,0);
\draw[->] (0,-1) -- (0,5);
\node[below left] at (0,0) {0};
\node[below] at (10,0) {10};
\node[left] at (0,4) {4};
\draw[thick,->] (0,0) -- (0,2);
\draw[thick,->] (0,2) -- (0,4) -- (5,4);
\draw[thick,->] (5,4) -- (10,4) -- (10,2);
\draw[thick,->] (10,2) -- (10,0) -- (5,0);
\draw[thick] (5,0) -- (0,0);
\end{tikzpicture}

This example uses the scale= option, which can be used in each \draw instruction individually or can apply to the whole picture if specified after \begin{tikzpicture}. It affects the specified coordinates, not the line lengths. The option -> adds the arrow tip only to the end of the path, so the rectangle has to consist of several paths.

A more sophisticated way is to use the decorations library.

Code:
\usetikzlibrary{arrows,decorations.markings}
\begin{tikzpicture}[>=stealth',scale=.5]
\draw[->] (-1,0) -- (11,0);
\draw[->] (0,-1) -- (0,5);
\node[below left] at (0,0) {0};
\node[below] at (10,0) {10};
\node[left] at (0,4) {4};
\draw[
  thick,
  decoration={
    markings,
    mark=at position 1/14 with {\arrow{>}},
    mark=at position 9/28 with {\arrow{>}},
    mark=at position 4/7 with {\arrow{>}},
    mark=at position 23/28 with {\arrow{>}}},
  postaction={decorate}] (0,0) -- (0,4) -- (10,4) -- (10,0) -- cycle;
\end{tikzpicture}

square1.png


One advantage is that this allows using the cycle construction, which, as said above, create the correct join at (0, 0). I agree that the syntax of the decorations is rather confusing. (Smile)

You are great with the tikz stuff. On mhf, you would help with my commutative diagrams. Where do you get a manual for this?
 
  • #10
Chris L T521 said:
EDIT: The most up-to-date one is this one: http://math.mit.edu/~dspivak/files/pgfmanual.pdf
This is for version 2.0. Here is http://www.ctan.org/tex-archive/graphics/pgf/base/doc/generic/pgf/pgfmanual.pdf on CTAN. Besides, it is included in the distribution at doc/generic/pgf/pgfmanual.pdf.
 

Similar threads

  • · Replies 8 ·
Replies
8
Views
7K
  • · Replies 8 ·
Replies
8
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 0 ·
Replies
0
Views
6K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 3 ·
Replies
3
Views
5K