当前位置:网站首页>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")
)
边栏推荐
猜你喜欢

解决uniapp列表快速滑动页面数据空白问题

PYQT5+openCV项目实战:微循环仪图片、视频记录和人工对比软件(附源码)

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

在连接mysql数据库的时候一直报错

Mmrotate rotation target detection framework usage record

基于Hardhat和Openzeppelin开发可升级合约(一)

揭露数据不一致的利器 —— 实时核对系统

由粒子加速器产生的反中子形成的白洞

Basic usage of MySQL in centos8

Verilog 和VHDL有符号数和无符号数相关运算
随机推荐
PLC-Recorder快速监控多个PLC位的技巧
Attribute acquisition method and operation notes of C # multidimensional array
原生方法合并word
deepTools对ChIP-seq数据可视化
Thanos Receiver
MySQL linked list data storage query sorting problem
基于Hardhat编写合约测试用例
TIPC protocol
通过券商经理的开户二维码开股票账户安全吗?还是去证券公司开户安全?
excel表格中选中单元格出现十字带阴影的选中效果
基于Hardhat和Openzeppelin开发可升级合约(二)
The working day of the month is calculated from the 1st day of each month
Summary of flutter problems
VS2019代码中包含中文内容导致的编译错误和打印输出乱码问题
TIPC introduction 1
The difference between SQL left join main table restrictions written after on and where
ESP32音频框架 ESP-ADF 添加按键外设流程代码跟踪
flutter 问题总结
Redis exceeds the maximum memory error oom command not allowed when used memory & gt; ' maxmemory'
C#基于当前时间,获取唯一识别号(ID)的方法
