在 Tikz 中绘制秀丽隐杆线虫生殖系

在 Tikz 中绘制秀丽隐杆线虫生殖系

我正在尝试使用 Ti 绘制秀丽隐杆线虫种系Z. 我用过Philippe Goutet 的/脚本创建“带有实心圆圈的六边形” 在此处输入图片描述

代码如下

\documentclass[11pt]{article}
\usepackage{tikz,xcolor}
\usetikzlibrary{patterns}
\definecolor{dapi}{RGB}{0,170,255}
\def\hexagonsize{0.2cm}
\pgfdeclarepatternformonly % hexagons pattern definition
{hexagons}% name
{\pgfpointorigin}% lower left
{\pgfpoint{3*\hexagonsize}{0.866025*2*\hexagonsize}}%  upper right
{\pgfpoint{3*\hexagonsize}{0.866025*2*\hexagonsize}}%  tile size
{% shape description
\pgfsetlinewidth{0.4pt}
\pgftransformshift{\pgfpoint{0mm}{0.866025*\hexagonsize}}
\pgfpathmoveto{\pgfpoint{0mm}{0mm}}
\pgfpathlineto{\pgfpoint{0.5*\hexagonsize}{0mm}}
\pgfpathlineto{\pgfpoint{\hexagonsize}{-0.866025*\hexagonsize}}
\pgfpathlineto{\pgfpoint{2*\hexagonsize}{-0.866025*\hexagonsize}}
\pgfpathlineto{\pgfpoint{2.5*\hexagonsize}{0mm}}
\pgfpathlineto{\pgfpoint{3*\hexagonsize+0.2mm}{0mm}}
\pgfpathmoveto{\pgfpoint{0.5*\hexagonsize}{0mm}}
\pgfpathlineto{\pgfpoint{\hexagonsize}{0.866025*\hexagonsize}}
\pgfpathlineto{\pgfpoint{2*\hexagonsize}{0.866025*\hexagonsize}}
\pgfpathlineto{\pgfpoint{2.5*\hexagonsize}{0mm}}
\pgfusepath{stroke}
\pgfsetfillcolor{dapi} % setting up fill color, doesn't work with any color other than shades of gray like "gray!30"
\pgfpathcircle{\pgfpoint{1.5*\hexagonsize}{0mm}}{0.5*\hexagonsize} % adding filled circles in hexagons
\pgfpathcircle{\pgfpoint{0mm}{0.866025*\hexagonsize}}{0.5*\hexagonsize}
\pgfpathcircle{\pgfpoint{0mm}{-0.866025*\hexagonsize}}{0.5*\hexagonsize}
\pgfpathcircle{\pgfpoint{3*\hexagonsize}{0.866025*\hexagonsize}}{0.5*\hexagonsize}
\pgfpathcircle{\pgfpoint{3*\hexagonsize}{-0.866025*\hexagonsize}}{0.5*\hexagonsize}
\pgfusepath{fill}
}
    \begin{document}
\begin{tikzpicture}
\path
[fill]
[pattern=hexagons]
(16,0) -- (4,0) to [out = 180, in = 270] (1,0.95) to [out = 90, in = 180] (4,1.9) -- (16,1.9) -- cycle;
\fill[green!35] (4,0) to [out = 180, in = 270] (0.5,0.95) to [out = 90, in = 180] (4,1.9) to 
[out = 180, in = 90](1,0.95) to [out = 270, in = 180] (4,0);
\fill [blue!50](0.75,1) circle [x radius=3mm, y radius=1.5mm, rotate=60];
\end{tikzpicture}
\end{document}

我的主要问题是它\pgfsetfillcolor{dapi}不起作用,我无法将其更改为灰色以外的任何颜色。图片描绘了秀丽隐杆线虫生殖系的一部分,左侧是远端。每个六边形是一个细胞,每个填充的圆圈是一个细胞核。图顶部的数字代表细胞的行号(仅供参考,不是必需的)。理想情况下,我希望拥有,

  • green前 20 行圆圈将用第 19 行和第 20 行中的几个红色填充核填充。
  • 第 21 行最右端应填充红色原子核(但请参见下文)
  • 第 21 行至第 30 行之间的约三分之一的细胞核呈新月形、红色且随机分布(显示为第 21 行的深蓝色细胞核,不是通过 Tikz 生成的,而是后来添加的)。
  • 第 21 行和第 26 行之间约有 5-7 个随机核,呈圆形并填充为绿色。

不用说,我对 Ti 的了解Z /LaTeX 几乎为零。但似乎我所要求的对于定义的模式来说非常困难,但如果有人能解决这个问题,我也不会感到惊讶。如果有人向我解释如何更改填充颜色以及我做错了什么,我会很高兴!

答案1

有两种图案:固有颜色的图案和无色的图案。此图案定义为“仅形式”。定义中不打算采用颜色,假定颜色为无色。而是pattern color在使用图案时使用来设置颜色。

\documentclass[border=10pt,11pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{patterns}
\definecolor{dapi}{RGB}{0,170,255}
\def\hexagonsize{0.2cm}
\pgfdeclarepatternformonly % hexagons pattern definition
{hexagons}% name
{\pgfpointorigin}% lower left
{\pgfpoint{3*\hexagonsize}{0.866025*2*\hexagonsize}}%  upper right
{\pgfpoint{3*\hexagonsize}{0.866025*2*\hexagonsize}}%  tile size
{% shape description
\pgfsetlinewidth{0.4pt}
\pgftransformshift{\pgfpoint{0mm}{0.866025*\hexagonsize}}
\pgfpathmoveto{\pgfpoint{0mm}{0mm}}
\pgfpathlineto{\pgfpoint{0.5*\hexagonsize}{0mm}}
\pgfpathlineto{\pgfpoint{\hexagonsize}{-0.866025*\hexagonsize}}
\pgfpathlineto{\pgfpoint{2*\hexagonsize}{-0.866025*\hexagonsize}}
\pgfpathlineto{\pgfpoint{2.5*\hexagonsize}{0mm}}
\pgfpathlineto{\pgfpoint{3*\hexagonsize+0.2mm}{0mm}}
\pgfpathmoveto{\pgfpoint{0.5*\hexagonsize}{0mm}}
\pgfpathlineto{\pgfpoint{\hexagonsize}{0.866025*\hexagonsize}}
\pgfpathlineto{\pgfpoint{2*\hexagonsize}{0.866025*\hexagonsize}}
\pgfpathlineto{\pgfpoint{2.5*\hexagonsize}{0mm}}
\pgfusepath{stroke}
\pgfsetfillcolor{dapi} % setting up fill color, doesn't work with any color other than shades of gray like "gray!30"
\pgfpathcircle{\pgfpoint{1.5*\hexagonsize}{0mm}}{0.5*\hexagonsize} % adding filled circles in hexagons
\pgfpathcircle{\pgfpoint{0mm}{0.866025*\hexagonsize}}{0.5*\hexagonsize}
\pgfpathcircle{\pgfpoint{0mm}{-0.866025*\hexagonsize}}{0.5*\hexagonsize}
\pgfpathcircle{\pgfpoint{3*\hexagonsize}{0.866025*\hexagonsize}}{0.5*\hexagonsize}
\pgfpathcircle{\pgfpoint{3*\hexagonsize}{-0.866025*\hexagonsize}}{0.5*\hexagonsize}
\pgfusepath{fill}
}
    \begin{document}
\begin{tikzpicture}
\path
[fill]
[pattern=hexagons, pattern color=dapi]
(16,0) -- (4,0) to [out = 180, in = 270] (1,0.95) to [out = 90, in = 180] (4,1.9) -- (16,1.9) -- cycle;
\fill[green!35] (4,0) to [out = 180, in = 270] (0.5,0.95) to [out = 90, in = 180] (4,1.9) to
[out = 180, in = 90](1,0.95) to [out = 270, in = 180] (4,0);
\fill [blue!50](0.75,1) circle [x radius=3mm, y radius=1.5mm, rotate=60];
\end{tikzpicture}
\end{document}

彩色图案

然而,如果你需要不同的核,那么你就不能用一个模式来做到这一点。你可以理论上,将六边形绘制为图案,然后单独添加核。然而,这可能相当容易出错,即使在编译时间方面稍快一​​些。将核与包含它的六边形单元一起绘制可能更容易、更可靠。这样,您可以引入尽可能多的变化。

例如,

\documentclass[border=10pt,11pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\definecolor{dapi}{RGB}{0,170,255}
\begin{document}
\begin{tikzpicture}
  [
    hexa/.style={draw=dapi, minimum size=\hdim, inner sep=0pt, regular polygon, regular polygon sides=6, anchor=center},
    nucleus/.style={fill, minimum size=.35*\hdim, inner sep=0pt, circle, anchor=center},
  ]
  \begin{scope}
    \clip (16,0) coordinate (d) -- (4,0) coordinate (a) to [out = 180, in = 270] (1,0.95) coordinate (b) to [out = 90, in = 180] (4,1.9) coordinate (c) -- (d |- c) -- cycle (b |- c) coordinate (h0-0);
    \newdimen\hdim
    \newdimen\odim
    \hdim=3mm
    \pgfmathsetlength\odim{0.866025*\hdim}
    \foreach \j [remember=\j as \jlast (initially 0)] in {1,...,70}
    \foreach \i [remember=\i as \ilast (initially 0) ] in {1,...,8}
    {
      \ifodd\j\def\tempa{30}\else\def\tempa{-30}\fi
      \ifnum\j<21\def\tempb{green}\else\def\tempb{red}\fi
      \ifnum\j=19\ifnum\i=3\def\tempb{red}\fi\ifnum\i=7\def\tempb{red}\fi\fi
      \ifnum\j=20\ifnum\i=1\def\tempb{red}\fi\ifnum\i=5\def\tempb{red}\fi\ifnum\i=8\def\tempb{red}\fi\fi
      \ifnum\j=22\ifnum\i=4\def\tempb{green}\fi\fi
      \ifnum\j=24\ifnum\i=7\def\tempb{green}\fi\fi
      \ifnum\j=25\ifnum\i=6\def\tempb{green}\fi\fi
      \ifnum\j=24\ifnum\i=2\def\tempb{green}\fi\fi
      \ifnum\j=26\ifnum\i=3\def\tempb{green}\fi\fi
      \ifnum\j=21\ifnum\i=5\def\tempb{green}\fi\fi
      \ifnum\i=1
        \ifnum\j=1\path (h0-0) node (h\j-\i) [hexa] {} node [nucleus, \tempb] {};
        \else\path ([shift=(\tempa:\odim)]h\jlast-1) node (h\j-\i) [hexa]  {} node [nucleus, \tempb] {};
        \fi
      \else\path ([yshift=-\odim]h\j-\ilast) node (h\j-\i) [hexa] {} node [nucleus, \tempb] {};
      \fi
    };
  \end{scope}
  \fill[green!35] (a) to [out = 180, in = 270] (0.5,0.95) to [out = 90, in = 180] (c) to
  [out = 180, in = 90] (b) to [out = 270, in = 180] (a);
  \fill [blue!50] (0.75,1) circle [x radius=3mm, y radius=1.5mm, rotate=60];
\end{tikzpicture}
\end{document}

各种核

答案2

这是我根据 @cfr 的回答制作的最终图片,略作修改,加入了减数分裂后随机旋转的新月形核。对某些人可能有用。 *秀丽隐杆线虫*生殖系的远端生殖腺臂

代码如下,

\documentclass[border=10pt,11pt]{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\definecolor{dapi}{RGB}{0,170,255}
\begin{document}
\begin{tikzpicture}
  [
    hexa/.style={draw=dapi, minimum size=\hdim, inner sep=0pt, regular polygon, regular polygon sides=6, anchor=center},
    nucleus/.style={fill, minimum size=.5*\hdim, inner sep=0pt, circle, anchor=center},
    crescent/.style={fill = white, minimum size=.35*\hdim, inner sep=0pt, circle, anchor=south}
  ]
  \begin{scope}
    \clip (16,0) coordinate (d) -- (4,0) coordinate (a) to [out = 180, in = 270] (1,0.95) coordinate (b) to [out = 90, in = 180] (4,1.9) coordinate (c) -- (d |- c) -- cycle (b |- c) coordinate (h0-0);
    \newdimen\hdim
    \newdimen\odim
    \hdim=3.5mm
    \pgfmathsetlength\odim{0.866025*\hdim}
    \def\tempc{0}
    \foreach \j [remember=\j as \jlast (initially 0)] in {1,...,70}
    \foreach \i [remember=\i as \ilast (initially 0) ] in {1,...,8}
    \pgfmathsetseed{\j+\i} % for reproducibility
    \pgfmathrandominteger{\k}{1}{360} % k is (randomly) defind to rotate crescent nuclei
    {
      \ifodd\j\def\tempa{30}\else\def\tempa{-30}\fi
      \ifnum\j<21\def\tempb{green}\else\def\tempb{red}\fi
      \ifnum\j=19\ifnum\i=3\def\tempb{red}\fi\fi % tempb - to add red nuclei in progenitor zone and green nuclei in leptotene/zygotene
      \ifnum\j=20\ifnum\i=5\def\tempb{red}\fi\fi
      \ifnum\j=21\ifnum\i=5\def\tempb{green}\fi\fi
      \ifnum\j=22\ifnum\i=4\def\tempb{green}\fi\fi
      \ifnum\j=24\ifnum\i=7\def\tempb{green}\fi\fi
      \ifnum\j=25\ifnum\i=6\def\tempb{green}\fi\fi
      \ifnum\j=24\ifnum\i=2\def\tempb{green}\fi\fi
      \ifnum\j=26\ifnum\i=3\def\tempb{green}\fi\fi
      \ifnum\j=21\ifnum\i=4\def\tempc{1}\fi\fi % tempc for adding crescent shaped nuclei in laeptotene/zygotene region
      \ifnum\j=21\ifnum\i=6\def\tempc{1}\fi\fi      
      \ifnum\j=22\ifnum\i=2\def\tempc{1}\fi\fi
      \ifnum\j=22\ifnum\i=5\def\tempc{1}\fi\fi      
      \ifnum\j=22\ifnum\i=7\def\tempc{1}\fi\fi      
      \ifnum\j=23\ifnum\i=2\def\tempc{1}\fi\fi      
      \ifnum\j=23\ifnum\i=6\def\tempc{1}\fi\fi      
      \ifnum\j=23\ifnum\i=7\def\tempc{1}\fi\fi      
      \ifnum\j=24\ifnum\i=1\def\tempc{1}\fi\fi      
      \ifnum\j=24\ifnum\i=4\def\tempc{1}\fi\fi      
      \ifnum\j=25\ifnum\i=3\def\tempc{1}\fi\fi      
      \ifnum\j=25\ifnum\i=4\def\tempc{1}\fi\fi      
      \ifnum\j=25\ifnum\i=7\def\tempc{1}\fi\fi      
      \ifnum\j=26\ifnum\i=1\def\tempc{1}\fi\fi      
      \ifnum\j=26\ifnum\i=5\def\tempc{1}\fi\fi      
      \ifnum\j=27\ifnum\i=3\def\tempc{1}\fi\fi      
      \ifnum\j=27\ifnum\i=5\def\tempc{1}\fi\fi      
      \ifnum\j=28\ifnum\i=2\def\tempc{1}\fi\fi      
      \ifnum\j=28\ifnum\i=5\def\tempc{1}\fi\fi      
      \ifnum\j=28\ifnum\i=6\def\tempc{1}\fi\fi      
      \ifnum\j=29\ifnum\i=5\def\tempc{1}\fi\fi      
      \ifnum\j=31\ifnum\i=2\def\tempc{1}\fi\fi
      \ifnum\i=1
        \ifnum\j=1\path (h0-0) node (h\j-\i) [hexa] {} node [nucleus, \tempb] {} node [crescent, rotate=\k,opacity = \tempc] {};
        \else\path ([shift=(\tempa:\odim)]h\jlast-1) node (h\j-\i) [hexa]  {} node [nucleus, \tempb] {} node [crescent, rotate=\k,opacity = \tempc] {};
        \fi
      \else\path ([yshift=-\odim]h\j-\ilast) node (h\j-\i) [hexa] {} node [nucleus, \tempb] {}
      node [crescent, rotate=\k,opacity = \tempc] {};
      \fi
    };
  \end{scope}
  \fill[pink!45] (a) to [out = 180, in = 270] (0.5,0.95) to [out = 90, in = 180] (c) to
  [out = 180, in = 90] (b) to [out = 270, in = 180] (a);
  \fill [dapi] (0.75,1) circle [x radius=3mm, y radius=1.5mm, rotate=60];
  \node[above, rotate=90] (DTC) at (0.5,0.95) {DTC};
  \node[below, rotate = -30] (ME) at (6.4,0) {ME};
  \draw[dashed, ultra thick, color = blue] (6.13,1.9) -- (6.13,0);
  \node[above] (pz) at (4,1.9) {Progenitor Zone};
  \node[above] (lz) at (7,1.9) [align=left]{Leptotene/ \\Zygotene};
  \node[above] (pachytene) at (10,1.9) {Pachytene};
\end{tikzpicture}
\end{document}

再次感谢@cfr 和@PaulGaborit。

相关内容