Skip to main content
added 1144 characters in body
Source Link
Qrrbrbirlbel
  • 124.5k
  • 8
  • 259
  • 483

Alternative (for my code)

Instead of a Bézier curve you could also just draw an ellipsoid arc:

arr/.style={
  to path={
    (\tikztostart.north) arc [x radius={.5/(\i-1)-.5/(\i)},
                              y radius=.75,
                              start angle=0, delta angle=180]}}

which gives almost the same curves.

Alternative (for your code)

You could use the halfway point at the top but adjust the in distance and out distance respectivly.

However, since these can only be given in the canvas coordinate system (i.e. with units) but the distance between your dots is in the xyz coordinate system (without units) you would need to calculate that distance somehow or simply use the control points where you can specify the distance in the xyz coordinate system:

\draw[->] (1/\y, 0.06)
  to [controls=+(up:.1) and +(right:{.25*(1/\y-1/\x)})] (\z, 0.2)
  to [controls=+(left:{.25*(1/\y-1/\x)}) and +(up:.1)] (1/\x, 0.06);

Here the distance for the top point is a quarter of the distance between the dots, i.e. halfway between a dot and the top point.

Alternative (for my code)

Instead of a Bézier curve you could also just draw an ellipsoid arc:

arr/.style={
  to path={
    (\tikztostart.north) arc [x radius={.5/(\i-1)-.5/(\i)},
                              y radius=.75,
                              start angle=0, delta angle=180]}}

which gives almost the same curves.

Alternative (for your code)

You could use the halfway point at the top but adjust the in distance and out distance respectivly.

However, since these can only be given in the canvas coordinate system (i.e. with units) but the distance between your dots is in the xyz coordinate system (without units) you would need to calculate that distance somehow or simply use the control points where you can specify the distance in the xyz coordinate system:

\draw[->] (1/\y, 0.06)
  to [controls=+(up:.1) and +(right:{.25*(1/\y-1/\x)})] (\z, 0.2)
  to [controls=+(left:{.25*(1/\y-1/\x)}) and +(up:.1)] (1/\x, 0.06);

Here the distance for the top point is a quarter of the distance between the dots, i.e. halfway between a dot and the top point.

Source Link
Qrrbrbirlbel
  • 124.5k
  • 8
  • 259
  • 483

I think you're doing it too complicated.

You can just use one path, here bend right = 90 which creates a curve that curves orthogonally (90°) to the line connecting start and target nodes/coordinates.

However, this isn't all that is needed, see

\tikz
  \foreach[count=\ii from 1] \i in {2,...,5}
    \draw (5/\ii,0) to[bend right=90] (5/\i,0);

enter image description here

Luckily, TikZ provides the distance key which changes the curve as you would like:

\tikz
  \foreach[count=\ii from 1] \i in {2,...,5}
    \draw (5/\ii,0) to[bend right=90, distance=1cm] (5/\i,0);

enter image description here


Unfortunately, PGF/TikZ will include the control points of these curves into the bounding box of the diagram adding a bit vertical whitespace on the top.

In this simple case, I'll make the path actually set to overlaybut I will place a coordinate at the middle which will be the highest point on these curves and will add this coordinate later to the bounding box.
This is not exactly the same because it ignores the line width but I don't think this is going to be a problem. You can always use the bbox library or take a look at related questions like Bounding box is larger than expected when drawing a curved path.


In your code, you just need to do

\draw[->] (1/\y, 0.06) to[bend right=90, distance=.2cm] (1/\x, 0.06);

to get the proper curves. (The 0.2cm will be scaled to 1cm the same your 0.2 did after it was converted to the canvas coordinate system.)


In my code below I'm mainly using the chains library with no placement rule (going {=}) since I want to place the dots manually at (1/\i, 0) but want to use the library's feature of connecting nodes on a chain. For this, the arr style is setup as mentioned above.

Code

% page setup
%\documentclass[11pt]{article}
%\usepackage[a4paper, total={6in, 8in}]{geometry}
\documentclass[tikz, border=3mm]{standalone}
% tikz
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{chains}
% main document
\begin{document}
\begin{tikzpicture}[
  x=5cm, % better than scale
  start chain=going {=}, % no-op for placement
  label position=below,
  arr/.style={
    ->, bend right=90, distance=1cm,
    overlay, edge node=coordinate(@) % for bounding box fix
  }]
% Draw the real line and the interval (0, 1]
\draw[->] (-0.5, 0) -- (1.5, 0);
\node[label={[name=l-0]$0$}] at (0, 0) {$($}
 node[label=$1$]             at (1, 0) {$]$};

\scoped[disable label 1/.style=coordinate]
\foreach \i in {1, ..., 5}
  \node[% the dot
    circle, inner sep=+0pt, outer sep=+5pt,
    minimum size=+3pt, fill, draw,
    on chain, join=by arr] at (1/\i,0) {}
   node[% the fraction
    disable label \i/.try, % no label for 1/1
    anchor=base] (l-\i)
    at (l-0.base-|chain-end) {$\frac{1}{\i}$};
\path(@); % enlage bounding box

\node[base left, inner sep=+0pt] at (l-5.base west) {$\dots$};
\end{tikzpicture}
\tikz
  \foreach[count=\ii from 1] \i in {2,...,5}
    \draw (5/\ii,0) to[bend right=90] (5/\i,0);
    
\tikz
  \foreach[count=\ii from 1] \i in {2,...,5}
    \draw (5/\ii,0) to[bend right=90, distance=1cm] (5/\i,0);
\end{document}

Output

enter image description here