Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm attempting to construct a tikzpicture that looks like this:

What I'd like to turn into a tikz.

Here's what I have:

\documentclass[12pt]{article}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\usepackage{tkz-euclide}

\begin{document}

\begin{tikzpicture}[xscale=.6, yscale=.6]
\draw [<->,thick] (0,8) node [left] {$\mathbb{R}^{n}$}
    |- (8,0);

\draw [<->,thick] (10,8) node [left] {$\mathbb{R}^{m}$}
    |- (18,0);

\tkzDefPoint(4,1){A}
\tkzDefPoint(.5,3){B}
\tkzDefPoint(1,5){C}
\tkzDefPoint(1.2,7){D}
\tkzDefPoint(5.3,7.5){E}
\tkzDefPoint(7,6){F}
\tkzDefPoint(6,4){G}
\tkzDefPoint(6.7,3){H}

\draw [decoration={random steps,segment length=.75cm,amplitude=.5cm},
        decorate, rounded corners=.3cm]
     (A) -- (B) -- (C) -- (D) -- (E) -- (F) -- (G) -- (H) -- (A);

\draw [fill] (4,6) circle (.05) node [below] {$\bar{u}$};
\draw [dashed] (4,6) circle (1) node [below] {$B_{\delta}\left(\bar{u}\right)$};

\tkzDefPoint(14,1){I}
\tkzDefPoint(10.5,3){J}
\tkzDefPoint(11,5){K}
\tkzDefPoint(11.2,7){L}
\tkzDefPoint(15.3,7.5){M}
\tkzDefPoint(17,6){N}
\tkzDefPoint(16,4){O}
\tkzDefPoint(16.7,3){P}

\draw [decoration={random steps,segment length=.75cm,amplitude=.5cm},
        decorate, rounded corners=.3cm]
     (I) -- (J) -- (K) -- (L) -- (M) -- (N) -- (O) -- (P) -- (I);

\draw [fill] (14,3) circle (.05) node [above] {$f\left(\bar{u}\right)$};
\draw [dashed] (14,3) circle (1) node [below] {$f\left(B_{\epsilon}\left(\bar{u}\right)\right)$};

\end{tikzpicture}

\end{document}

Which produces:

Product of my code.

And then my ineptitude became too frustrating.

Why do the blobs have tiny lines coming out of them every so often? Why are the corners of the blob at (4,1) and (14,1) not rounded? How do I correctly label the points and open balls? How do I create a tastefully bent arrow (as in the lines labeled "f")?

EDIT 1

Attempting to find the correct balance between segment length, amplitude, and rounded corner radii was cumbersome so I've settled for non-random blobs.

I took JLDiaz's suggestion in defining a tikzstyle but I don't think I fully understand what they meant. Here's what I have:

\documentclass[12pt]{article}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[xscale=1, yscale=1]
\tikzstyle{ball}=[circle, dashed, minimum size=1cm, draw]
\tikzstyle{point}=[circle, fill, minimum size=.01cm, draw]

\draw [<->,thick] (0,8) node [left] {$\mathbb{R}^{n}$}
    |- (8,0);

\draw [rounded corners=10pt] (4,1) -- (.5,3) -- (1,5) -- (1.2,7) -- (5.3,7.5) -- (7,6) -- (6,4) -- (6.7,3) --cycle;

\draw (4,6) node[point] (Point1) {};
\node [below] at (Point1) {$\bar{u}$};

\draw (4, 6) node[ball] (OpenBall1) {};
\node [below] at (OpenBall1) {$B_{\delta}\left(\bar{u}\right)$};

\end{tikzpicture}

\end{document}

Which produces:

Edited production.

The way I've set up the styles and nodes must be wrong because the desired effect has not taken place as JLDiaz described. What's the correct way to define these styles and nodes? Is there a way for tikz to see collisions and report an error on the console?

share|improve this question

2 Answers 2

Why do the blobs have tiny lines coming out of them every so often?

Because the amplitude of the steps and the rounding radii are too similar. Reduce the radius or increase the amplitude and/or steps. You have to find right values by trial and error.

Why are the corners of the blob at (4,1) and (14,1) not rounded?

Because the path is not closed. Substitute the last point for --cycle;

How do I correctly label the points and open balls?

They did not came as you expected because above and below cannot be referred to circles or other paths, but instead to other nodes. Define a style ball for example, as circle, dashed, minimum size=1cm and replace your circles by node[ball] (name) {}. Then you can put the labels relative to (name) using below and above.

How do I create a tastefully bent arrow (as in the lines labeled "f")?

Use to[bend left] for example, instead of -- to connect the appropriate points.

Update

Since the OP had some problems following my suggestions, as he stated in a recent edit, I think a more detailed explanations is due.

  1. About the random blobs. I also tried to find some combination of step length, amplitude and rounded corners which produced a nice result, but unsuccesfully. So I think it is a good idea not to use the random steps decoration. You can still get something like a random blob using techniques given in other answers.

  2. About tikz styles and label positioning for the balls. Your code is right, but in the line:

    \node [below] at (OpenBall1) {$B_{\delta}\left(\bar{u}\right)$};
    

    the syntax at (OpenBall1) means at the center of that node. You have to use at (OpenBall11.south) instead. An alternative is to use positioning tikz library and:

    \node [below=2mm of OpenBall1] {$B_etc...$};
    

    in this case Tikz chooses intelligently the appropiate anchor for the relative positioning.

  3. You are getting "too big" points. This is because each node contains an inner padding, which is always obeyed with independence of the minimum size. You can set to zero the inner padding with inner sep=0pt, so that you have better control over the circle size.

share|improve this answer

Have you considered a less manual method for your objective? For instance, the inkscape2tikz Inkscape plugin converts diagrams you draw in Inkscape into tikz for you.

Even if you do want to manually create the tikz code, at least you can get a hint in situations where you are unsure of how to proceed by creating individual bits, and converting them to tikz.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.