The arc
operation can be used here. The general syntax as recommended by the TikZ/PGF manual (thanks to @Tobi for the comment) is
\draw (<starting point>) arc [<options>];
with these options:
radius=<dim>
x radius=<dim>
y radius=<dim>
start angle=<deg>
end angle=<deg>
delta angle=<deg>
or a less readable version
\draw (<starting point>) arc (<start angle>:<end angle>:<radius>);
where <radius>
can be a single length or <dim> and <dim>
for different radii.
Code
\documentclass[border=2pt]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
ticks=none,
axis lines = middle,
axis line style={->},
ymin=-1.5, ymax=1.5,
xmin=-1.5, xmax=1.5,
axis equal]
\addplot[black, domain=0:0.7071] {x};
\draw[black] (axis cs:0,0) circle [radius=1];
\draw (axis cs:.125,0)arc[radius=.25cm,start angle=0,end angle=45];
% \draw (axis cs:.125,0)arc(0:45:.25cm); % same as above with different syntax
\end{axis}
\end{tikzpicture}
\end{document}
Output
Update: fixed gradient angle
Here is an idea. You can "connect" two nodes using another node, with option sloped
, and minimum width equal to the distance between the nodes to connect. The shape of the "connecting" node is by default a rectangle which you can fill with a gradient. But you can even try more exotic node shapes for the "connection".
The following code implements a macro which simplifies the syntax:
% Requires \usetikzlibrary{calc}
\def\connect#1#2#3{%
% #1: starting node
% #2: ending node
% #3: attributes for the shape connecting nodes
\path let
\p1 = ($(#2)-(#1)$),
\n1 = {veclen(\p1)},
\n2 = {atan2(\x1,\y1)} % <- Update
in
(#1) -- (#2) node[#3, midway, sloped, shading angle=\n2+90, minimum width=\n1, inner sep=0pt, #3] {};
}
You can use this macro as in: \connect{A}{B}{options}
, being A
and B
the coordinates to connect and options
the ones to be used for the node which fakes the connection. Here you can specify the gradient, as for example:
\begin{tikzpicture}
\foreach \A/\B in {{0,0}/{2,1}, {3,0}/{1,1}} {
\fill [red] (\A) circle(2pt);
\fill [blue] (\B) circle(2pt);
\connect{\A}{\B}{bottom color=blue, top color=red, minimum height=1pt}
}
\end{tikzpicture}
Which produces:
Note that minimum height
specifies in this case the "connection" width.
As said, you can use more exotic shapes as connectors, as for example ellipses:
% ...
\connect{\A}{\B}{bottom color=blue, top color=red, minimum height=1pt, ellipse}
Best Answer
There are several ways, e.g.:
Or the shift can be added to the start and end points:
Or a double line can be used, see the answer of Alenanno.