I'm attempting to construct a tikzpicture that looks like this:
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:
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:
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?
Best Answer
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.
Because the path is not closed. Substitute the last point for
--cycle;
They did not came as you expected because
above
andbelow
cannot be referred to circles or other paths, but instead to other nodes. Define a styleball
for example, ascircle, dashed, minimum size=1cm
and replace your circles bynode[ball] (name) {}
. Then you can put the labels relative to(name)
usingbelow
andabove
.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.
About the random blobs. I also tried to find some combination of
step length
,amplitude
androunded corners
which produced a nice result, but unsuccesfully. So I think it is a good idea not to use therandom steps
decoration. You can still get something like a random blob using techniques given in other answers.About tikz styles and label positioning for the balls. Your code is right, but in the line:
the syntax
at (OpenBall1)
means at the center of that node. You have to useat (OpenBall11.south)
instead. An alternative is to usepositioning
tikz library and:in this case Tikz chooses intelligently the appropiate anchor for the relative positioning.
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 withinner sep=0pt
, so that you have better control over the circle size.