当前位置:网站首页>R HISTOGRAM EXAMPLE QUICK REFERENCE
R HISTOGRAM EXAMPLE QUICK REFERENCE
2022-07-02 09:38:00 【小宇2022】
library(tidyverse)
theme_set(
theme_bw() +
theme(legend.position = "top")
)
head(iris, 3)
iris.gathered <- iris %>%
as_data_frame() %>%
gather(key = "variable", value = "value",
-Sepal.Length, -Species)
head(iris.gathered, 3)
ggplot(iris.gathered, aes(x = value, y = Sepal.Length)) +
geom_point(aes(color = Species)) +
facet_wrap(~variable)+
scale_color_viridis_d()

set.seed(1234)
wdata = data.frame(
sex = factor(rep(c("F", "M"), each=200)),
weight = c(rnorm(200, 55), rnorm(200, 58))
)
head(wdata, 4)
hist(wdata$weight, breaks = 30, col = "steelblue", frame = FALSE)

library(ggplot2)
theme_set(theme_bw())
# Basic plot
ggplot(wdata, aes(x = weight)) +
geom_histogram(bins = 30)
# Change fill color by sex group
ggplot(wdata, aes(x = weight)) +
geom_histogram(aes(fill = sex), bins = 30, alpha = 0.5,
position = position_dodge()) +
scale_fill_viridis_d()

library(ggpubr)
# Basic plots
gghistogram(wdata, x = "weight", fill = "steelblue", alpha = 1)
# Change color by sex group
gghistogram(
wdata, x = "weight", color = "sex",
palette = c("#00AFBB", "#E7B800")
)
边栏推荐
- C#多维数组的属性获取方法及操作注意
- Compilation errors and printout garbled problems caused by Chinese content in vs2019 code
- 6方面带你认识LED软膜屏 LED软膜屏尺寸|价格|安装|应用
- Approximate sum count (approximate
- 从攻击面视角,看信创零信任方案实践
- 基于Hardhat和Openzeppelin开发可升级合约(二)
- Mmrotate rotation target detection framework usage record
- CTF record
- Solve the problem of data blank in the quick sliding page of the uniapp list
- Tdsql | difficult employment? Tencent cloud database micro authentication to help you
猜你喜欢

Redis超出最大内存错误OOM command not allowed when used memory &gt; 'maxmemory'

Internship report skywalking distributed link tracking?
![[idea] use the plug-in to reverse generate code with one click](/img/b0/00375e61af764a77ea0150bf4f6d9d.png)
[idea] use the plug-in to reverse generate code with one click

I STM32 development environment, keil5/mdk5.14 installation tutorial (with download link)

From the perspective of attack surface, see the practice of zero trust scheme of Xinchuang

VS2019代码中包含中文内容导致的编译错误和打印输出乱码问题

CentOS8之mysql基本用法

vant tabs组件选中第一个下划线位置异常

Jinshanyun - 2023 Summer Internship

Attribute acquisition method and operation notes of C # multidimensional array
随机推荐
A white hole formed by antineutrons produced by particle accelerators
TIPC Getting Started6
ESP32存储配网信息+LED显示配网状态+按键清除配网信息(附源码)
tqdm的多行显示与单行显示
高德根据轨迹画线
Approximate sum count (approximate
Redis超出最大内存错误OOM command not allowed when used memory &gt; 'maxmemory'
On April 17, 2022, the five heart matchmaker team received double good news
Tidb DM alarm DM_ sync_ process_ exists_ with_ Error troubleshooting
js中给数组添加元素的方法有哪些
八大排序汇总
enumrate的start属性的坑
2022年遭“挤爆”的三款透明LED显示屏
TIPC messaging3
Tick Data and Resampling
Digital transformation takes the lead to resume production and work, and online and offline full integration rebuilds business logic
念念不忘,必有回响 | 悬镜诚邀您参与OpenSCA用户有奖调研
对毕业季即将踏入职场的年轻人的一点建议
Tick Data and Resampling
通过券商经理的开户二维码开股票账户安全吗?还是去证券公司开户安全?
