提问于:
浏览数:
2486
%坐标轴设定
\newcommand\plzj{$\dfrac{\text{频率}}{\text{组距}}$}
\newcommand\zftw{--++(0.2,0)
--++(0.05,0.15)--++(0.1,-0.3)--++(0.05,0.15)
--++(0.05,0.15)--++(0.1,-0.3)--++(0.05,0.15)
--++(0.05,0.15)--++(0.1,-0.3)--++(0.05,0.15)
--++(0.2,0)}
\newcommand\zftzb[6]{%
\draw[<->] (0,#3/\zftyb)node[right]{\plzj}
--(0,0)node[below]{0} \zftw --(#1,0)node[above]{#2};
\foreach \i in {1,2,...,#6} {
\node[below] at (\i,0) {\pgfmathparse{int(#4+#5*(\i-1))}\pgfmathresult};
}}
%用法:
%\zftzb{x轴长}{x轴标}{y轴长}{x轴刻度开始}{组距}{刻度个数}
%此处y轴长非实际长度,而是比最高的直方数值大一些即可
%画直方命令
\newcount\zftctr
\newcommand\zftyb{1}%y轴的比例
\makeatletter
\newcommand\zft{\@ifstar{\zftb}{\zfta}}
\makeatother
\newcommand\zfta[2][]{\advance\zftctr by 1\relax
\draw (\zftctr,#2/\zftyb) rectangle (\zftctr+1,0);
\draw[dashed] (0,#2/\zftyb)node[left,#1]{#2}--(\zftctr,#2/\zftyb);
}
\newcommand\zftb[1]{\advance\zftctr by 1\relax
\draw (\zftctr,#1/\zftyb) rectangle (\zftctr+1,0);
}
%用法:
%用\zft{...}画直方,无需标y值的用\zft*{...},
%调节数字位置用\zft[shift={(...)}]{...}
\newcommand\zftkz{%靠左式,即组从0开始时用
\zftctr=-1\relax\def\zftw{}}
\begin{tikzpicture}[scale=.54,x={(1cm,0cm)},z={(0.3535cm,0.3535cm)},y={(0cm,1cm)},thick]
\lpoint {0,0,0}AA{-6};
\lpoint {4,0,0}BB{-3};
\lpoint {4,0,4}CC{0};
\lpoint {0,0,4}DD{-2};
\lpoint {5,3,0}PP{-6};
\lpoint {0,4,0}{A1}{A_1}{7};
\lpoint {4,4,0}{B1}{B_1}{-1};
\lpoint {4,4,4}{C1}{C_1}{2};
\lpoint {0,4,4}{D1}{D_1}{6};
\tkzDrawSegments(A,B B,C A1,B1 B1,C1 C1,D1 D1,A1 B,B1 C,C1 A,A1)
\tkzDrawSegments[dashed](A,D D,C D,D1)
\draw[fill=black](5,3,0)ellipse [x radius=.08, y radius=.08];
\end{tikzpicture}