본문 바로가기
유용한 정보

ggplot2 보다 훨씬 쉽고 간편한 visualization library

by systrader79 2021. 6. 9.
728x90
반응형
728x170

개인적으로는 순수하게 데이터 분석에 국한해 볼 때, 코딩의 일관성과 용이성 면에 있어서는 파이썬보다 R이, pandas나 matplotlib보다는 dplyr이나 ggplot2 가 훨씬 효율적이고 쉽다고 생각합니다. 

 

그런데, ggplot도 쓰다보면 아주 단순한 plot을 뽑아낼 때, '생각보다(?)는' 귀찮을 때가 많고, 지정해야 하는 인자들이 많아서 번거로울 때가 있는데, 이런 번거로움을 한 큐에 해결할 수 있는 라이브러리가 나왔네요. 

 

ggplot2의 wrapper인 simplevis인데, 간단한 plot는 명령어 한 줄로 해결이 가능합니다. 

Visualization 코드도 gg_bar(데이터 프레임, x축 인자, y축 인자) 와 같이 '극도로(?) 직관적' 이어서 아이큐가 아메바 수준이라도 쉽게 코드를 짤 수 있습니다. 

 

p.s) 아이큐가 두 자리 이상인 분들에게는 사용을 권하지 않습니다. 

 

원문 링크 : https://www.r-bloggers.com/2021/06/simplevis-simple-ggplot2-visualisation-with-less-brainpower-and-typing/

 

 

simplevis – simple ggplot2 visualisation with less brainpower and typing

ShareTweet

Introduction

simplevis

 is a package of 

ggplot2

 wrapper functions that aims to make beautiful 

ggplot2

 visualisation with less brainpower and typing!

This blog will provide an overview of:

  • the visualisation family types that simplevis currently supports
  • how visualisation families support combinations of colouring (by a variable), facetting. both or neither.

library(simplevis)

library(dplyr)

library(palmerpenguins)

Visualisation family types

bar

plot_data <- storms %>%

group_by(year) %>%

summarise(wind = mean(wind))

 

gg_bar(plot_data, year, wind)

point

gg_point(iris, Sepal.Width, Sepal.Length)

line

plot_data <- storms %>%

group_by(year) %>%

summarise(wind = mean(wind))

 

gg_line(plot_data, year, wind)

boxplot

gg_boxplot(storms, year, wind)

hbar (i.e horizontal bar)

plot_data <- ggplot2::diamonds %>%

group_by(cut) %>%

summarise(price = mean(price))

 

gg_hbar(plot_data, price, cut)

sf (short for simple features map)

gg_sf(example_sf_point, borders = nz)

Colouring, facetting, neither or both

Each visualisation family generally has 4 functions.

The function name specifies whether or not a visualisation is to be coloured by a variable 

*_col()

, facetted by a variable 

*_facet()

, neither 

*()

 or both of these 

*_col_facet()

.

Colouring by a variable means that different values of a selected variable are to have different colours. Facetting means that different values of a selected variable are to have their facet.

A 

*()

 function such 

gg_point()

 requires only a dataset, an x variable and a y variable.

gg_point(penguins, bill_length_mm, body_mass_g)

A 

*_col()

 function such 

gg_point_col()

 requires only a dataset, an x variable, a y variable, and a colour variable.

gg_point_col(penguins, bill_length_mm, body_mass_g, sex)

A 

*_facet()

 function such 

gg_point_facet()

 requires only a dataset, an x variable, a y variable, and a facet variable.

gg_point_facet(penguins, bill_length_mm, body_mass_g, species)

A 

*_col_facet()

 function such 

gg_point_col_facet()

 requires only a dataset, an x variable, a y variable, a colour variable, and a facet variable.

gg_point_col_facet(penguins, bill_length_mm, body_mass_g, sex, species)

Data is generally plotted with a stat of 

identity

, which means data is plotted as is. Only for boxplot, there is a different default stat of boxplot, which means data will be transformed to boxplot statistics.

Further information

More blogs to come on 

simplevis

 methods for adjusting colours, titles and scales, filtering out NA values, and working with 

ggplotly

 and 

leaflet

. In the meantime, see the vignette and articles on the simplevis website.

 

 

1. 네이버 카페 '실전주식투자연구소' 로 오시면, 본 블로그의 모든 내용을 카테고리별로 정렬하여 순서대로 확인하실 수 있고, 다양한 실전 투자 정보도 얻을 수 있습니다~

2. 자타가 공인하는 주식 단기 시스템 트레이딩의 최고 전략가, '닥터 퀀트의 단기 트레이딩 강좌'가 뉴지스탁에서 진행중입니다. 닥터 퀀트의 강좌에서는 그동안 공개하지 않았던 무려 50개 이상의 실전 트레이딩 전략과 주기적인 업데이트 강의가 제공됩니다~

3. 'systrader79의 단기 시스템 트레이딩 강의'와 '자산 배분 완전 정복 강의' 가 뉴지스탁에서 진행중입니다~     주식 단기 트레이딩과 자산 배분 전략에 관심이 있으신 분들의 많은 성원 부탁드립니다

4. 여러분의 인생이 걸린 너무나도 중요한 소식 ----> 여기를 클릭하세요!

 

728x90
반응형
그리드형

댓글