Hot answers tagged tikz-pgf
22
I agree with kgr generating the actual data should be done by a script. To have a certain readability (in case you need to manually tweak something afterwards, like e.g. highlight something with a special color) you should definitively go with a key-value interface as Qrrbrbirlbel suggested. I'd go with pgfkeys, which is already a part of TikZ. Here's a ...
15
This is just a little add-on to Tom Bombadil's very impressive answer that shows how to feed the macro data from a table (which can also be a CSV file) using PGFPlotstable.
You can provide your data like this (values taken from Addgene):
\pgfplotstableread{
Name Start End Color Height
T7_terminator 129 1 20 0.1
...
14
The width of the background triangles is 2^order*stepsize, so you can calculate the step size as a function of the desired overall width:
\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{lindenmayersystems}
\begin{document}%
\def\trianglewidth{2cm}%
\pgfdeclarelindenmayersystem{Sierpinski triangle}{
...
14
An alternative way using decorations. It's a bit dependent on how the initial triangle is drawn (i.e., the direction of the path), and the nesting of decorations has to be done manually.
\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations}
% Not sure this follows any proper defition of
% Sirpinksi triangle. It just works.
...
13
PGFPlots can calculate the regression line only for tabulated data, so you'll have to create the points in a table. You can do this using \pgfplotstablenew.
The coefficients of the regression line are stored in the macros \pgfplotstableregressiona and \pgfplotstableregressionb.
\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
...
12
\documentclass{standalone}
\usepackage{pst-fractal}
\begin{document}
\multido{\iA=1+1}{5}{%
\begin{pspicture}(3,2.8)
\psSier[linecolor=blue!70,fillcolor=red!40](0,0){3cm}{\iA}
\end{pspicture}}
\end{document}
10
As Jake has mentioned in his comment, the PGF/TikZ manual is the definitive reference for PGF/TikZ, and it contains some very gentle tutorials that will help get you started. There's also a Minimal Introduction to TikZ which could be helpful (I've never read it). Another valuable source of examples would be the gallery in TeXample.net. And, last but not ...
9
TikZ itself has a very powerful foreach loop: \foreach. (→ foreach; PGF manual (v2.10), section 2.20 “Repeating Things: For-Loops” and chapter 56 “Repeating Things: The Foreach Statement”)
It uses the syntax
\foreach \varA/\varB/…/\var<N>[<options>] in {val1A/val1B/…/val1<N>,
...
9
This would be done best with a new shape declaration that is made for a second node part, but for now, here is an implementation using the path picture and manually specifying the width and height of the arrow.
I thought that with an single arrow tip angle of 90 equal head indent and head extend should result in an arrow tip similar to your image, this ...
8
One possibility:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1,T2A]{fontenc}
\usepackage[english,russian]{babel}
\usepackage[a5paper]{geometry}
\usepackage{amsthm,thmtools}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{amsmath,amssymb}
\usetikzlibrary{shadows.blur}
\usetikzlibrary{shapes.symbols}
\usetikzlibrary{shadows,shapes}
...
8
You can assign a default value for a key by using the .default handler. By setting
qar/.style={
draw,
rectangle,
fill=#1
},
qar/.default=red
the value red will be used whenever qar is called without an argument.
The same thing works for keys that take two or more arguments:
qar2/.style 2 args={
rectangle,
draw=#1, thick,
fill=#2
...
7
The pin solution you chose is an interesting one, though I don’t it doesn’t work perfectly with the loop option (there is also loop above) as the pin distance that places the pin node and the loop itself are independent.
You could manually set a pin distance.
You can use it as a node alongside a looped edge.
Use the align=center option that allows one to ...
7
Your log file will contain the message
Package pgfplots Warning: You have an axis with empty range (in direction y). Replacing it with a default range and clearing all plots. on input line 8.
The cure would be to add xmin,xmax,ymin,ymax with appropriate values.
6
Polar coordinates in TikZ can be specified using a single radius for a circular coordinate system, or using an x and a y radius for elliptical coordinate systems. Internally, the circular coordinate system is represented by an elliptical coordinate system with x radius = y radius. This works fine for static values, but if the radius is set to rnd, different ...
6
I guess the problem here relies on how the cross has been created: my feeling is that by exploiting the path picture bounding box as reference makes things rather complicated. I'm not sure whether is possible to rotate that (perhaps yes, but what's the effort?) and for sure there's a simpler way. Indeed, for debugging purposes it is possible to draw the path ...
6
If you add font=\sffamily\sansmath to the tikzpicture options (or the axis options), all text will be in sans serif, without you having to find all relevant styles:
\documentclass{standalone}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
%deal with warning message in log
\pgfplotsset{compat=1.8}
\usepackage{helvet}
\usepackage[eulergreek]{sansmath}
...
6
I think the following captures many of the features you request. I discuss the issues after the code.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,matrix}
\begin{document}
\begin{tikzpicture}[very thick]
\matrix (m) [matrix of nodes, column sep=3ex, row sep=2ex,
column 1/.style={anchor=east}, column 2/.style={anchor=west},
...
6
This is going to be a very long answer (both in length and detailedness).
Keep calm and keep reading. :)
How to access a coordinate on a circle/an ellipse: polar coordinates
While you can access a coordinate on a circle (or an ellipse with different radii) by using
({<x radius> * cos(<angle>)}, {<y radius> * sin(<angle>)})
TikZ ...
6
Yup, looks like a bug. You might want to file a bug report.
You can get a correct smooth plot by using -- (current plot end|-{rel axis cs:1,0}) \closedcycle instead of just \closedcycle.
\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[axis lines=middle,xmin=0, xmax=6, ymin=0, axis on top]
...
5
Your problem seems to be how to align several tikzpictures and place labels over them. One possibility would be to use remember picture and overlay options with a tabular environment to align graphics.
Please, look at next code:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tabular}{rl}
...
5
The solution with the library tikz-mec (documentation only in Italian, but the examples and the shape details make it quite easy to be used):
\documentclass[tikz,png,border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{backgrounds,calc,decorations.markings,mec}
\begin{document}
\begin{tikzpicture}[scale=1,thick,dot/.style={draw,circle,minimum ...
5
This problem appears because the corners on the lines are really tight, causing the lines to overshoot when a sharp line join is used (see How can I prevent pgfplots from rendering lines incorrectly when I use "no markers"?). You can fix this by using line join=round. to apply that option to all your plots without having to change all the files, ...
5
This answer is not using the tkz-kiviat but still it does what it is supposed to do (without requiring additional packages). You have to manually indicate the number of axes as well as the positions of the nodes, and of course your label.
\documentclass[]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[upright]{fourier}
...
5
One possibility using the calc library to draw some rotated ellipses:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,shapes}
\begin{document}
\begin{tikzpicture}[every node/.style={draw}]
\node (l1) at (0,0) [circle] {};
\node (l2) at (2,0) [circle] {};
\node (l3) at (4,0) [circle] {};
\node (m1) at (1, 1.732) [circle] {};
\node (m2) at ...
5
Above method only allowing east or west non-rounding. I needed that and was not satisfied with the answer.
So we have to adopt method from other solution (Rounded corners in TikZ trees.) and make customized differently rounded corners.
I would be gratefull if someone includes this in future TIKZ.
\documentclass{article}
\usepackage{tikz}
...
5
The TikZ/PGF kernel has macros for this. I propose a more general \xforeach macro written in expl3; the syntax is a bit different, but I guess you can live with it.
\documentclass{article}
\usepackage{xparse,tikz}
\ExplSyntaxOn
\NewDocumentCommand{\xforeach}{mmm}
{
\group_begin:
\unapiedra_xforeach:nnn {#1} {#2} {#3}
\group_end:
}
...
5
You can use append after command in the xticklabel style options to insert drawing commands:
\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis x line=middle,
axis y line=left,
tickwidth=0pt,
xticklabels={$s$},
xticklabel style={
yshift=-3ex,
name=label,
append after ...
5
A little syntax error. You have
\only<3>{\tikzset{mynode./style={done}}}
and it should be
\only<3>{\tikzset{mynode/.style={done}}}
(the dot after the slash).
The complete code (I changed the old syntax \tikzstyle to \tikzset):
\documentclass{beamer}
\usepackage{tikz}
\tikzset{
empty/.style = {shape=rectangle, draw=green, fill=green, ...
5
Just for the looping fun of it; every section is one level... you can even automate the levels etc. but it's a little xii.tex way of doing it since it then becomes a lindenmayer system :)
\documentclass[tikz]{standalone}
\usetikzlibrary{shapes.geometric}
\begin{document}
\begin{tikzpicture}[
main tri/.style={isosceles triangle,fill,isosceles triangle apex ...
4
Another option is to add the % as an xlabel, and change the position of this, by adding
xlabel={(\%)},
xlabel style={at={(rel axis cs:1.01,0)},anchor=west}
to the axis options. rel axis cs is a coordinate system that is relative to the axes, with (0,0) in the lower left corner, and (1,1) in the upper right.
To shift the label down a bit, you can change ...
Only top voted, non community-wiki answers of a minimum length are eligible
