Bars, rectangles with bases on x-axis
Usage
- geom_bar(mapping = NULL, data = NULL, stat = "bin", position = "stack", ...)
Arguments
- mapping
- The aesthetic mapping, usually constructed with
aes
oraes_string
. Only needs to be set at the layer level if you are overriding the plot defaults. - data
- A layer specific dataset - only needed if you want to override the plot defaults.
- stat
- The statistical transformation to use on the data for this layer.
- position
- The position adjustment to use for overlappling points on this layer
- ...
- other arguments passed on to
layer
. This can include aesthetics whose values you want to set, not map. Seelayer
for more details.
Description
The bar geom is used to produce 1d area plots: bar charts for categorical x, and histograms for continuous y. stat_bin explains the details of these summaries in more detail. In particular, you can use the weight
aesthetic to create weighted histograms and barcharts where the height of the bar no longer represent a count of observations, but a sum over some other variable. See the examples for a practical example.
Details
The heights of the bars commonly represent one of two things: either a count of cases in each group, or the values in a column of the data frame. By default, geom_bar
uses stat="bin"
. This makes the height of each bar equal to the number of cases in each group, and it is incompatible with mapping values to the y
aesthetic. If you want the heights of the bars to represent values in the data, use stat="identity"
and map a value to the y
aesthetic.
By default, multiple x's occuring in the same place will be stacked a top one another by position_stack. If you want them to be dodged from side-to-side, see position_dodge
. Finally, position_fill
shows relative propotions at each x by stacking the bars and then stretching or squashing to the same height.
Sometimes, bar charts are used not as a distributional summary, but instead of a dotplot. Generally, it's preferable to use a dotplot (see geom_point
) as it has a better data-ink ratio. However, if you do want to create this type of plot, you can set y to the value you have calculated, and use stat='identity'
A bar chart maps the height of the bar to a variable, and so the base of the bar must always been shown to produce a valid visual comparison. Naomi Robbins has a nice article on this topic. This is the reason it doesn't make sense to use a log-scaled y axis with a bar chart
Aesthetics
geom_bar
understands the following aesthetics (required aesthetics are in bold):
x
alpha
colour
fill
linetype
size
weight
Examples
Bars, rectangles with bases on x-axis的更多相关文章
- Flot Reference flot参考文档
Consider a call to the plot function:下面是对绘图函数plot的调用: var plot = $.plot(placeholder, data, options) ...
- 谈谈Python中列表、元组和数组的区别和骚操作
一.列表(List) 1.列表的特点 列表是以方括号“[]”包围的数据集合,不同成员以“,”分隔.如 L = [1,2,3], 列表a有3个成员. 列表是可变的数据类型[可进行增删改查],列表中可以包 ...
- UVA 10574 - Counting Rectangles 计数
Given n points on the XY plane, count how many regular rectangles are formed. A rectangle is regular ...
- UVA - 10574 Counting Rectangles
Description Problem H Counting Rectangles Input: Standard Input Output:Standard Output Time Limit: 3 ...
- 应用Apache Axis进行Web Service开发
转自(http://tscjsj.blog.51cto.com/412451/84813) 一.概述 SOAP原意为Simple Object Access Protocol(简单对象访问协议),是一 ...
- 有理数的稠密性(The rational points are dense on the number axis.)
每一个实数都能用有理数去逼近到任意精确的程度,这就是有理数的稠密性.The rational points are dense on the number axis.
- 使用axis开发web service服务端
一.axis环境搭建 1.安装环境 JDK.Tomcat或Resin.eclipse等. 2.到 http://www.apache.org/dyn/closer.cgi/ws/axis/1_4下载A ...
- PeopleSoft Rich Text Boxes上定制Tool Bars
在使用PT8.50或在8.51时,你可能遇到过Rich-text编辑框.该插件使你能够格式化文本,添加颜色.链接.图片等等.下面是效果图: 如果页面中只有这么一个字段,该文本框就会有足够的空间来容 ...
- AXIS最佳实践
前言: Axis是apache一个开源的webservice服务,需要web容器进行发布.本节主要用于介绍使用Axis开发webservice,包括服务端的创建.webservice的部署.客户端的调 ...
随机推荐
- 工作总结 MVC 验证 [Required] 必填 与 string 小知识
例如 添加页面有个 title 字段 设置了 [Required] 不填的时候 设置 还是验证不通过 设置为 还是不通过 说明了 验证只与页面上传不传值有关 与在后台设不设置值 无关. ...
- Linux内核scatterlist API介绍
1. 前言 我们在那些需要和用户空间交互大量数据的子系统(例如MMC[1].Video.Audio等)中,经常看到scatterlist的影子.对我们这些“非英语母语”的人来说,初见这个词汇,脑袋瞬间 ...
- Hibernate的like用法
直接写String sql = "from ClientInfo as a where a.client_name like '%"+ clientname+"%'&qu ...
- 机器学习(6): 层次聚类 hierarchical clustering
假设有N个待聚类的样本,对于层次聚类来说,步骤: 1.(初始化)把每个样本归为一类,计算每两个类之间的距离,也就是样本与样本之间的相似度: 2.寻找各个类之间最近的两个类, ...
- Git 基本分支规范
基本代码分支应该分为两类,一类是主要分支,包括线上主分支 Master 和开发主分支Develop:另一类是辅助分支,包括测试分支 Release,线上紧急修复分支 Hotfix,以及功能开发分支 F ...
- sql 跨表修改的方式
update xhj_mon_job_log a set person_id = (select id from xhj_mon_job_manage b where a.task_id = b.id ...
- 3dmax坐标系与导出fbx的坐标系
3dmax和opengl都是右手坐标系,但是3dmax是z轴向上,而opengl中是Y轴向上.如图: 所以在3dmax的fbx导出对话框中有“轴转化”一项,可以设置“Y向上”或者“Z向上”. 默认是“ ...
- java线程高并发编程
java线程具体解释及高并发编程庖丁解牛 线程概述: 祖宗: 说起java高并发编程,就不得不提起一位老先生Doug Lea,这位老先生可不得了.看看百度百科对他的评价,一点也不为过: 假设IT的历史 ...
- js实现页面时间动态变化
利用函数嵌套和setTimeout函数实现时间动态变化 var myDate = new Date(); myDate.getYear(); //获取当前年份(2位) myDate.getFullYe ...
- [na]那些OVER的封装(pppoe/ppp/ipsec)
什么over什么,如pppoe, ppp的封装都在over对象之后,入下图: PPPOE Ipsec