While there is the scopes
TikZ library which allows you to use in-path scopes, many of the drawing options are global to the drawing path. Things like color, thickness and drawing pattern (e.g. solid vs. dashes) can only be applied to the whole path. The reason for this comes from the underlying graphic system (PS or PDF) and PGF/TikZ can't do much about it.
If you want to draw lines with different settings you will have to do so with two or more drawing commands. Note that TikZ has the ability to draw material into the background, i.e. behind previous drawn material. Enclose such commands between \begin{pgfonlayer}{background}
... \end{pgfonlayer}
.
You could set up your own axes and use scopes
to restrict the lines:
\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{tikz}
\usetikzlibrary{arrows}
\begin{document}
\begin{tikzpicture}[x={(0.966cm,0.259cm)},y={(-0.966cm,0.259cm)},z={(0.259cm,0.966cm)}]
\draw[->] (-2,-2,-2) -- node[fill=white] {x} ++ (2,0,0);
\draw[->] (-2,-2,-2) -- node[fill=white] {y} ++ (0,2,0);
\draw[->] (-2,-2,-2) -- node[fill=white] {z} ++ (0,0,2);
\begin{scope}
\clip (0,3,0) -- (0,3,5) -- (0,10,5) -- (0,10,0) -- cycle;
\draw[thick] (2.5,8,2.5) -- (2.5,3,2.5);
\end{scope}
\fill[opacity=0.5,blue] (0,3,0) -- (5,3,0) -- (5,3,5) -- (0,3,5) -- cycle;
\shade[ball color=red] (2.5,1.5,2.5) circle (1.5*1cm);
\fill[opacity=0.5,blue] (0,0,0) -- (5,0,0) -- (5,0,5) -- (0,0,5) -- cycle;
\begin{scope}
\clip (0,0,0) -- (2.5,0,0) -- (2.5,0,5) -- (2.5,3,5) -- (0,3,5) -- (0,3,0) -- cycle;
\draw[thick, dashed] (2.5,8,2.5) -- (2.5,0,2.5);
\end{scope}
\draw[thick] (2.5,0,2.5) -- (2.5,-5,2.5);
\end{tikzpicture}
\end{document}
Best Answer
There is
pst-solides3d
. The package readme mentions:The package is designed to draw solids in 3D perspective. Features include:
create primitive solids;
create solids by including a list of its vertices and faces;
faces of solids and surfaces can be colored by choosing from a very large palette of colors;
draw parametric surfaces in algebraic and reverse polish notation;
create explicit and parameterized algebraic functions drawn in 2 or 3 dimensions;
project text onto a plane and onto the faces of a solid;
support for including external database files.
Here's a small example (compile with LaTeX or XeLaTeX):