matplotlib可视化系列之【排版】

虽然排版只是绘图中的一个辅助功能,但好的排版可以提高图形的表现力。

[En]

Although typesetting is only an auxiliary function in drawing, good typesetting can improve the expressiveness of graphics.

让人们一目了然地看到图形想要表达的内容和数据,而不是睁大眼睛看图片。

[En]

Let people see at a glance the content and data that the graphics want to express, instead of having to look in the picture with their eyes wide open.

如果说 matplotlib的坐标系统,各种基础元素,包括柱状图,折线图,散点图等它的硬实力,
那么,排版就是 matplotlib 的软实力,结合排版,能让分析结果给人一个良好的第一印象,增强别人对分析结果的信任。

排版是一个大话题,涉及很多细节,这里只从三个方面来改进排版,相比直接绘制图形,首先改进这三个方面,可以大大提高可视化的清晰度。

[En]

Typesetting is a big topic, involving a lot of details, here only from three aspects to improve typesetting, compared with directly drawing graphics, first improve these three aspects, can greatly improve the clarity of visualization.

层次

画画就像写文章,平淡的叙事很难吸引读者,情节的跌宕起伏才是吸引读者的法宝。

[En]

Drawing is the same as writing articles, flat narration is hardly attractive to readers, and the ups and downs of the plot is the magic weapon to attract readers.

画图时,只展示各种元素就像一篇记录当前账本的文章,枯燥乏味。

[En]

When drawing, just showing the various elements is like an article recording the current ledger, boring.

通过调整元素的位置、大小和厚度,还可以使图形显示完全不同的效果,如以下两幅图像:

[En]

By adjusting the position, size, and thickness of the elements, you can also make the graphics show completely different effects, such as the following two images:

matplotlib可视化系列之【排版】
代码参考:https://github.com/rougier/scientific-visualization-book/blob/master/code/typography/typography-matters.py

相对于第一个图,第二个图通过调整 matters 的大小和位置,以及坐标轴刻度的大小和粗细等,明显让人感觉到第二个图更加的精致。

字体

matplotlib 支持调整绘图中的字体,选择那种字体没有明确的原则,可以根据显示的内容,多试试几种字体,看看哪种看的更加顺眼。

例如,对于数学公式,清晰度比显示普通文本更重要,因为显示的内容更复杂。

[En]

For example, for mathematical formulas, clarity is more important than displaying ordinary text because the content of the display is more complex.

以下是以几种字体显示的数学公式,以体验差异。

[En]

The following is the display of mathematical formulas in several fonts to experience the differences.

代码参考:https://github.com/rougier/scientific-visualization-book/blob/master/code/typography/typography-math-stacks.py

matplotlib可视化系列之【排版】

选择与图形中的主要字体相似的字体来显示数学公式是很常见的。

[En]

It is common to choose fonts similar to the main fonts in the drawing to display mathematical formulas.

易辨认性

易认是一个很抽象的概念,具体来说,先做两件事。

[En]

Easy to recognize is a very abstract concept, specifically, do two things first.

首先,你可以从背景中清楚地看到文本。例如,下面的示例:

[En]

First, you can see the text clearly from the background. For example, the following example:

matplotlib可视化系列之【排版】
上面的图形中都有 Read me 几个字,第三排给文字加上背景,第四排给文字加了描边。
这显然比前两行的文本要清楚得多。
[En]

This is obviously much clearer than the text in the first two rows.

另一种提高可识别性的方法是,当图形更改时,可以显示与图形组合的文本,以便您可以一目了然地看到数据代表图形的哪一部分,例如:

[En]

Another way to improve recognizability is that text combined with graphics can be displayed as the graphics change, so that you can see at a glance which part of the graphics the data represents, such as:

matplotlib可视化系列之【排版】

图中的文本与等高线一起显示,不同的描述知道这些值代表等高线的数据。

[En]

The text in the figure is displayed with the contours, and different descriptions know that the values represent the data of the contours.

但文字的比例与图纸相同,文字看起来有点小。

[En]

But the scale of the text is the same as that of the drawing, and the text looks a little small.

数据都挤在一起,显示在等高线上的相同位置。您需要仔细识别它,然后才能看到这些值。

[En]

And the data are all huddled together and displayed in the same position on the contours. You need to identify it carefully before you can see the values.

下图放大了显示文本,并错开了轮廓上的值,从而提高了整个图形的可识别性。

[En]

The following picture magnifies the display text and stagger the values on the contours, which improves the recognizability of the whole figure.

matplotlib可视化系列之【排版】
大家可以体会下2个图的差别。

代码参见:https://github.com/rougier/scientific-visualization-book/blob/master/code/typography/typography-text-path.py

总结

如果排版的细节层出不穷,那么对完美排版的看法也不尽相同,没有完全统一的标准。

[En]

If the details of typesetting are endless, the views on perfect typesetting are also different, and there is no completely unified standard.

这里讨论的几点主要是从提高清晰度的角度出发,通过几个尽可能简单的改进,使我们的图形更加专业。

[En]

Several points discussed here are mainly from the point of view of improving clarity, through several improvements as simple as possible to make our graphics more professional.

Original: https://www.cnblogs.com/wang_yb/p/16367587.html
Author: wang_yb
Title: matplotlib可视化系列之【排版】

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/499401/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球