# Tag Info

38

Here's a quick option: \begin{tikzpicture} \foreach \i in {0,...,3} \foreach \j in {0,...,3} { \foreach \a in {0,120,-120} \draw (3*\i,2*sin{60}*\j) -- +(\a:1); \foreach \a in {0,120,-120} \draw (3*\i+3*cos{60},2*sin{60}*\j+sin{60}) -- +(\a:1);} \end{tikzpicture} Which results in

34

With TikZ, you can define a pattern which allows to fill any shape with a hexagonal grid by adding the option pattern=hexagons: \documentclass{article} \usepackage{tikz} \usetikzlibrary{patterns} \def\hexagonsize{0.5cm} \pgfdeclarepatternformonly {hexagons}% name {\pgfpointorigin}% lower left {\pgfpoint{3*\hexagonsize}{0.866025*2*\hexagonsize}}% ...

30

A funny solution (have you ever used lindenmayersystems library?): \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{lindenmayersystems} \begin{document} \begin{tikzpicture} \pgfdeclarelindenmayersystem{triangular grid}{\rule{F->F-F+++F--F}} \path[draw=black, l-system={triangular grid,step=1cm, angle=-60,axiom=F--F--F,order=4, }] ...

28

As with most of the settings in pgfplots, you can set these things globally in the preamble using \pgfplotsset For example minor ticks: \pgfplotsset{minor grid style={dashed,red}} major ticks: \pgfplotsset{major grid style={dotted,green!50!black}} both minor and major ticks: \pgfplotsset{grid style={dashed,gray}} A complete MWE follows ...

26

A try in pgfplots in case you ever decide to learn/use it. :-) In this case, much of the code is setting up the styling to match your example. This could be stored as a style defined once in your document, as I have done, and used for consistent style for all plots. There is surely a better way to draw the double line at the outer edge. I tried lots of ...

26

Like Leo said: use \foreach and some math: \usetikzlibrary{calc} \newcommand*\rows{10} \begin{tikzpicture} \foreach \row in {0, 1, ...,\rows} { \draw ($\row*(0.5, {0.5*sqrt(3)})$) -- ($(\rows,0)+\row*(-0.5, {0.5*sqrt(3)})$); \draw ($\row*(1, 0)$) -- ($(\rows/2,{\rows/2*sqrt(3)})+\row*(0.5,{-0.5*sqrt(3)})$); \draw ($\row*(1, 0)$) ...

24

If you make the coordinates not an exact multiple of the step size you can get this effect: \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} \draw[step=0.5cm,color=gray] (.75,.75) grid (3.75,3.75); \end{tikzpicture} \end{document}

24

Okay, here’s what I came up with. It isn’t in the “spirit” of the question, since I haven’t used any of TikZ’s polar coordinate features: instead, I just drew the grid on by hand and with some basic loops. This is the code I used, with some hopefully self-explanatory comments: \documentclass{article} \usepackage{tikz} \begin{document} ...

21

Here's a solution that uses to paths to execute arbitrary code in the guise of a simple command. If the preamble were hidden away in a package, the invocation would just be: \begin{tikzpicture} \draw (-2,-2) to[grid with coordinates] (7,4); \end{tikzpicture} The sneaky trick is to use the fact that the to path declaration can contain arbitrary code via a ...

20

A very basic approach using grid: \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} \draw (0,0) grid (3,3); \draw (0,4) grid (3,7); \draw (4,0) grid (7,3); \draw (4,4) grid (7,7); \foreach \i/\valor in {1/1,2/2,3/3,5/n-2,6/n-1,7/n} { \node[anchor=south] at (\i-0.5,7) {$\valor$}; \node[anchor=east] at (0,-\i+7.5) ...

18

You could use PGFplots (version 1.5) for this. It can draw polar axes with very flexible customisation possibilities: \documentclass{article} \usepackage{pgfplots} \usepgfplotslibrary{polar} \begin{document} \begin{tikzpicture} \begin{polaraxis}[ width=40cm, xmin=160,xmax=200, ymin=2,ymax=3, yticklabels={}, xtick={160,165,...,200}, ...

18

Version 1.5 of pgfplots includes a Smith chart library. This is an example from its manual \documentclass{standalone} \usepackage{pgfplots} \usepgfplotslibrary{smithchart} \begin{document} \begin{tikzpicture}[scale=0.75] \begin{smithchart}[ title=Huge Smith Chart (rescaled), width=20cm] \addplot coordinates {(0.5,0.2) (1,0.8) (2,2)}; \end{smithchart} ...

13

A slightly different solution using a matrix transformation and clipping: \newcommand*{\rows}{10} \pgfmathsetmacro{\xcoord}{cos(60)} \pgfmathsetmacro{\ycoord}{sin(60)} \begin{tikzpicture} \pgftransformcm{1}{0}{\xcoord}{\ycoord}{\pgfpointorigin} \path[clip,preaction = {draw=black}] (\rows,0) -- (0,0) -- (0,\rows) -- cycle; \draw (0,0) grid ...

13

In the pgfmanual it says on p. 145 that due to rounding errors, the "last" lines of a grid may be omitted. In this case, you have to add an epsilon to the corner points In this case, you will have to subtract an epsilon, i.e. a very small value, from the corner point. Something like \draw[step=0.5cm,color=gray] (2-0.001,2-0.001) grid (4,4); ...

12

TikZ doesn't have a node shape of this form. But since it is just a rectangle with some added lines, it is relatively straightforward to define (once knowing how to define shapes). \documentclass{article} \usepackage{tikz} \usetikzlibrary{positioning} \makeatletter \pgfkeys{/pgf/grid lines/.initial=2} \pgfdeclareshape{grid}{ % inherit most things from ...

12

To get a minor grid you need minor ticks. You can enable those with e.g. minor tick num=2 which adds two minor ticks between each major tick. \documentclass[11pt]{standalone} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[grid=both,xlabel={error},ylabel={power},minor tick num=2] ...

11

Late to the party but another opportunity of nonlinear transformations and pretty printing radians for me. I stole the plotted function from alexwlchan's answer. \documentclass[tikz]{standalone} \usetikzlibrary{fpu} \usepgfmodule{nonlineartransformations} \makeatletter ...

10

Yes, it can be done in TikZ. I enclose my try. %! *latex mal-polar.tex \documentclass[a4paper]{article} \pagestyle{empty} \usepackage{tikz} \begin{document} \begin{tikzpicture}[>=latex] \fill[fill=lightgray] plot[domain=-pi/2:pi/2] (xy polar cs:angle=\x r,radius= {2-2*sin(\x r)}); \draw[thick, color=red, domain=0:2*pi, samples=200,smooth] plot (xy polar ...

10

If a naive solution is also OK: \documentclass{article} \usepackage{graphicx} \usepackage{subfig} \begin{document} \begin{figure} \begin{tabular}{cc} \includegraphics[width=65mm]{it} & \includegraphics[width=65mm]{it} \\ (a) first & (b) second \\[6pt] \includegraphics[width=65mm]{it} & \includegraphics[width=65mm]{it} \\ (c) third & ...

10

If you care for something a bit fancier, you could also try that one: \documentclass{article} \usepackage{tikz} \usetikzlibrary{fadings} \begin{document} \begin{tikzpicture} \draw[step=0.5cm,color=gray,path fading=south] (.99,.75) grid (3.5,1); \draw[step=0.5cm,color=gray,path fading=north] (.99,3.5) grid (3.5,3.75); ...

10

The eso-pic package lets you add material to each page. With TikZ you can draw a nice background grid. \documentclass{article} \usepackage{tikz} \usepackage{eso-pic} \AddToShipoutPicture{% \begin{tikzpicture}[overlay,remember picture] \draw[thick,red] (current page.north east) rectangle (current page.south west); ...

10

Not exactly an answer because I think it's more complicated to transform a tool than to create a new tool. Like Andrew says it's impossible in your case. Here a macro : ( I made this code in few minutes also I think tikz's expert can do a better macro with more options) \documentclass{article} \usepackage{fullpage,tikz} \makeatletter \pgfkeys{% ...

9

This should do what you want. A box consisting of the requested number of lines, drawn at the baselines, is added with \AtBeginShipout. \documentclass{article} \usepackage{atbegshi,picture,xcolor} \AtBeginShipout{% \AtBeginShipoutUpperLeft{% \color{red}% \put(\dimexpr 1in+\oddsidemargin, -\dimexpr ...

9

Not hard to do in Metapost... prologues := 3; outputtemplate := "%j%c.eps"; beginfig(1); s = 1cm; path f; f = (for t = 0 upto 359: (cosd(t), sind(t)) scaled (2-2sind(t)) .. endfor cycle) scaled s; fill subpath(0,90) of f -- subpath(270,360) of f .. cycle withcolor .1 red + .7 white; for r = s/2 step s until 4s: draw fullcircle scaled 2r withcolor .8 ...

9

With PSTricks, the following is too short for typing exercise. \documentclass[border=12pt,pstricks]{standalone} \usepackage{pst-plot} \def\r{2*(1-sin(x))} \begin{document} \begin{pspicture}[algebraic,plotpoints=100,polarplot](-5.5,-5.5)(5.5,5.5) \psaxes[axesstyle=polar,subticklinestyle=dashed](5,0) ...

9

This can be easily done with TikZ: \documentclass{article} \usepackage{tikz} \begin{document} Simple grid: \medskip \tikz\draw [thin] (0,0) grid (5,5); More complex grid: \medskip \begin{tikzpicture} \draw [thin, step=0.1, gray] (0,0) grid (5,5); \draw [thick, gray] (0,0) grid (5,5); \end{tikzpicture} \end{document}

8

EDIT : This issue is now fixed in the current development version (CVS) of TikZ/PGF. The fix is not what is proposed below but from Till Tantau's comment: Fixed in CVS. However, negative increments are (still) not allowed. Instead, the two parameters of the pgfpathgrid command are now considered as two corners of a rectangle rather than as ...

8

Some corrections are necessary (you're forgetting \topskip) \newbox\gridbox \setbox\gridbox\line{% \special{color push rgb .8 .8 1}% \vrule height\baselineskip width0pt \hrulefill \special{color pop}} \def\grid{\vtop to0pt{\hrule height0pt\kern-\dimexpr\baselineskip-\topskip\relax \vbox to\dimexpr\vsize+2pt\relax{\leaders\copy\gridbox\vfil}\vss}} ...

8

I am sorry but there's no easy solution. First I tried using a to path but that doesn't let you change the line style:-( Next I tried implementing a dedicated command. This time the main problem is that in order to iterate over the coordinate labels, the labels should be integral, which isn't true in general. The following should work, but it requires ...

8

Not exactly what you are looking for (no subgrid) but coordinates are shown. \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{decorations.pathreplacing} \makeatletter \def\tikz@Get@x@coor#1,#2\tikz@sentinel{% \pgfmathparse{int(round(#1/1cm))}} \def\tikz@Get@y@coor#1,#2\tikz@sentinel{% \pgfmathparse{int(round(#2/1cm))}} \tikzset{% show ...

Only top voted, non community-wiki answers of a minimum length are eligible