当前位置:网站首页>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")
)
边栏推荐
- Develop scalable contracts based on hardhat and openzeppelin (II)
- Order by injection
- PYQT5+openCV项目实战:微循环仪图片、视频记录和人工对比软件(附源码)
- C#多维数组的属性获取方法及操作注意
- PKG package manager usage instance in FreeBSD
- [cloud native] 2.5 kubernetes core practice (Part 2)
- Jenkins installation
- js中给数组添加元素的方法有哪些
- spritejs
- ImportError: cannot import name ‘Digraph‘ from ‘graphviz‘
猜你喜欢

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

Pit of the start attribute of enumrate

Amazon cloud technology community builder application window opens

从攻击面视角,看信创零信任方案实践

Is the Ren domain name valuable? Is it worth investing? What is the application scope of Ren domain name?

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

mmrotate旋转目标检测框架使用记录

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

TIPC Service and Topology Tracking4

TIPC messaging3
随机推荐
RPA advanced (II) uipath application practice
MySQL比较运算符IN问题求解
JS——每次调用从数组里面随机取一个数,且不能与上一次为同一个
Resources reads 2D texture and converts it to PNG format
Programmer growth Chapter 6: how to choose a company?
Summary of data export methods in powerbi
TIPC Cluster5
Functional interfaces and method references
2022年4月17日五心红娘团队收获双份喜报
Some things configured from ros1 to ros2
原生方法合并word
数字化转型挂帅复产复工,线上线下全融合重建商业逻辑
Supermarket (heap overload
Writing contract test cases based on hardhat
Introduction to interface debugging tools
Verilog 和VHDL有符号数和无符号数相关运算
TIPC Service and Topology Tracking4
II Stm32f407 chip GPIO programming, register operation, library function operation and bit segment operation
Jinshanyun - 2023 Summer Internship
在网上开股票账户安全吗?我是新手,还请指导
