You can include the axis
environment in the tikzpicture
generated by Geogebra. To align the coordinate systems, set anchor=origin
in the axis
options, and choose the same x
and y
lengths:
\documentclass{article}
\usepackage{tikz, pgfplots}
\usetikzlibrary{arrows}
\begin{document}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\draw[->,color=black] (-6.72,0) -- (7.8,0);
\foreach \x in {-6,-4,-2,2,4,6}
\draw[shift={(\x,0)},color=black] (0pt,2pt) -- (0pt,-2pt) node[below] {\footnotesize $\x$};
\draw[->,color=black] (0,-3.75) -- (0,7.03);
\foreach \y in {-2,2,4,6}
\draw[shift={(0,\y)},color=black] (2pt,0pt) -- (-2pt,0pt) node[left] {\footnotesize $\y$};
\draw(3,-1) circle (2cm);
\fill [color=black] (-3,0) circle (1.5pt);
\draw [color=black] (-2.9,-0.26)-- ++(-1.5pt,-1.5pt) -- ++(3.0pt,3.0pt) ++(-3.0pt,0) -- ++(3.0pt,-3.0pt);
\begin{axis}[
anchor=origin, % Align the origins
x=1cm, y=1cm, % Set the same unit vectors
hide axis
]
\addplot [mark=*, color=red] table {
4 5
-2 -2
-4 0
};
\end{axis}
\end{tikzpicture}
\end{document}
Well, here's a suggestion. It uses the accepted answer from What's the easiest way to draw the arc defined by three points in TikZ? to draw the arc. A third coordinate is placed midway between the two points, offset a bit to the left, and used as a midpoint for the arc. Modifying this offset changes the radius of the circle, although the offset is of course not the same as the radius.
I also changed how all the lines and arrows are drawn. Whether you think this is an improvement or not I'll leave for you to decide. Note that you can define a text width
and align
ment for nodes, so there is no need to add a \parbox
in each node. See the new toptext
style.
Regarding the background fill: The fit
library lets you create a node that encompasses a list of other nodes. When you only add the two top nodes to this list, it will of course not cover the entire figure. What I did was to add a new node bottom
at the end of one of the vertical lines, and add this to the fit=
node list. (You could also use the anchors of the current bounding box
node.) Using the backgrounds
library I placed the fill on the background, so it doesn't cover up the other elements.
A final note: \color{green}
is a switch that makes all the following text green. Hence, the final pair of braces in \color{green}{text}
is not needed, and they wont limit the effect of \color
. There is however a \textcolor
command that does use such a syntax, \textcolor{green}{green text}
. (Compare \textcolor{red}{red text} black text \color{red}{red text} still red text
.)
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usetikzlibrary{shapes.geometric,arrows,positioning,fit,calc,backgrounds}
\usepackage{hyperref}
\tikzset{
b/.style={
draw,
rectangle,
rounded corners=2ex,
minimum height=0.5in,
minimum width=2in,
align=center},
c/.style={
draw,
rectangle,
rounded corners=2ex,
minimum height=0.5in,
minimum width=2in,
align=center,
rotate=-90},
ar/.style={
rounded corners=2ex,
->,
>=latex},
myarrow/.style args={#1 colored by #2 and #3}{
-stealth,
line width=#1,
#2,
postaction={draw,-stealth,#3,line width=(#1)/3,
shorten <=(#1)/3,
shorten >=2*(#1)/3},
},
toptext/.style={ % <-- New
above,
text width=5cm,
align=center}
}
\begin{document}
\begin{tikzpicture}
\node (client) [b] {Client};
\node (serveur) [b, left=4 cm of client.west] {Serveur};
% draw the vertical lines
\draw [thick] (serveur.south) -- ++(0,-300pt);
\draw (client.south) -- ++(0,-300pt) coordinate (bottom);
% add a coordinate below serveur for given y-offsets from bottom of serveur
\foreach [count=\i] \y in {-100,-150,-200,-250}
\path (serveur.south) ++(0,\y pt) coordinate (level \i);
\draw [ar] (level 1 -| client.south) -- node[toptext] {POST \nolinkurl{authentification/}\\username=user\&password=abc123} (level 1);
\draw [ar] (level 2) -- node[toptext] {HTTP 200 OK\\ \textcolor{green}{\{Token : "JWT"\}}} (level 2-| client.south);
\draw [ar] (level 3 -| client.south) -- node[toptext] {GET \nolinkurl{api/user/id}\\ \textcolor{green}{JWT : Token}} (level 3);
\draw [ar] (level 4 -| client.south) -- node[toptext,below] {HTTP 200 OK\\ \textcolor{green}{\{name : foo\}}} (level 4);
% define some coordinates
\coordinate (a) at ($(level 2) + (-3pt,0)$);
\coordinate (b) at ($(level 3) + (-3pt,0)$);
\coordinate (c) at ($(a)!0.5!(b) + (-1cm,0)$); % modify the -1cm offset here
% Just to show the points used
\foreach \x in {a,b,c}
\fill[red] (\x) circle[radius=2pt];
% Draw the arc through the points
\tkzCircumCenter(a,b,c)\tkzGetPoint{O}
\tikzset{compass style/.append style={-latex,thick,black}}
\tkzDrawArc(O,a)(b)
% fill background
\begin{scope}[on background layer]
\node [rectangle, opacity=0.2, fill=blue, fit=(client)(serveur)(bottom)]{};
\end{scope}
\end{tikzpicture}
\end{document}
Best Answer
I don't understand the 3D behavior of
tikz
very well, but here's a way to do one of your pictures in Asymptote using a bunch of lines, arcs, and labels.A few of the built-in Asymptote commands I used:
X
is the unit vector (1,0,0) similarly forY
andZ
Updated to incorporate a few of Charles Staats' suggestions
Update #2
Charles Staats pointed out good parameters for an oblique projection, which better matches the original picture. Using
currentprojection=obliqueX
,width=\textwidth
, and editing the labels a bit to better suit this projection:Orthographic code: