在R中使用ggplot2绘制数据

Being able to create visualizations or graphical representations of data at hand is a key step in being able to communicate information and findings to others from a non-technical background.

能够创建手头数据的可视化图形表示形式是从非技术背景向其他人传达信息和发现的关键步骤。

In this story, you will learn to use the ggplot2 library in R to declaratively make beautiful plots or charts of your data.

在这个故事中,您将学习如何使用R中的ggplot2库来声明性地绘制数据的漂亮图形或图表。

什么是数据可视化? (What is Data Visualization?)

Wiki says “Data visualization is the graphic representation of data. It involves producing images that communicate relationships among the represented data to viewers of the images.”

Wiki说: “数据可视化数据的图形表示。 它涉及制作图像,以将表示的数据之间的关系传达给图像的查看者。”

什么是ggplot2? (What is ggplot2?)

Image for post

ggplot2 is a system for declaratively creating graphics, based on The Grammar of Graphics. You provide the data, tell ggplot2 how to map variables to aesthetics, what graphical primitives to use, and it takes care of the details.- Tidyverse.org

ggplot2是一个基于图形语法的声明式创建图形的系统。 您提供数据,告诉ggplot2如何将变量映射到美学,使用哪些图形基元以及如何处理细节。- Tidyverse.org

The inputs we are interested in are:

我们感兴趣的输入是:

  1. Call the ggplot(df) function which creates a blank canvas with the dataset(df) of interest

    调用ggplot(df)函数,该函数将使用感兴趣的数据集(df)创建一个空白画布

  2. Specify aesthetic mappings, which specifies how you want to map variables to visual aspects. In this case, we are simply mapping the variables to the x- and y-axes.

    指定美学映射,这指定了如何将变量映射到视觉方面。 在这种情况下,我们只是将变量映射到x轴和y轴。
  3. You then add new layers that are geometric objects which will show up on the plot and additional layers as required.

    然后添加作为几何对象的新图层,这些图层将显示在图形上,并根据需要添加其他图层。 </
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值