Posts

春秋时期的天文:星象

太阳下山,夜空中就会布满繁星。在浩瀚宇宙中传递了亿万年的星光,由于位置相近或偶然的投影,在夜空中形成了各种形状。人类看到这些形状就会联想到生活中的事物,或是想出新奇的故事。现代 88 个星座的命名有的历史悠久,有的则比较年轻。南天星座大多是大航海时代命名的,因此大多取象于航海仪器,比如六分仪座(Sextans)、望远镜座(Telescopim)。北半球的星座的命名则由来已久,往往是以神话命名的,比如武仙座(Hercules,宙斯的儿子大力士海格立斯)、仙后座(Cassiopeia,古代埃塞俄比亚的王后)。在中国,也有星座是用神话来命名的。《左传·昭公元年》子产给叔向讲了这么一个故事:
2020-08-19
7 min read

春秋时期的天文:日食

日升月落,星移斗转,是最鲜明的天体运动。先民在长期观察中,发现气候寒温、草木荣枯与天象之间存在紧密的关系。上古时期,历法还不够成熟,而且也不够普及;又没有准确的计时系统。天象在先民的日常生活中起着极其重要的作用。这就是为什么“三代以上,人人皆知天文”的缘故。到了后世,历法发达,计时系统逐渐准确,而大部分人又不必从事与气候紧密相关的农业劳动,因此,“有问之文人学士而懵然不知者”。
2020-08-17
6 min read

How to define aesthetic mappings of ggplot2 within another function

ggplot2 is great for visualization, but sometimes we need to include ggplot2 functions within another function. ggplot() uses aes() to define aesthetic mappings of different variables. The question is: how to define aesthetic mappings when writing functions using ggplot()? In this post I will present several approaches. First of all, let’s load the required packages and some test data. library(ggplot2) library(dplyr) data("mtcars") Using aes_string() There are two standard ways to define aesthetic mappings in ggplot2, aes_string() and aes_(). Writing a function using aes_string() is the same as using aes(), but calling the function requires passing the variable names as strings to the function.
2020-03-28
1 min read