Which package can easily write a graph, as an arbitrary curve or area, just for indication? The circle and ellipse don't be considered for their particular shape. TIKZ's Bézier curve is too non-intuitive to use.
Asked
Active
Viewed 4,139 times
17
2 Answers
19
You can use TikZ \draw plot functionality to get smoothed lines and polygons. TikZ works directly with pdflatex:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\tikz \draw plot [smooth cycle] coordinates {(0,0) (1,0.1) (2,0.3) (2,1.4) (1.5,2.5) (0.8,2.5) (0.3,1.2) (-0.2,0.6) } node at (1,1) {Area};
\tikz \draw plot [smooth,tension=1.2] coordinates {(0,1) (0.75,0.5) (1.5,0.9) (2,0) (2.5,0)} node at (1,0) {Line};
\end{document}

Or, as Andrew Stacey suggested, using random coordinates. You can play around with the seed and the factors for the random part. rnd returns a number between 0 and 1, rand returns a number between -1 and 1.
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\pgfmathsetseed{3}
\draw plot [smooth cycle, samples=8,domain={1:8}] (\x*360/8+5*rnd:0.5cm+1cm*rnd) node at (0,0) {Area};
\pgfmathsetseed{2}
\draw plot [smooth, samples=5,domain={1:5},xshift=1cm] (\x+0.5*rnd,0.75*rand) node at (4,-0.75) {Line};
\end{tikzpicture}
\end{document}

Jake
- 232,450
9
run with xelatex
\documentclass{article}
\usepackage{pstricks}
\begin{document}
\begin{pspicture}(6,6)
\psccurve[fillstyle=solid,fillcolor=blue!20!red!10](0,0)(2,0.5)(4,1)(6,5)(3,3)(2,5)
\rput(3,2){\Huge\textbf{Curve}}
\end{pspicture}
\end{document}

TH.
- 62,639
-
This seems to work fine with the normal
latexcompiler. I'm just wondering what the special reason is to usexelatex? I do not know it very well and like to learn more about it. – Martin Scharrer Mar 15 '11 at 08:55 -
@Martin: The issue is that
pstrickswon't work withpdflatex. Yes, it should work with the dvi-producinglatex. But it also works withxelatex. – Matthew Leingang Mar 15 '11 at 09:08 -
1@Martin: with
xelatexyou'll get directly the pdf. ALternatively you can runpdflatex -shell-escapewhen using\usepackage[pdf]{pstricks}– Mar 15 '11 at 09:10 -
-
@pluton because XeLaTeX has a native support of PostScript specials, PDFLaTeX does not. – yo' Oct 22 '14 at 13:02
-
@tohecz: It is not really a native support. It does nearly the same as the package
auto-pst-pdfforpdflatex. – Oct 22 '14 at 14:06
to[out=angle,in=angle]. See for example http://tex.stackexchange.com/questions/1175/drawing-a-hypergraph/1195#1195. But you should give us more details about what you want. – Caramdir Mar 15 '11 at 03:46