当前位置:网站首页>R HISTOGRAM EXAMPLE QUICK REFERENCE
R HISTOGRAM EXAMPLE QUICK REFERENCE
2022-07-02 11:43:00 【Xiaoyu 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")
)
边栏推荐
猜你喜欢

webauthn——官方开发文档

What is the relationship between digital transformation of manufacturing industry and lean production

Always report errors when connecting to MySQL database

enumrate的start属性的坑

Win11 arm system configuration Net core environment variable

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

Mongodb learning and sorting (condition operator, $type operator, limit() method, skip() method and sort() method)

制造业数字化转型和精益生产什么关系

II Stm32f407 chip GPIO programming, register operation, library function operation and bit segment operation

CentOS8之mysql基本用法
随机推荐
Digital transformation takes the lead to resume production and work, and online and offline full integration rebuilds business logic
PowerBI中导出数据方法汇总
MTK full dump抓取
ImportError: cannot import name ‘Digraph‘ from ‘graphviz‘
Array splitting (regular thinking
Principle of scalable contract delegatecall
mmrotate旋转目标检测框架使用记录
C file and folder operation
从攻击面视角,看信创零信任方案实践
通过券商经理的开户二维码开股票账户安全吗?还是去证券公司开户安全?
Order by注入
SQLite modify column type
JS——每次调用从数组里面随机取一个数,且不能与上一次为同一个
mysql 基本语句
excel表格中选中单元格出现十字带阴影的选中效果
Writing contract test cases based on hardhat
ROS lacks catkin_ pkg
基于 Openzeppelin 的可升级合约解决方案的注意事项
MySQL comparison operator in problem solving
SSRF
