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的部署.客户端的调 ...
随机推荐
- Python练习笔记——采用生成器函数实现两数之间的偶数计算
题目:编写一个生成器函数myeven(start, end),采用迭代器逐次实现[start, end)范围内的偶数计算2 4 6 8. ... def myeven(start, end): whi ...
- 文件描述符file descriptor与inode的相关知识
每个进程在Linux内核中都有一个task_struct结构体来维护进程相关的 信息,称为进程描述符(Process Descriptor),而在操作系统理论中称为进程控制块 (PCB,Process ...
- 图解IIS配置过程
环境介绍: 操作系统:win7,64位.IIS7 开发软件:VS2010,32位 图解IIS配置过程: 此过程之前确保已安装了IIS. 1.在"控制面板"中找到"管理工具 ...
- .Net程序猿玩转Android开发---(11)页面跳转
在不论什么程序开发中,都会遇到页面之间跳转的情况,Android开发也不例外.这一节,我们来认识下Android项目中如何进行页面跳转.页面跳转分为有參数和无參数页面跳转,已经接受还有一个页面的返回值 ...
- C# 获取方法内参数名称
public partial class Main : Form { public Main() { foreach(var parameter in typeof(Main).GetMethod(& ...
- 修改 Input placeholder 的样式
::-webkit-input-placeholder { /* WebKit browsers */ color: #ccc; } :-moz-placeholder { /* Mozilla Fi ...
- activiti 开发环境
1 javadocs 的11 个package org.activiti.engine,包含7个Service接口.异常定义.流程引擎.流程引擎配置和一些运行时异常类. org.activiti.en ...
- JDK1.5新特性,基础类库篇,格式化类(Formatter)用法
Formatter类提供了对布局对齐和排列的支持,以及对数值.字符串和日期.时间数据的常规格式和特定于语言环境的输出的支持.通用Java类型,诸如byte.BigDecimal和Calendar都被支 ...
- Bash编程的test和条件语句
1.if语句一句条件判断结果选择执行路径.最简单的if-then句型: if command //如果command的退出状态为0,执行body then body fi 重点:if认为command ...
- spark内存概述
转自:https://github.com/jacksu/utils4s/blob/master/spark-knowledge/md/spark%E5%86%85%E5%AD%98%E6%A6%82 ...