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

【IDEA】使用插件一键逆向生成代码

PHP tea sales and shopping online store

Win11 arm system configuration Net core environment variable

Principle of scalable contract delegatecall

TIPC addressing 2
![[cloud native] 2.5 kubernetes core practice (Part 2)](/img/87/826894d758392a0c7a60dd5fa09eef.png)
[cloud native] 2.5 kubernetes core practice (Part 2)

CentOS8之mysql基本用法

TIPC messaging3

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

从攻击面视角,看信创零信任方案实践
随机推荐
Resources reads 2D texture and converts it to PNG format
Summary of data export methods in powerbi
函数式接口和方法引用
ROS lacks catkin_ pkg
mysql链表数据存储查询排序问题
MySQL比较运算符IN问题求解
微信小程序利用百度api达成植物识别
A white hole formed by antineutrons produced by particle accelerators
ros缺少catkin_pkg
RPA advanced (II) uipath application practice
map集合赋值到数据库
II Stm32f407 chip GPIO programming, register operation, library function operation and bit segment operation
启牛商学院给的股票账户安全吗?能开户吗?
C#基于当前时间,获取唯一识别号(ID)的方法
基于Hardhat编写合约测试用例
数字化转型挂帅复产复工,线上线下全融合重建商业逻辑
Precautions for scalable contract solution based on openzeppelin
mysql 基本语句
Order by注入
liftOver进行基因组坐标转换
