- [R을 이용한 2D Contour 이미지]2024년 05월 11일 21시 54분 47초에 업로드 된 글입니다.작성자: r-code-for-data-analysis
참고
https://www.rdocumentation.org/packages/graphics/versions/3.6.2/topics/filled.contour
filled.contour function - RDocumentation
locations of grid lines at which the values in z are measured. These must be in ascending order. (The rest of this description does not apply to .filled.contour.) By default, equally spaced values from 0 to 1 are used. If x is a list, its components x$x an
www.rdocumentation.org
x,y,z 로 이루어진 데이터를 이용하여 x축, y축 위에 높이, 색깔을 나타내는 matrix 형태의 데이터가 있을 때,
x,y 평면 위에 color를 gradual image로 그려주는 함수 : filled.contour 가 유용하다.
micro lens를 통과한 빛의 intensity를 측정한 데이터가 다음과 같다.
패키지 불러오기 및 데이터 로드
library(tidyverse) require(akima) require(rgl) df <- read_csv("./data/z_6.304.csv", col_types = cols(.default = "n"), skip=1,col_names = F)
2d 이미지로 그리기
filled.contour(x=c(1:nrow(df)), y=c(1:ncol(df)), z=as.matrix(df), color.palette=colorRampPalette(c("blue","yellow","red")), plot.title=title(main="mm" , sub= "" , xlab="", ylab=""), nlevels=50, plot.axes = { axis(side = 2, at = tdn, labels = "", col.lab="white") axis(side = 1, at = rdn, labels = rdn, col.lab="white") }, key.title=title(main="T(%)"), key.axes = axis(4, seq(0, 8, by = 0.1)))
x축과 y축을 바꾸어보자
filled.contour(x=c(1:ncol(df)), y=c(1:nrow(df)), z=as.matrix(t(df)), color.palette=colorRampPalette(c("blue","yellow","red")), plot.title=title(main="2D Contour Image" , sub= "" , xlab="", ylab=""), nlevels=50, plot.axes = { axis(side = 2, at = c(1:nrow(df)), labels = c(1:nrow(df)), col.lab="white") axis(side = 1, at = c(1:ncol(df)), labels = c(1:ncol(df)), col.lab="white") }, key.title=title(main="T(%)"), key.axes = axis(4, seq(0, 8, by = 0.1)))
728x90반응형'데이터 시각화' 카테고리의 다른 글
[R을 이용하여 COLOR 색좌표] (0) 2024.05.16 [R을 이용한 3D contour 쌓기] Plotly (0) 2024.05.11 R을 이용한 달력 만들기 (calendR) (0) 2024.03.30 R을 이용한 일정표, 스케줄 테이블 만들기 [vistime] (0) 2024.03.30 R을 이용한 논문용 그래프 (흑백용 패턴 색칠) (1) 2024.01.21 댓글