绘制图表的正确方法是什么?

绘制图表的正确方法是什么?

我制作了下面的图表,我想知道一种实用的或适当的方法来更轻松地绘制它。

\documentclass[border=4mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.multipart,arrows.meta,positioning,fit}
\begin{document}
\def\firstcircle{(-2,0) circle (1.5)}
\def\secondcircle{(0,0) circle (1.5)}
\begin{tikzpicture}
% letterings and missing pieces:
%\draw[step=0.5cm,gray,very thin] (-4,-2) grid (2,2); %Lineas guias
\draw[align=center] \firstcircle ;
\draw[align=center] \secondcircle ;
\draw[->] (1.5,0) -- (2,0) ;
\draw[->] (-3.5,0) -- (-4,0) ;
\draw[->] (-5,0.3) -- (-5,0.7);
\draw[->] (-5,-0.35) -- (-5,-0.75);
\draw[->] (3,0.3) -- (3,0.7);
\draw[->] (3,-0.35) -- (3,-0.75);
\node at (0.5, 0) {\scriptsize \textbf{Qualitative}};
\node at (-2.5, 0) {\scriptsize \textbf{Quantitative}};
\node at (3,0.15) {\scriptsize Interviews};
\node at (3,-0.2) {\scriptsize Documentary Research};
\node at (-5,0.15) {\scriptsize Secondary Data};
\node at (-5,-0.2) {\scriptsize Panel Set};
\node at (-5,1.35) {\tiny \textbf{Living Standars Measurement Survey}};
\node at (-5,1) {\tiny \textbf{1993,~98,~01,~05,~2014}};
\node at (-5,-1.05) {\tiny \textbf{Latinobarómetro:}};
\node at (-5,-1.40) {\tiny \textbf{1996 to 2015}};
\node at (3,1.35) {\tiny \textbf{Government, Private Sector}}; 
\node at (3,1) {\tiny \textbf{Workers and Labor Unions}};
\node at (3,-1.05) {\tiny \textbf{National Human Development PLan}};
\end{tikzpicture}
\end{document}

在此处输入图片描述

我希望在每个圆圈的中间得到“定量”和“定性”,并且不交叉它们。

答案1

我建议这样做。这种方法还使用了positioning库中的相对定位。它使用无衬线字体,这种字体在图表中通常效果更好。对于最小的字体大小,它使用 Latin Modern Quotation Sans,这种字体专为小尺寸的易读性而设计。我猜小尺寸是由于空间有限,但这个图表只是稍微大一点,如果真的有必要,可以做得比原来的更小。

相对定位和专业字体

这张图片的代码是

\begin{tikzpicture}
  [
    basic/.style={align=center},
    small node/.style={font=\quotefont\scriptsize},
    tiny node/.style={font=\quotefont\tiny, inner ysep=0pt},
    qual/.style={basic},
    quant/.style={basic},
    main circle/.style={circle, draw, inner sep=5mm, font=\sffamily\bfseries\small, text width=25mm, text centered},
    arrow line/.style={->, shorten >=2pt},
    main arrow/.style={<-, shorten >=2pt},
    >=Latex,
  ]
  \node (ql) [main circle, qual] {Qualitative};
  \node (qt) [main circle, left=of ql.center, quant] {Quantitative};
  \node (qlr) [small node, qual, right=5mm of ql] {Interviews\\Documentary Research};
  \node (qtr) [small node, quant, left=5mm of qt] {Secondary Data\\Panel Set};
  \node (qlo) [tiny node, qual, anchor=north] at (ql.north -| qlr) {Government\\Private Sector\\Workers \& Labor Unions};
  \node (qlp) [tiny node, qual, anchor=south] at (ql.south -| qlr) {National Human\\Development Plan};
  \node (qts) [tiny node, quant, anchor=north] at (ql.north -| qtr) {Living Standards\\Measurement Survey\\1993,\thinspace 98,\thinspace01,\thinspace 05,\thinspace 2014};
  \node (qtm) [tiny node, quant, anchor=south] at (ql.south -| qtr) {Latinobarómetro\\1996--2015};
  \draw [main arrow] (qlr) edge [arrow line] (qlo) edge [arrow line] (qlp) -- (ql);
  \draw [main arrow] (qtr) edge [arrow line] (qts) edge [arrow line] (qtm) -- (qt);
\end{tikzpicture}

样式的目的是可以灵活、一致地轻松更改格式:

  • small node对于较小的节点;
  • tiny node对于最小的孩子来说;
  • main circle对于圆形节点;
  • qual对于定性方面的节点;
  • quant对于那些注重定量研究的人来说;
  • basic用于定性和定量节点通用的格式;
  • arrow line向上/向下箭头;
  • main arrow表示左/右的。

如上所述,qualquant是多余的,因为它们只包含basic。但是,这种方法的好处是能够自由地进行实验并一致地修改格式。例如,假设我们使用库添加和重新定义样式,如下所示shadows.blur

    ...
    colour me/.style={text=#1, draw=#1},
    side node/.style={rounded corners,fill=white, thick, blur shadow},
    small node/.style={font=\quotefont\scriptsize, side node},
    tiny node/.style={font=\quotefont\tiny, side node},
    qual/.style={basic, colour me=magenta},
    quant/.style={basic, colour me=blue!75!cyan},
    main circle/.style={circle, inner sep=5mm, font=\sffamily\bfseries\small, text width=25mm, text centered, line width=1pt},
    ...

重新设计的示例

如果我们想在圆圈后面添加阴影,事情会变得有点棘手。为此,我们可能还需要编辑图片代码本身。

为此,我们可能会添加一种特殊的风格

    main circle first pass/.style={main circle, basic, blur shadow, fill=white, colour me=white},

然后开始我们的图片

  \node (qt-1) [main circle first pass] {Quantitative};
  \node (ql-1) [main circle first pass, right=of qt-1.center] {Qualitative};
  \node (ql) [main circle, qual] at (ql-1) {Qualitative};
  \node (qt) [main circle, quant] at (qt-1) {Quantitative};

这是一种将阴影保留在背景中的廉价方法。

阴影圆圈

如果你需要避免使用颜色,仍然可以给图表增加一些深度。例如,我们可以简单地调整quantqual

    qual/.style={basic, colour me=darkgray},
    quant/.style={basic, colour me=darkgray},

或许可以增加darkgray箭头的定义:

灰度版本

完整代码:

\documentclass[tikz,border=10pt]{standalone}
\usepackage[utf8]{inputenc}
\newcommand*\quotefont{\normalfont}
\newcommand*\qtfont[1]{%
  \renewcommand*\quotefont{#1}%
}
\usepackage[sf={lining,proportional},rm={lining,proportional},tt={monowidth,tabular,lining},qt=true]{cfr-lm}
\usetikzlibrary{arrows.meta,positioning,shadows.blur}
\begin{document}
\begin{tikzpicture}
  [
    basic/.style={align=center},
    small node/.style={font=\quotefont\scriptsize},
    tiny node/.style={font=\quotefont\tiny, inner ysep=0pt},
    qual/.style={basic},
    quant/.style={basic},
    main circle/.style={circle, draw, inner sep=5mm, font=\sffamily\bfseries\small, text width=25mm, text centered},
    arrow line/.style={->, shorten >=2pt},
    main arrow/.style={<-, shorten >=2pt},
    >=Latex,
  ]
  \node (ql) [main circle, qual] {Qualitative};
  \node (qt) [main circle, left=of ql.center, quant] {Quantitative};
  \node (qlr) [small node, qual, right=5mm of ql] {Interviews\\Documentary Research};
  \node (qtr) [small node, quant, left=5mm of qt] {Secondary Data\\Panel Set};
  \node (qlo) [tiny node, qual, anchor=north] at (ql.north -| qlr) {Government\\Private Sector\\Workers \& Labor Unions};
  \node (qlp) [tiny node, qual, anchor=south] at (ql.south -| qlr) {National Human\\Development Plan};
  \node (qts) [tiny node, quant, anchor=north] at (ql.north -| qtr) {Living Standards\\Measurement Survey\\1993,\thinspace 98,\thinspace01,\thinspace 05,\thinspace 2014};
  \node (qtm) [tiny node, quant, anchor=south] at (ql.south -| qtr) {Latinobarómetro\\1996--2015};
  \draw [main arrow] (qlr) edge [arrow line] (qlo) edge [arrow line] (qlp) -- (ql);
  \draw [main arrow] (qtr) edge [arrow line] (qts) edge [arrow line] (qtm) -- (qt);
\end{tikzpicture}
\begin{tikzpicture}
  [
    basic/.style={align=center},
    colour me/.style={text=#1, draw=#1},
    side node/.style={rounded corners,fill=white, thick, blur shadow},
    small node/.style={font=\quotefont\scriptsize, side node},
    tiny node/.style={font=\quotefont\tiny, side node},
    qual/.style={basic, colour me=magenta},
    quant/.style={basic, colour me=blue!75!cyan},
    main circle/.style={circle, inner sep=5mm, font=\sffamily\bfseries\small, text width=25mm, text centered, line width=1pt},
    arrow line/.style={->, shorten >=2pt},
    main arrow/.style={<-, shorten >=2pt},
    >=Latex,
  ]
  \node (ql) [main circle, qual] {Qualitative};
  \node (qt) [main circle, left=of ql.center, quant] {Quantitative};
  \node (qlr) [small node, qual, right=5mm of ql] {Interviews\\Documentary Research};
  \node (qtr) [small node, quant, left=5mm of qt] {Secondary Data\\Panel Set};
  \node (qlo) [tiny node, qual, anchor=north] at (ql.north -| qlr) {Government\\Private Sector\\Workers \& Labor Unions};
  \node (qlp) [tiny node, qual, anchor=south] at (ql.south -| qlr) {National Human\\Development Plan};
  \node (qts) [tiny node, quant, anchor=north] at (ql.north -| qtr) {Living Standards\\Measurement Survey\\1993,\thinspace 98,\thinspace01,\thinspace 05,\thinspace 2014};
  \node (qtm) [tiny node, quant, anchor=south] at (ql.south -| qtr) {Latinobarómetro\\1996--2015};
  \draw [main arrow] (qlr) edge [arrow line] (qlo) edge [arrow line] (qlp) -- (ql);
  \draw [main arrow] (qtr) edge [arrow line] (qts) edge [arrow line] (qtm) -- (qt);
\end{tikzpicture}
\begin{tikzpicture}
  [
    basic/.style={align=center},
    colour me/.style={text=#1, draw=#1},
    side node/.style={rounded corners, fill=white, thick, blur shadow},
    small node/.style={font=\quotefont\scriptsize, side node},
    tiny node/.style={font=\quotefont\tiny, side node},
    qual/.style={basic, colour me=magenta},
    quant/.style={basic, colour me=blue!75!cyan},
    main circle/.style={circle, inner sep=5mm, font=\sffamily\bfseries\small, text width=25mm, text centered, line width=1pt},
    main circle first pass/.style={main circle, basic, blur shadow, fill=white, colour me=white},
    arrow line/.style={->, shorten >=2pt},
    main arrow/.style={<-, shorten >=2pt},
    >=Latex,
  ]
  \node (qt-1) [main circle first pass] {Quantitative};
  \node (ql-1) [main circle first pass, right=of qt-1.center] {Qualitative};
  \node (ql) [main circle, qual] at (ql-1) {Qualitative};
  \node (qt) [main circle, quant] at (qt-1) {Quantitative};
  \node (qlr) [small node, qual, right=5mm of ql] {Interviews\\Documentary Research};
  \node (qtr) [small node, quant, left=5mm of qt] {Secondary Data\\Panel Set};
  \node (qlo) [tiny node, qual, anchor=north] at (ql.north -| qlr) {Government\\Private Sector\\Workers \& Labor Unions};
  \node (qlp) [tiny node, qual, anchor=south] at (ql.south -| qlr) {National Human\\Development Plan};
  \node (qts) [tiny node, quant, anchor=north] at (ql.north -| qtr) {Living Standards\\Measurement Survey\\1993,\thinspace 98,\thinspace01,\thinspace 05,\thinspace 2014};
  \node (qtm) [tiny node, quant, anchor=south] at (ql.south -| qtr) {Latinobarómetro\\1996--2015};
  \draw [main arrow] (qlr) edge [arrow line] (qlo) edge [arrow line] (qlp) -- (ql);
  \draw [main arrow] (qtr) edge [arrow line] (qts) edge [arrow line] (qtm) -- (qt);
\end{tikzpicture}
\begin{tikzpicture}
  [
    basic/.style={align=center},
    colour me/.style={text=#1, draw=#1},
    side node/.style={rounded corners, fill=white, thick, blur shadow},
    small node/.style={font=\quotefont\scriptsize, side node},
    tiny node/.style={font=\quotefont\tiny, side node},
    qual/.style={basic, colour me=darkgray},
    quant/.style={basic, colour me=darkgray},
    main circle/.style={circle, inner sep=5mm, font=\sffamily\bfseries\small, text width=25mm, text centered, line width=1pt},
    main circle first pass/.style={main circle, basic, blur shadow, fill=white, colour me=white},
    arrow line/.style={->, shorten >=2pt, darkgray},
    main arrow/.style={<-, shorten >=2pt, darkgray},
    >=Latex,
  ]
  \node (qt-1) [main circle first pass] {Quantitative};
  \node (ql-1) [main circle first pass, right=of qt-1.center] {Qualitative};
  \node (ql) [main circle, qual] at (ql-1) {Qualitative};
  \node (qt) [main circle, quant] at (qt-1) {Quantitative};
  \node (qlr) [small node, qual, right=5mm of ql] {Interviews\\Documentary Research};
  \node (qtr) [small node, quant, left=5mm of qt] {Secondary Data\\Panel Set};
  \node (qlo) [tiny node, qual, anchor=north] at (ql.north -| qlr) {Government\\Private Sector\\Workers \& Labor Unions};
  \node (qlp) [tiny node, qual, anchor=south] at (ql.south -| qlr) {National Human\\Development Plan};
  \node (qts) [tiny node, quant, anchor=north] at (ql.north -| qtr) {Living Standards\\Measurement Survey\\1993,\thinspace 98,\thinspace01,\thinspace 05,\thinspace 2014};
  \node (qtm) [tiny node, quant, anchor=south] at (ql.south -| qtr) {Latinobarómetro\\1996--2015};
  \draw [main arrow] (qlr) edge [arrow line] (qlo) edge [arrow line] (qlp) -- (ql);
  \draw [main arrow] (qtr) edge [arrow line] (qts) edge [arrow line] (qtm) -- (qt);
\end{tikzpicture}
\end{document}

答案2

以下是我通过定义节点来绘制事物的方法。我为每个圆的中心定义了两个坐标,并相对于这些坐标放置了标签(定性/定量),然后使用lcentre/rcentre作为中心将圆绘制为节点,将圆绘制为节点允许我使用\draw[->] (rcirc) -- (interviews) ;箭头自动从圆的边缘(而不是中心)指向相对标签的位置。根据确切的需求,可能最好使用将(rcirc.east)起点具体指定为圆的最右边点的位置。

我只精确地定位了四个东西(忽略定性/定量标签和圆的半径),两个圆的中心和节点“访谈\文献研究”和“二次数据\面板集”在两种情况下它们似乎是一个元素,所以我将它们组合成一个节点(使用TikZ 节点中的手动/自动换行和文本对齐),而不是让两个节点靠得很近。

其余节点的定位是通过\node (livingstandards) [above=of secondarydata]自动将节点相对于现有节点进行定位(我认为有一些空间可以更精确地指定两个节点之间的间隙等)然后所有连接箭头都像\draw[->] (rcirc) -- (interviews) ;这样写,如果节点移动,箭头会自动跟踪它,而不需要更新硬连线坐标。

\documentclass[border=4mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.multipart,arrows.meta,positioning,fit}
\begin{document}

\begin{tikzpicture}
\coordinate [label={[centered,xshift=-0.5cm]:\scriptsize \textbf{Quantitative}}] (lcentre) at (-2,0);
\coordinate [label={[centered,xshift=0.5cm]:\scriptsize \textbf{Qualitative}}](rcentre) at (0,0);
\node (lcirc) [circle,draw,minimum width=3cm] at (lcentre) {};
\node (rcirc) [circle,draw,minimum width=3cm] at (rcentre) {};
\node (interviews) at (4,0) [align=center,font=\scriptsize] { Interviews \\  Documentary Research};
\node (secondarydata) at (-6,0) [align=center,font=\scriptsize] { Secondary Data \\ Panel Set};
\node (livingstandards) [above=of secondarydata] [align=center,font=\tiny\bfseries] {Living Standards Measurement Survey \\ 1993,~98,~01,~05,~2014};
\node (latinobarometro) [below=of secondarydata] [align=center,font=\tiny\bfseries] {Latinobarómetro: \\ 1996 to 2015};
\node (government) [above=of interviews] [align=center,font=\tiny\bfseries] {Government, Private Sector \\ Workers and Labor Unions};
\node (nhdp) [below=of interviews] [align=center,font=\tiny\bfseries] {National Human Development Plan};
\draw[->] (rcirc) -- (interviews) ;
\draw[->] (lcirc) -- (secondarydata) ;
\draw[->] (secondarydata) -- (livingstandards);
\draw[->] (secondarydata) -- (latinobarometro);
\draw[->] (interviews) -- (government);
\draw[->] (interviews) -- (nhdp);
\end{tikzpicture}
\end{document}

制作 在此处输入图片描述

相关内容