2017-05-04 2 views
0

x와 y 스케일을 가진 레벨 플롯을 log10 틱으로 그려야합니다.R : 로그 틱 스케일을 사용한 레벨 플롯 그리기

예를 들어, 나는 이와 같이 정상적인 음모가 있습니다.

enter image description here

x <- 10*1:nrow(volcano) 
y <- 10*1:ncol(volcano) 
filled.contour(x, y, volcano, color = terrain.colors, plot.title = title(main = "Volcano topolgy", xlab = "Meters North", ylab = "Meters West"), plot.axes = { axis(1, seq(100, 800, by = 100)); axis(2, seq(100, 600, by = 100)) }, key.title = title(main = "Height\n(meters)"), key.axes = axis(4, seq(90, 190, by = 10))) 
그러나, x와 y 저울 눈금 저울을 기록하지 않습니다. 로그 틱 스케일 기능을 가진 다른 라이브러리 "latticeExtra"를 찾았습니다. 예를 들어 위와 같은 x와 y를 사용하면 로그 틱을 그릴 수 있지만 윤곽 데이터를 채울 수는 없습니다.

library(lattice) 
library(latticeExtra) 
xyplot(y ~ x, scales = list(x = list(log = 10), y = list(log = 10)), xscale.components = xscale.components.log10ticks, yscale.components = yscale.components.log10ticks) 

enter image description here

어떻게 로그 눈금 스케일과 수준의 플롯을 그릴 수 있습니까? 나중에 로그 위치로 레벨 계획에 산란을 음모하고 싶습니다.

미리 감사드립니다.

답변

1

여기 latticelatticeExtra

library(lattice) 
library(latticeExtra) 

xx <- 1:nrow(volcano) 
yy <- 1:ncol(volcano) 

levelplot(
    x = volcano, 
    xlim = range(xx), 
    ylim = range(yy), 
    scales = list(x = list(log = 10), y = list(log = 10)), 
    xscale.components = xscale.components.log10ticks, 
    yscale.components = yscale.components.log10ticks 
) 

enter image description here

를 사용하여 대안이다
1

당신이 직접 xy 데이터를 logtransform 및 사용자 정의 axis 문을 따라 축을 조정할 수 있습니다 filled.contour를 계속 사용하기를 원하지만 그것은 매우 우아 아니라면합니다 (base::plotlog = "xy" 매개 변수는 슬프게도 filled.contour에서 아무것도하지 않음) :

x <- log(10*1:nrow(volcano)) 
y <- log(10*1:ncol(volcano)) 
filled.contour(x, y, volcano, color = terrain.colors, 
       plot.title = title(main = "Volcano topolgy", 
            xlab = "Meters North", 
            ylab = "Meters West"), 
       plot.axes = { axis(1, at = log(seq(100, 800, by = 100)), labels = seq(100, 800, by = 100)); 
               axis(2, at = log(seq(100, 600, by = 100)), labels = seq(100, 600, by = 100)) }, 
       key.title = title(main = "Height\n(meters)"), 
       key.axes = axis(4, seq(90, 190, by = 10))) 

enter image description here 당신은 또한 scale_y_log10()scale_x_log10()ggplot2 당신을 위해 작동한다면, this question and answer를 참조 시도 할 수 있습니다.

관련 문제