当前位置:网站首页>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")
)
边栏推荐
- 可升级合约的原理-DelegateCall
- ImportError: cannot import name ‘Digraph‘ from ‘graphviz‘
- TIPC messaging3
- 可昇級合約的原理-DelegateCall
- Is bond fund safe? Does the bond buying foundation lose principal?
- Some things configured from ros1 to ros2
- Solve the problem of data blank in the quick sliding page of the uniapp list
- mysql链表数据存储查询排序问题
- 揭露数据不一致的利器 —— 实时核对系统
- The difference between SQL left join main table restrictions written after on and where
猜你喜欢
Basic usage of MySQL in centos8
ctf 记录
tidb-dm报警DM_sync_process_exists_with_error排查
Importerror: impossible d'importer le nom « graph» de « graphviz»
Multi line display and single line display of tqdm
mysql链表数据存储查询排序问题
Eight sorting summaries
制造业数字化转型和精益生产什么关系
6方面带你认识LED软膜屏 LED软膜屏尺寸|价格|安装|应用
念念不忘,必有回响 | 悬镜诚邀您参与OpenSCA用户有奖调研
随机推荐
Programmer growth Chapter 6: how to choose a company?
Homer forecast motif
念念不忘,必有回响 | 悬镜诚邀您参与OpenSCA用户有奖调研
js中给数组添加元素的方法有哪些
Wechat applet uses Baidu API to achieve plant recognition
VS2019代码中包含中文内容导致的编译错误和打印输出乱码问题
C#基于当前时间,获取唯一识别号(ID)的方法
Mongodb learning and sorting (condition operator, $type operator, limit() method, skip() method and sort() method)
基于Hardhat和Openzeppelin开发可升级合约(二)
MySQL linked list data storage query sorting problem
【IDEA】使用插件一键逆向生成代码
数字化转型挂帅复产复工,线上线下全融合重建商业逻辑
Introduction to interface debugging tools
II Stm32f407 chip GPIO programming, register operation, library function operation and bit segment operation
map集合赋值到数据库
QT获取某个日期是第几周
ImportError: cannot import name ‘Digraph‘ from ‘graphviz‘
Some things configured from ros1 to ros2
C# 文件与文件夹操作
从攻击面视角,看信创零信任方案实践