我正在使用Beamer
和准备一些演示文稿XeLaTeX
。我想使用 绘制一些图像TikZ
,如下所示:
我的示例演示如下:
\documentclass[aspectratio=149,presentation,10pt]{beamer}
\setbeamertemplate{navigation symbols}{}
\usefonttheme{professionalfonts}
\usepackage{tikz}
\definecolor{lightgray}{RGB}{204,204,204}
\definecolor{tomato}{RGB}{231,76,60}
\definecolor{snow}{RGB}{236,240,241}
\setbeamercolor{background canvas}{bg=snow}
\begin{document}
\begin{frame}[fragile]
\begin{tikzpicture}[R/.style={fill=lightgray,color=lightgray},L/.style={-,line width=2pt,color=tomato}]
\node (f) at (-0.5,2) [rotate=90] {Frequency};
\node (h) at (5,6) {\bf{Histogram of rdist}};
\node (r) at (5.5,-0.5) {rdist};
\draw [R] (0,3.75) rectangle (1,0);
\draw [L] (3,0) -- (3,5);
\draw [R] (3.05,4.9) rectangle (4.05,0);
\draw [R] (4.1,4.9) rectangle (5.1,0);
\draw [R] (5.15,1.75) rectangle (6.15,0);
\draw [R] (8.15,1.75) rectangle (9.15,0);
\end{tikzpicture}
\end{frame}
\end{document}
并产生以下输出:
现在我不知道该怎么画了axes
。
我是 TikZ 的新手...为了熟悉它,我已经从头开始阅读手册 (pgfmanual.pdf)...它很大,我学到了很多新的想法。在此基础上,我还准备了一些图表。但是,对于图表绘制,我几乎一无所知。
如果有人能一步一步地指导我这个主题,我将非常感激。正如我已经提到的,我正在学习 TikZ。
答案1
据我所知,只缺少轴。虽然用 pgfplots 绘制它们可能更方便,但使用 Ti 实现它们也很容易钾“仅” Z。(有些看似不必要的延伸,否则在轴的末端连接的线看起来不太好看。)
\documentclass[aspectratio=149,presentation,10pt]{beamer}
\setbeamertemplate{navigation symbols}{}
\usefonttheme{professionalfonts}
\usepackage{tikz}
\definecolor{lightgray}{RGB}{204,204,204}
\definecolor{tomato}{RGB}{231,76,60}
\definecolor{snow}{RGB}{236,240,241}
\setbeamercolor{background canvas}{bg=snow}
\begin{document}
\begin{frame}[fragile]
\begin{tikzpicture}[R/.style={fill=lightgray,color=lightgray},L/.style={-,line width=2pt,color=tomato}]
\node (f) at (-1.2,2) [rotate=90] {Frequency};
\node[font=\bfseries] (h) at (5,6) {Histogram of rdist};
\node (r) at (5.5,-1.5) {rdist};
\draw [R] (0,3.75) rectangle (1,0);
\draw [L] (3,0) -- (3,5);
\draw [R] (3.05,4.9) rectangle (4.05,0);
\draw [R] (4.1,4.9) rectangle (5.1,0);
\draw [R] (5.15,1.75) rectangle (6.15,0);
\draw [R] (8.15,1.75) rectangle (9.15,0);
% axes
\pgfmathsetmacro{\vfactor}{4.9/6}
\draw[thick] (-0.5,0) -| (-0.2,6*\vfactor)--(-0.5,6*\vfactor);
\foreach \X in {0,...,6}
{\draw[thick] (-0.2,\X*\vfactor) -- (-0.5,\X*\vfactor) node[left] {\X};}
\pgfmathsetmacro{\hfactor}{9.15/4}
\draw[thick] (0,-0.5)|-(4*\hfactor,-0.2)--(4*\hfactor,-0.5);
\foreach \X in {0,...,4}
{\draw[thick] (\X*\hfactor,-0.2) -- (\X*\hfactor,-0.5) node[below] {\X};}
\end{tikzpicture}
\end{frame}
\end{document}