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

Thanos Receiver

ImportError: cannot import name ‘Digraph‘ from ‘graphviz‘

ESP32存储配网信息+LED显示配网状态+按键清除配网信息(附源码)

Map set assignment to database

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

Skills of PLC recorder in quickly monitoring multiple PLC bits

Jinshanyun - 2023 Summer Internship

Webauthn - official development document

RPA进阶(二)Uipath应用实践

Multi line display and single line display of tqdm
随机推荐
数字化转型挂帅复产复工,线上线下全融合重建商业逻辑
A sharp tool for exposing data inconsistencies -- a real-time verification system
LVM operation
Array splitting (regular thinking
Tick Data and Resampling
enumrate的start属性的坑
Internship report skywalking distributed link tracking?
电脑无缘无故黑屏,无法调节亮度。
Some things configured from ros1 to ros2
[idea] use the plug-in to reverse generate code with one click
bedtools使用教程
Is it safe to open a stock account online? I'm a novice, please guide me
Liftover for genome coordinate conversion
TIPC Service and Topology Tracking4
念念不忘,必有回响 | 悬镜诚邀您参与OpenSCA用户有奖调研
From the perspective of attack surface, see the practice of zero trust scheme of Xinchuang
tqdm的多行显示与单行显示
JS -- take a number randomly from the array every call, and it cannot be the same as the last time
基于Hardhat和Openzeppelin开发可升级合约(一)
Mongodb learning and sorting (condition operator, $type operator, limit() method, skip() method and sort() method)
