当前位置:网站首页>GGPLOT: HOW TO DISPLAY THE LAST VALUE OF EACH LINE AS LABEL
GGPLOT: HOW TO DISPLAY THE LAST VALUE OF EACH LINE AS LABEL
2022-07-02 11:49:00 【Xiaoyu 2022】
# Load required R packages
library(tidyverse)
library(ggrepel)
# Set ggplot2 default theme to theme_bw()
theme_set(theme_bw())
# Demo data
df <- tibble::tribble(
~Species, ~Petal.Length, ~Petal.Width, ~Sepal.Length, ~Sepal.Width,
"setosa", 1.462, 0.246, 5.006, 3.428,
"versicolor", 4.26, 1.326, 5.936, 2.77,
"virginica", 5.552, 2.026, 6.588, 2.974
)
df_long <- df %>%
pivot_longer(
Petal.Length:Sepal.Width,
names_to = "variable", values_to = "value"
)
# Basic line plot
lp <- ggplot(df_long, aes(x = Species, y = value, group = variable)) +
geom_line(aes(color = variable)) +
geom_point() +
theme(legend.position = "top")
# Filter the last values and add onto the line plot
# Corresponds to the `virginica` species
data_ends <- df_long %>% filter(Species == "virginica")
lp +
geom_text_repel(
aes(label = value), data = data_ends,
fontface ="plain", color = "black", size = 3
)

边栏推荐
- Develop scalable contracts based on hardhat and openzeppelin (II)
- pgsql 字符串转数组关联其他表,匹配 拼接后原顺序展示
- Seriation in R: How to Optimally Order Objects in a Data Matrice
- GGHIGHLIGHT: EASY WAY TO HIGHLIGHT A GGPLOT IN R
- Resources reads 2D texture and converts it to PNG format
- The position of the first underline selected by the vant tabs component is abnormal
- Some things configured from ros1 to ros2
- C#多维数组的属性获取方法及操作注意
- On April 17, 2022, the five heart matchmaker team received double good news
- 在连接mysql数据库的时候一直报错
猜你喜欢

HOW TO ADD P-VALUES TO GGPLOT FACETS
![[idea] use the plug-in to reverse generate code with one click](/img/b0/00375e61af764a77ea0150bf4f6d9d.png)
[idea] use the plug-in to reverse generate code with one click

Dynamic memory (advanced 4)
![[cloud native] 2.5 kubernetes core practice (Part 2)](/img/87/826894d758392a0c7a60dd5fa09eef.png)
[cloud native] 2.5 kubernetes core practice (Part 2)

亚马逊云科技 Community Builder 申请窗口开启

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

【2022 ACTF-wp】

HOW TO ADD P-VALUES ONTO A GROUPED GGPLOT USING THE GGPUBR R PACKAGE

可昇級合約的原理-DelegateCall

PgSQL string is converted to array and associated with other tables, which are displayed in the original order after matching and splicing
随机推荐
Principle of scalable contract delegatecall
Implementation of address book (file version)
PHP query distance according to longitude and latitude
HOW TO ADD P-VALUES ONTO A GROUPED GGPLOT USING THE GGPUBR R PACKAGE
揭露数据不一致的利器 —— 实时核对系统
Map set assignment to database
Basic usage of MySQL in centos8
行业的分析
GGPLOT: HOW TO DISPLAY THE LAST VALUE OF EACH LINE AS LABEL
Resources reads 2D texture and converts it to PNG format
Flesh-dect (media 2021) -- a viewpoint of material decomposition
HOW TO CREATE A BEAUTIFUL INTERACTIVE HEATMAP IN R
SSRF
Order by injection
to_ Bytes and from_ Bytes simple example
qt 仪表自定义控件
Native method merge word
C # method of obtaining a unique identification number (ID) based on the current time
Some suggestions for young people who are about to enter the workplace in the graduation season
由粒子加速器产生的反中子形成的白洞