我正在使用 Tikz 绘制二分图,但似乎没有使节点变小(您可以在代码中看到我为节点指定了不同的大小)或使它们看起来不透明/2D。如果您查看示例,它们似乎是 3D 的。
\documentclass[a4paper]{report}
\usepackage{tikz}
\usetikzlibrary{arrows,%
petri,%
topaths}%
\usepackage{tkz-berge}
\begin{document}
\begin{tikzpicture}[scale=1.5]
\SetVertexNoLabel
\tikzset{VertexStyle/.style ={shape = circle, ball color = black, draw, opacity=1, minimum size = 4pt, fill=black}}
\Vertex[x=0,y=0]{A}
\Vertex[x=2,y=2]{B}
\Vertex[x=3,y=1.5]{C}
\Vertex[x=4,y=0]{D}
\tikzset{VertexStyle/.style ={shape = circle, ball color = white, minimum size = 2pt, draw}}
\Vertex[x=0,y=2]{E}
\Vertex[x=2,y=0]{G}
\Vertex[x=3,y=0.5]{H}
\Vertex[x=4,y=2]{I}
\tikzstyle{EdgeStyle}=[]
\Edge(A)(G)
\Edge(A)(E)
\Edge(B)(E)
\Edge(B)(G)
\Edge(B)(I)
\Edge(C)(I)
\Edge(C)(H)
\Edge(D)(H)
\Edge(D)(G)
\Edge(D)(I)
\tikzstyle{EdgeStyle}=[bend right]
\Edge(A)(E)
\Edge(C)(H)
\end{tikzpicture}
\end{document}
答案1
设置inner sep
为零,然后将“顶点的最小大小”定义为所需值。例如:
\documentclass[a4paper]{report}
\usepackage{tkz-berge}
\begin{document}
\begin{tikzpicture}[scale=1.5, transform shape]
\SetVertexNoLabel
\tikzset{VertexStyle/.style = {shape=circle, ball color=black, draw,
opacity=0.8, minimum size=4pt, inner sep=0pt}}
\Vertex[x=0,y=0]{A}
\Vertex[x=2,y=2]{B}
\Vertex[x=3,y=1.5]{C}
\Vertex[x=4,y=0]{D}
\tikzset{VertexStyle/.style = {shape=circle, ball color = white, draw,
minimum size=2pt, inner sep=0pt}}
\Vertex[x=0,y=0]{A} % it override first definition of node A
\Vertex[x=0,y=2]{E}
\Vertex[x=2,y=0]{G}
\Vertex[x=3,y=0.5]{H}
\Vertex[x=4,y=2]{I}
\tikzstyle{EdgeStyle}=[]
\Edge(A)(G)
\Edge(A)(E)
\Edge(B)(E)
\Edge(B)(G)
\Edge(B)(I)
\Edge(C)(I)
\Edge(C)(H)
\Edge(D)(H)
\Edge(D)(G)
\Edge(D)(I)
\tikzstyle{EdgeStyle}=[bend right]
\Edge(A)(E)
\Edge(C)(H)
\end{tikzpicture}
\end{document}
关于opacity
您想要获得什么,我不清楚。如果您希望有一些透明度,那么您需要将其设置opacity
为小于 1(在 MWE 中我将其设置为opacity=0.8
)。
答案2
如果您设置,scale=0.5,opacity=0.5
您将获得原始大小一半且透明度为 50% 的节点。
\documentclass[a4paper]{report}
\usepackage{tikz}
\usetikzlibrary{arrows,%
petri,%
topaths}%
\usepackage{tkz-berge}
\begin{document}
\begin{tikzpicture}[scale=1.5]
\SetVertexNoLabel
\tikzset{VertexStyle/.style ={shape = circle, ball color = black, draw, opacity=1, minimum size = 4pt, fill=black}}
\Vertex[x=0,y=0]{A}
\Vertex[x=2,y=2]{B}
\Vertex[x=3,y=1.5]{C}
\Vertex[x=4,y=0]{D}
\tikzset{VertexStyle/.style ={shape = circle, ball color = white,
scale=0.5,opacity=0.5, draw}}
\Vertex[x=0,y=2]{E}
\Vertex[x=2,y=0]{G}
\Vertex[x=3,y=0.5]{H}
\Vertex[x=4,y=2]{I}
\tikzstyle{EdgeStyle}=[]
\Edge(A)(G)
\Edge(A)(E)
\Edge(B)(E)
\Edge(B)(G)
\Edge(B)(I)
\Edge(C)(I)
\Edge(C)(H)
\Edge(D)(H)
\Edge(D)(G)
\Edge(D)(I)
\tikzstyle{EdgeStyle}=[bend right]
\Edge(A)(E)
\Edge(C)(H)
\end{tikzpicture}
\end{document}