Drawing a Clockwise Rectangle on the Complex Plane with Tikz

In summary: On Linux systems, one can copy it to the documentation directory of the TeX installation, which is usually /usr/share/texmf/doc. Then the command texdoc pgfmanual should open the manual.In summary, to draw a rectangle with vertices on (0,0), (0,4), (10,4), and (10,0) and arrows representing a clockwise orientation, the tikz package can be used with the command\tikz\draw (0,0) -- (0,4) -- (10,4) -- (10,0) -- cycle;or \begin{tikzpicture}\draw (0,0) -- (0,4) -- (10,4
  • #1
Dustinsfl
2,281
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
  • #2
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.
 
  • #3
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:
  • #4
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.
 
  • #5
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.
 
  • #6
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)
 
  • #7
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)
 
  • #8
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?
 
  • #9
  • #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.
 

FAQ: Drawing a Clockwise Rectangle on the Complex Plane with Tikz

1. How do I draw a clockwise rectangle on the complex plane using Tikz?

To draw a clockwise rectangle on the complex plane using Tikz, you will need to use the following command: \draw (x,y) rectangle (a,b); where (x,y) represents the coordinates of the bottom left corner of the rectangle and (a,b) represents the coordinates of the top right corner.

2. Can I specify the color and thickness of the rectangle's border?

Yes, you can specify the color and thickness of the rectangle's border by using the \draw[options] command. For example, \draw[blue, thick] (x,y) rectangle (a,b); will draw a rectangle with a blue border that is thicker than the default thickness.

3. How do I rotate the rectangle on the complex plane?

To rotate the rectangle on the complex plane, you can use the \draw[rotate=angle] command. For example, \draw[rotate=45] (x,y) rectangle (a,b); will rotate the rectangle by 45 degrees in a counterclockwise direction.

4. Can I add labels or text to the rectangle?

Yes, you can add labels or text to the rectangle by using the \node[text options] at (x,y) {text}; command. This will create a node at the specified coordinates with the given text. You can also use the \draw (x,y) node[text options] {text}; command to draw the rectangle and label in one line of code.

5. Is there a way to fill the rectangle with color?

Yes, you can fill the rectangle with color by using the \fill[fill options] (x,y) rectangle (a,b); command. This will fill the rectangle with the specified color and any additional options such as pattern or opacity. You can also use the \draw[fill=fillcolor] (x,y) rectangle (a,b); command to draw the rectangle and fill it with color in one line of code.

Similar threads

Replies
1
Views
1K
Replies
8
Views
6K
Replies
1
Views
1K
Replies
1
Views
5K
Replies
3
Views
3K
Replies
3
Views
1K
Replies
3
Views
4K
Replies
1
Views
7K
Back
Top