如何使下图中的文字变为白色并使图形居中?
%% LyX 1.6.9 created this file. For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{babel}
\usepackage{multicol}
\usepackage{tikz}
\begin{document}
\begin{center}
%
\begin{figure}
\caption{Overlap of valley regions in tumourigenic cell line vs. control}
\definecolor{darkColor}{rgb}{0.102,0,0.2} %darkPurple
\definecolor{mediumColor}{rgb}{0.2,0,0.4} %purple
\definecolor{lightColor}{rgb}{0.413,0.315,0.615} %lightPurple
\begin{tikzpicture}[scale=1]
\tikzstyle{LeftLabel}= [text=white]
\tikzstyle{RightLabel}= [text=white]
\tikzstyle{CenterLabel}= [text=white]
\def\firstcircle{(-1.25,0) circle (1.75)}
\def\secondcircle{(1.25,0) circle (1.75)}
%\draw[help lines] (-4,-4) grid (8,4);
\begin{scope}
\fill[lightColor] \firstcircle;
\fill[lightColor] \secondcircle;
\clip \firstcircle;
\fill[mediumColor] \secondcircle;
\end{scope}
\draw \firstcircle ;
\draw (-1,0) node [left] (LeftLabel) {Cancer} ;
\draw node[below of=LeftLabel, node distance=.4cm] {1710};
\draw \secondcircle ;
\draw (1,0) node [right] (RightLabel) {Control};
\draw node[below of=RightLabel, node distance=.4cm] {2180};
\draw (0,0) node [] (overlap) {};
\draw node[below of=overlap, node distance=.4cm] {373};
\end{tikzpicture}%
\end{figure}
\par\end{center}
\end{document}
答案1
添加white
到节点选项或text=white
用于图片。\centering
在 的开头使用figure
。\caption
属于图下方(但在表格上方)。
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{babel}
\usepackage{multicol}
\usepackage{tikz}
\begin{document}
%
\begin{figure}
\centering
\definecolor{darkColor}{rgb}{0.102,0,0.2} %darkPurple
\definecolor{mediumColor}{rgb}{0.2,0,0.4} %purple
\definecolor{lightColor}{rgb}{0.413,0.315,0.615} %lightPurple
\begin{tikzpicture}[scale=1,text=white]
\def\firstcircle{(-1.25,0) circle (1.75)}
\def\secondcircle{(1.25,0) circle (1.75)}
%\draw[help lines] (-4,-4) grid (8,4);
\begin{scope}
\fill[lightColor] \firstcircle;
\fill[lightColor] \secondcircle;
\clip \firstcircle;
\fill[mediumColor] \secondcircle;
\end{scope}
\draw \firstcircle ;
\draw (-1,0) node [left] (LeftLabel) {Cancer} ;
\draw node[below of=LeftLabel, node distance=.4cm] {1710};
\draw \secondcircle ;
\draw (1,0) node [right] (RightLabel) {Control};
\draw node [below of=RightLabel, node distance=.4cm] {2180};
\draw (0,0) node [] (overlap) {};
\draw node [below of=overlap, node distance=.4cm] {373};
\end{tikzpicture}%
\caption{Overlap of valley regions in tumourigenic cell line vs. control}
\end{figure}
\end{document}
请注意,您还可以使用透明度(例如opacity
选项),以便重叠区域自动获得不同的颜色。我还会使用circle
形状节点。
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{babel}
\usepackage{multicol}
\usepackage{tikz}
\begin{document}
%
\begin{figure}
\centering
\definecolor{darkColor}{rgb}{0.102,0,0.2} %darkPurple
\definecolor{mediumColor}{rgb}{0.2,0,0.4} %purple
\definecolor{lightColor}{rgb}{0.413,0.315,0.615} %lightPurple
\begin{tikzpicture}[scale=1,text=white,font=\sffamily]
\def\firstcircle{(-1.25,0) circle (1.75)}
\def\secondcircle{(1.25,0) circle (1.75)}
\node [fill=lightColor,draw=black,circle,minimum size=3.5cm,align=center,opacity=.666,text=white] at (-1.25,0)
(Cancer) {Cancer\\1710};
\node [fill=lightColor,draw=black,circle,minimum size=3.5cm,align=center,opacity=.666,text=white] at (+1.25,0)
(Control) {Control\\2180};
\path (Cancer) -- (Control) node [midway] {373};
\end{tikzpicture}%
\caption{Overlap of valley regions in tumourigenic cell line vs. control}
\end{figure}
\end{document}