如何使用 TikZ 在笛卡尔坐标系内绘制文本?

如何使用 TikZ 在笛卡尔坐标系内绘制文本?

我是 Ti 新手Z 并想知道如何绘制如下所示的简单图形。

示例图片

答案1

你可以

  • 用于pgfplots绘制带有网格、轴和带标签刻度的坐标系,无需绘制任何图
  • axis cs通过坐标将文本放置为节点
  • 使用字体类型和大小的样式

例如:

\documentclass[border=10pt]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}[every node/.append style={font=\sffamily\footnotesize}]
  \begin{axis}[
      axis y line     = left,
      axis x line     = bottom,
      xtick           = {-37,-36,...,-29},
      ytick           = {9,9.5,...,14},
      ticklabel style = {font = \sffamily\footnotesize},
      grid,
      grid style = {color=gray!50, dotted},
      xmin       = -38,   xmax = -28,
      ymin       = 9,     ymax = 14,
    ]      
    \node at (axis cs:-34,10)   {companies};
    \node at (axis cs:-32,12)   {institutions};
    \node at (axis cs:-34,13.4) {Agency};
    \node at (axis cs:-37,13)   {schools};
  \end{axis}
\end{tikzpicture}
\end{document}

阴谋

答案2

有一点像Stefan 的回答但表中有(部分)数据:

\documentclass[tikz,border=5]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\pgfplotstableread{%
x     y     label        
-37   13.25 school       
-34   13.25 Agency       
-33   14.00 body         
-34   12.50 organisation 
-34.5 12.00 organizations
-32    9.50 industry     
-34   10.00 companies    
-30   14.00 office       
-34.5 12.75 agencies     
-36.5 11.75 Association
-35.5 9.5   society 
}\data
\begin{document}
\begin{tikzpicture}
\begin{axis}[axis y line=left, axis x line=bottom,
  xmin=-38, xmax=-27, ymin=9, ymax=14.5,
  every node near coord/.style={font=\sffamily}]
\addplot [only marks, nodes near coords, point meta=explicit symbolic] 
  table [x=x, y=y, meta=label] {\data};
\end{axis} 
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容