17

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.

3
  • TikZ with the to[out=angle,in=angle]. See for example tex.stackexchange.com/questions/1175/drawing-a-hypergraph/…. But you should give us more details about what you want.
    – Caramdir
    Commented Mar 15, 2011 at 3:46
  • @Caramdir: I learn a lot from the link. Here is the example, draw this kind of figure intuitively and easily.
    – Rushavski
    Commented Mar 15, 2011 at 4:49
  • Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count. This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). Commented Apr 15, 2011 at 13:48

2 Answers 2

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}

smooth polygon and line


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}

random shapes

1
  • Now throw in a randomiser on the coordinates! Commented Mar 15, 2011 at 13:01
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}

enter image description here

6
  • This seems to work fine with the normal latex compiler. I'm just wondering what the special reason is to use xelatex? I do not know it very well and like to learn more about it. Commented Mar 15, 2011 at 8:55
  • @Martin: The issue is that pstricks won't work with pdflatex. Yes, it should work with the dvi-producing latex. But it also works with xelatex. Commented Mar 15, 2011 at 9:08
  • 1
    @Martin: with xelatex you'll get directly the pdf. ALternatively you can run pdflatex -shell-escape when using \usepackage[pdf]{pstricks}
    – user2478
    Commented Mar 15, 2011 at 9:10
  • and xelatex does not require shell escape as pdflatex does? why not?
    – pluton
    Commented Mar 15, 2011 at 18:47
  • @pluton because XeLaTeX has a native support of PostScript specials, PDFLaTeX does not.
    – yo'
    Commented Oct 22, 2014 at 13:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .