![尝试将图表中的正方形改为圆形](https://linux22.com/image/357638/%E5%B0%9D%E8%AF%95%E5%B0%86%E5%9B%BE%E8%A1%A8%E4%B8%AD%E7%9A%84%E6%AD%A3%E6%96%B9%E5%BD%A2%E6%94%B9%E4%B8%BA%E5%9C%86%E5%BD%A2.png)
我正在尝试制作一个带有圆圈的 1D 隔间图,但是将 tikzstyle 更改为圆形并不能将其从正方形更改为圆形。
\documentclass[12pt]{report}
\usepackage{caption}
\usepackage{tikz}
\usetikzlibrary{arrows}
\begin{document}
\tikzstyle{int}=[draw, line width = 0.5mm, minimum size=5em]
\tikzstyle{make circle}=[circle, line width = 0.5 mm, minimum size=5em]
\begin{figure}
\centering
\begin{tikzpicture}[node distance=3cm,auto,>=latex']
\node [int] (a) {};
%%%%%%%%%%%%%
\node [makecircle] (c) [] {$M$}; %% This is the problem (still makes a square)
%%%%%%%%%%%
\node [int] (d) [right of=c, node distance=4cm] {$E$};
\draw[->, ultra thick, blue] (c) edge node {$r(1-p)$} (d);
\draw [green, ultra thick, ->]
([xshift=-0.25cm]a.north) to[out=120, in=60, distance=1.5cm] ([xshift=0.25cm]a.north);
\node [above=1.0cm,text=green] at (a.north) {$pr$};
\draw [red, ultra thick, ->] (0,-1) -- (0,-2);
\node [right=0.5cm,below=0.15cm,text=red] at (a.south) {$\approx 0$};
\end{tikzpicture}
\caption{This is a two compartment model}
\end{figure}
\end{document}
答案1
您用 绘制圆圈\node [int] (a) {};
(这里没有定义圆圈),但用 写下文本 M \node [makecircle] (c) [] {$M$};
(这里没有draw
)(您写makecircle
的不是make circle
。)
因为make circle
只会添加circle
,所以我删除了 tikzstyle 并重复使用该int
样式。
\documentclass[12pt]{report}
\usepackage{caption}
\usepackage{tikz}
\usetikzlibrary{arrows}
\begin{document}
\tikzstyle{int}=[draw, line width = 0.5mm, minimum size=5em]
\begin{figure}
\centering
\begin{tikzpicture}[node distance=3cm,auto,>=latex']
\node[int, circle] (c) [] {$M$};
\node [int] (d) [right of=c, node distance=4cm] {$E$};
\draw[->, ultra thick, blue] (c) edge node {$r(1-p)$} (d);
\draw [green, ultra thick, ->]
([xshift=-0.25cm]c.north) to[out=120, in=60, distance=1.5cm] ([xshift=0.25cm]c.north);
\node [above=1.0cm,text=green] at (c.north) {$pr$};
\draw [red, ultra thick, ->] (0,-1) -- (0,-2);
\node [right=0.5cm,below=0.15cm,text=red] at (c.south) {$\approx 0$};
\end{tikzpicture}
\caption{This is a two compartment model}
\end{figure}
\end{document}