programing

플롯 축 값 제거

muds 2023. 6. 15. 22:09
반응형

플롯 축 값 제거

r-plot 그래프에서 각각 x축 또는 y축의 축 값을 제거할 수 있는 방법이 있는지 궁금합니다.

나는 그것을 알고 있습니다.axes = false축 전체를 제거할 것입니다. 하지만 번호만 제거하고 싶습니다.

x축 또는 y축에서 번호 지정 제거:

plot(1:10, xaxt='n')
plot(1:10, yaxt='n')

레이블도 제거하려는 경우:

plot(1:10, xaxt='n', ann=FALSE)
plot(1:10, yaxt='n', ann=FALSE)

기본 그래픽을 사용하는 표준 방법은 축=을 사용하는 것입니다.FALSE를 선택한 다음 축(또는 축)을 사용하여 자체 축을 만듭니다.예를들면,

x <- 1:20
y <- runif(20)
plot(x, y, axes=FALSE, frame.plot=TRUE)
Axis(side=1, labels=FALSE)
Axis(side=2, labels=FALSE)

격자 등가물은

library(lattice)
xyplot(y ~ x, scales=list(alternating=0))

@Richie Cotton은 위에서 꽤 좋은 답변을 했습니다.페이지는 몇 가지 예시를 제공한다는 것만 덧붙일 수 있습니다.다음을 시도합니다.

x <- 1:20
y <- runif(20)
plot(x,y,xaxt = "n")
axis(side = 1, at = x, labels = FALSE, tck = -0.01)

그림 내부에 레이블을 넣을 수도 있습니다.

plot(spline(sub$day, sub$counts), type ='l', labels = FALSE)

경고를 받게 될 것입니다.라벨은 실제로 플롯이 실행되는 서브루틴으로 전달되는 매개변수이기 때문이라고 생각합니다(계속?).경고가 플롯 함수의 직접적인 매개 변수가 아니었기 때문에 팝업됩니다.

배경과 일치하도록 axis_color를 변경하고 배경을 동적으로 수정할 경우 axis_color를 동시에 업데이트해야 합니다.공유된 그림에는 모의 데이터()를 사용한 그래프/플롯 예제가 표시됩니다.

### Main Plotting Function ###
plotXY <- function(time, value){

    ### Plot Style Settings ###

    ### default bg is white, set it the same as the axis-colour 
    background <- "white"

    ### default col.axis is black, set it the same as the background to match
    axis_colour <- "white"

    plot_title <- "Graph it!"
    xlabel <- "Time"
    ylabel <- "Value"
    label_colour <- "black"
    label_scale <- 2
    axis_scale <- 2
    symbol_scale <- 2
    title_scale <- 2
    subtitle_scale <- 2
    # point style 16 is a black dot
    point <- 16 
    # p - points, l - line, b - both
    plot_type <- "b"

    plot(time, value, main=plot_title, cex=symbol_scale, cex.lab=label_scale, cex.axis=axis_scale, cex.main=title_scale, cex.sub=subtitle_scale, xlab=xlabel, ylab=ylabel, col.lab=label_colour, col.axis=axis_colour, bg=background, pch=point, type=plot_type)
}

plotXY(time, value)

enter image description here

언급URL : https://stackoverflow.com/questions/1154242/remove-plot-axis-values

반응형