4

enter image description here

Hello! I was wondering how I can add a circle (x-1.5)^2+(y-1.5)^2=1.5^2 as shown in red. Here is my code:

\documentclass{article}
\usepackage{pgfplots}
\usepackage{graphicx} 
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usepackage{gensymb}
\usetikzlibrary{shapes,arrows,positioning}
\pgfplotsset{compat=1.18, width=10cm}

\begin{document} \begin{center}

\tdplotsetmaincoords{60}{125} \begin{tikzpicture} [tdplot_main_coords, cube/.style={very thick,black}, axis/.style={->,blue,thick}]

%draw the axes
\draw[axis] (0,0,0) -- (4,0,0) node[anchor=west]{$x$};
\draw[axis] (0,0,0) -- (0,4,0) node[anchor=west]{$y$};
\draw[axis] (0,0,0) -- (0,0,4) node[anchor=west]{$z$};

%draw the top and bottom of the cube
\draw[cube] (0,0,0) -- (0,3,0) -- (3,3,0) -- (3,0,0) -- cycle;
\draw[cube] (0,0,3) -- (0,3,3) -- (3,3,3) -- (3,0,3) -- cycle;

%draw the edges of the cube
\draw[cube] (0,0,0) -- (0,0,3);
\draw[cube] (0,3,0) -- (0,3,3);
\draw[cube] (3,0,0) -- (3,0,3);
\draw[cube] (3,3,0) -- (3,3,3);


\end{tikzpicture} \end{center}

\end{document}

1 Answers1

7

add the following line of code

            \draw[thick, red] (1.5, 1.5, 0)  circle (1.5);

MWE

\documentclass{article}
\usepackage{pgfplots}
\usepackage{graphicx} 
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usepackage{gensymb}
\usetikzlibrary{shapes,arrows,positioning}
\pgfplotsset{compat=1.18, width=10cm}

\begin{document} \begin{center}

    \tdplotsetmaincoords{60}{125}
    \begin{tikzpicture}
        [tdplot_main_coords,
        cube/.style={very thick,black},
        axis/.style={->,blue,thick}]

        %the circle
        \draw[thick, red] (1.5, 1.5, 0)  circle (1.5);

        %draw the axes
        \draw[axis] (0,0,0) -- (4,0,0) node[anchor=west]{$x$};
        \draw[axis] (0,0,0) -- (0,4,0) node[anchor=west]{$y$};
        \draw[axis] (0,0,0) -- (0,0,4) node[anchor=west]{$z$};

        %draw the top and bottom of the cube
        \draw[cube] (0,0,0) -- (0,3,0) -- (3,3,0) -- (3,0,0) -- cycle;
        \draw[cube] (0,0,3) -- (0,3,3) -- (3,3,3) -- (3,0,3) -- cycle;

        %draw the edges of the cube
        \draw[cube] (0,0,0) -- (0,0,3);
        \draw[cube] (0,3,0) -- (0,3,3);
        \draw[cube] (3,0,0) -- (3,0,3);
        \draw[cube] (3,3,0) -- (3,3,3);

    \end{tikzpicture}
\end{center}

\end{document}

Output

enter image description here

js bibra
  • 21,280