Ticker

6/recent/ticker-posts

Draw Regular Polygons in Tikz LaTeX

Draw Regular Polygons in Tikz \(\LaTeX\)

Polygons (see more details.) are 2-dimensional shapes. They are made of straight lines, and the shape is "closed" (all the lines connect up). A regular polygon has all angles equal and all sides equal, otherwise it is irregular. Polygons can easily be created in Tikz \(\LaTeX\) and properties of the shapes can be enhanced.


Commands

  • \documentclass[margin=5mm]{standalone} --- to create a standalone document with 5 mm on all the sides
  • \usepackage{tikz} --- to create Tikzpicture environment
  • \usepackage{pgfplots} --- to generate high quality graphs/shapes within \(\LaTeX\)
  • \usetikzlibrary{shapes.geometric} --- to generate regular polygons
  • \foreach \i in {3,4,5,6,...,10} --- this is for loop in pgfplots iterating from 3 to 10
  • \i --- take value from the array generated in for loop
  • blue!\i! --- concentration of blue color
  • (4*\i,1) --- polygons are placed at the multiples of 4 separated horizontally when \(y=1\) e.g., \((12,1),(16,1)\) and so on...

\(\LaTeX\) Code

\documentclass[margin=5mm]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{shapes.geometric}
\begin{document}
\begin{tikzpicture}
\foreach \i in {3,4,5,6,...,10}
\node[regular polygon,draw,regular polygon sides = \i,fill = blue!\i!,minimum size = 3cm] (p) at (4*\i,1) {};
\end{tikzpicture}
\end{document}

OUTPUT


Related Questions

  • tikz regular polygon
  • tikz manual
  • tikz fill shape
  • how to draw triangle in latex
  • how to draw square in latex
  • how to draw pentagon in latex
  • how to draw hexagon in latex
  • how to draw octagon in latex
  • how to draw triangle in tikz
  • how to draw square in tikz
  • how to draw pentagon in tikz
  • how to draw hexagon in tikz
  • how to draw octagon in tikz

Post a Comment

0 Comments