R绘制基本柱状图(不同颜色)

该博客展示了使用R语言`ggplot2`包绘制`faithful`数据集中的`waiting`变量的直方图。通过改变填充颜色和设置不同数量的柱状间隔,创建了一系列美观的直方图,用于展示等待时间的分布情况。每个图都用白色边框和不同色调的填充色,其中部分图设置了特定的柱状数量。
library(gcookbook) # For the data set
library(tidyverse)

ggplot(faithful, aes(x=waiting)) + geom_histogram(colour='black',fill='lightblue')

在这里插入图片描述

ggplot(faithful, aes(x=waiting)) + geom_histogram(colour='white',fill='lightcoral')

在这里插入图片描述

ggplot(faithful, aes(x=waiting)) + geom_histogram(colour='black',fill='lightcyan')

在这里插入图片描述

ggplot(faithful, aes(x=waiting)) + geom_histogram(colour='black',fill='lightgoldenrodyellow')

在这里插入图片描述

ggplot(faithful, aes(x=waiting)) + geom_histogram(colour='white',fill='lightgreen')

在这里插入图片描述

ggplot(faithful, aes(x=waiting)) + geom_histogram(colour='black',fill='lightgray',bins=40)

在这里插入图片描述

ggplot(faithful, aes(x=waiting)) + geom_histogram(colour='white',fill='red',bins=40)

在这里插入图片描述

ggplot(faithful, aes(x=waiting)) + geom_histogram(colour='white',fill='lightpink',bins=30)

在这里插入图片描述

ggplot(faithful, aes(x=waiting)) + geom_histogram(colour='white',fill='lightsalmon',bins=30)

在这里插入图片描述

ggplot(faithful, aes(x=waiting)) + geom_histogram(colour='white',fill='lightseagreen',bins=30)

在这里插入图片描述

ggplot(faithful, aes(x=waiting)) + geom_histogram(colour='white',fill='lightskyblue',bins=30)

在这里插入图片描述

ggplot(faithful, aes(x=waiting)) + geom_histogram(colour='white',fill='lightslategray',bins=30)

在这里插入图片描述

ggplot(faithful, aes(x=waiting)) + geom_histogram(colour='white',fill='slateblue',bins=30)

在这里插入图片描述

ggplot(faithful, aes(x=waiting)) + geom_histogram(colour='white',fill='sienna',bins=30)

在这里插入图片描述

ggplot(faithful, aes(x=waiting)) + geom_histogram(colour='white',fill='skyblue',bins=30)

在这里插入图片描述

ggplot(faithful, aes(x=waiting)) + geom_histogram(colour='white',fill='slateblue',bins=30)

在这里插入图片描述

ggplot(faithful, aes(x=waiting)) + geom_histogram(colour='white',fill='slategray',bins=30)

在这里插入图片描述

ggplot(faithful, aes(x=waiting)) + geom_histogram(colour='black',fill='snow',bins=30)

在这里插入图片描述

ggplot(faithful, aes(x=waiting)) + geom_histogram(colour='black',fill='springgreen',bins=30)

在这里插入图片描述

ggplot(faithful, aes(x=waiting)) + geom_histogram(colour='white',fill='steelblue',bins=30)

在这里插入图片描述

ggplot(faithful, aes(x=waiting)) + geom_histogram(colour='white',fill='tan',bins=30)

在这里插入图片描述

ggplot(faithful, aes(x=waiting)) + geom_histogram(colour='white',fill='thistle',bins=30)

在这里插入图片描述

ggplot(faithful, aes(x=waiting)) + geom_histogram(colour='white',fill='tomato',bins=30)

在这里插入图片描述

ggplot(faithful, aes(x=waiting)) + geom_histogram(colour='white',fill='turquoise',bins=30)

在这里插入图片描述

ggplot(faithful, aes(x=waiting)) + geom_histogram(colour='white',fill='blue',bins=30)

在这里插入图片描述

ggplot(faithful, aes(x=waiting)) + geom_histogram(colour='black',fill='wheat',bins=30)

在这里插入图片描述

ggplot(faithful, aes(x=waiting)) + geom_histogram(colour='black',fill='white',bins=30)

在这里插入图片描述

ggplot(faithful, aes(x=waiting)) + geom_histogram(colour='black',fill='whitesmoke',bins=30)

在这里插入图片描述

ggplot(faithful, aes(x=waiting)) + geom_histogram(colour='black',fill='yellow',bins=30)

在这里插入图片描述

ggplot(faithful, aes(x=waiting)) + geom_histogram(colour='white',fill='yellowgreen',bins=30)

在这里插入图片描述
参考文献:Practical Receipes for Visualizing Data----R Graphics Cookbook —Winston Chang O’REILLY

百度文库—颜色大全:含中英文对照及色值

开发环境:RStudio和微信截屏工具

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值