我正在尝试更改 PGF\tikz 图像中图案的点/线间距。在默认设置下,许多图案看起来相同(点、交叉点、东北线),几乎难以区分 - 请参阅下面的代码!
我推测可以向 \fill[...] 添加一个额外的参数来完成这个操作,但我还没有在任何地方找到它。
\documentclass[11pt]{amsart}
%
%%%%%%%%%%%%%%%%% Packages %%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\usepackage{ifthen}
\usepackage{amsmath,amssymb}
%\usepackage[notref,notcite]{showkeys}
\usepackage{graphicx}
%\usepackage{psfrag}
\usepackage{fullpage}
%\usepackage{hyperref}
\usepackage{enumerate}
\usepackage{pgf,tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{positioning}
\usetikzlibrary{patterns}
\usepgflibrary{patterns}
\begin{document}
\definecolor{qqqqff}{rgb}{0,0,1}
\definecolor{ffqqqq}{rgb}{1,0,0}
\definecolor{ttzzqq}{rgb}{0,0.6,0}
\definecolor{cqcqcq}{rgb}{0.7529411764705882,0.7529411764705882,0.7529411764705882}
\begin{figure}[!ht]
\begin{center}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1cm,y=1cm]
\fill[line width=0pt,color=ttzzqq,fill=ttzzqq,pattern=crosshatch dots,pattern color=ttzzqq] (5.4,1.2) -- (6.8,1.4) -- (9,-2) -- (8.1,-2.6) -- cycle;
\fill[line width=0pt,color=ffqqqq,fill=ffqqqq,pattern=north east lines,pattern color=ffqqqq] (6.8,2.6) -- (11.2,2.6) -- (11.2,1.4) -- (6.8,1.4) -- cycle;
\fill[line width=0pt,color=qqqqff,fill=qqqqff,pattern= vertical lines,pattern color=qqqqff] (11.2,1.4) -- (9,-2) -- (9.9,-2.6) -- (12.6,1.2) -- cycle;
\end{tikzpicture}
\end{center}
\end{figure}
答案1
最新版本TikZ
引入了patterns.meta
一个库,它定义了可以参数化调整的新模式。新库似乎仍处于试验阶段,可以更改。但它可以满足您的要求。
\documentclass[11pt]{amsart}
%
%%%%%%%%%%%%%%%%% Packages %%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{amsmath,amssymb}
\usepackage{tikz}
\usetikzlibrary{arrows, positioning, patterns, patterns.meta}
\begin{document}
\definecolor{qqqqff}{rgb}{0,0,1}
\definecolor{ffqqqq}{rgb}{1,0,0}
\definecolor{ttzzqq}{rgb}{0,0.6,0}
\definecolor{cqcqcq}{rgb}{0.7529411764705882,0.7529411764705882,0.7529411764705882}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1cm,y=1cm]
\fill[line width=0pt,color=ttzzqq,fill=ttzzqq,pattern=crosshatch dots,pattern color=ttzzqq] (5.4,1.2) -- (6.8,1.4) -- (9,-2) -- (8.1,-2.6) -- cycle;
\fill[line width=0pt,color=ffqqqq,fill=ffqqqq,pattern=north east lines,pattern color=ffqqqq] (6.8,2.6) -- (11.2,2.6) -- (11.2,1.4) -- (6.8,1.4) -- cycle;
\fill[line width=0pt,color=qqqqff,fill=qqqqff,pattern= vertical lines,pattern color=qqqqff] (11.2,1.4) -- (9,-2) -- (9.9,-2.6) -- (12.6,1.2) -- cycle;
\end{tikzpicture}
\begin{tikzpicture}
\fill[pattern={Dots[distance=2mm, radius=1mm]}, pattern color=ttzzqq](5.4,1.2)--(6.8,1.4)-- (9,-2) -- (8.1,-2.6) -- cycle;
\fill[pattern={Lines[angle=45, line width=2pt, distance=2mm]},pattern color=ffqqqq] (6.8,2.6) -- (11.2,2.6) -- (11.2,1.4) -- (6.8,1.4) -- cycle;
\fill[pattern={Lines[angle=90, line width=3pt, distance=10pt]},pattern color=qqqqff, postaction={pattern={Lines[angle=90, xshift=5pt, line width=3pt, distance=10pt]}, pattern color=cqcqcq}] (11.2,1.4) -- (9,-2) -- (9.9,-2.6) -- (12.6,1.2) -- cycle; \end{tikzpicture}
\end{document}