barcode

R 배워보기-8.2. Miscellaneous

Coding/R

이거는 솔직히 8.1에 비하면 분량은 짧아요... 

근데 ggplot은 불러야됨 


그래프를 저⭐장 

그래프 두갠가 그리긴 했음... 제주도 야채 서브셋으로... 

 

> pdf("plots.pdf")
> plot(plot)
50건 이상의 경고들을 발견되었습니다 (이들 중 처음 50건을 확인하기 위해서는 warnings()를 이용하시길 바랍니다).
> dev.off()

pdf("파일명.pdf")만 쓰면 빈 pdf파일이 나오고 밑에 저장할 그래프를 하나씩 쓰면 페이지당 하나씩 저장된다. 

 

> pdf("plots.pdf")
> plot(plot)
50건 이상의 경고들을 발견되었습니다 (이들 중 처음 50건을 확인하기 위해서는 warnings()를 이용하시길 바랍니다).
> plot(plot2)
50건 이상의 경고들을 발견되었습니다 (이들 중 처음 50건을 확인하기 위해서는 warnings()를 이용하시길 바랍니다).
> dev.off()
X11cairo 
       2

그게 무슨말이냐면 여러개도 된다는 소리지. 

 

# 6x3 inches
pdf("plots.pdf", width=6, height=3)

# 10x6 cm
pdf("plots.pdf", width=10/2.54, height=6/2.54)

아니 새기들아 미터법 안쓰냐고 

 

> svg("plot.svg")
> plot(plot)
> dev.off()
X11cairo 
       2

svg는 이거 

 

> png("plot.png")
> plot(plot)
> dev.off()
X11cairo 
       2

png는 이거

 

> png("plot.tiff")
> plot(plot2)
> dev.off()
X11cairo 
       2

tiff는 이거다. 

 

png("plot.png", width=480, height=240, res=120)
plot(...)
dev.off()

얘는 픽셀로 받는갑다. 

 

점과 선 모양

이렇다고 합니다. 

 

글꼴

(진짜 짤 제조기 만드신 분 복받으세요)

글꼴 바꿀 수 있더라... 

 

> plot2=ggplot(data=data_carrot,aes(x=연산,y=조수입.백만원.,fill=연산))+geom_bar(stat="identity")+geom_text(y=70000,label="Carrot",family="Courier")

대충 이런 식으로 바꿉니다. Courier는 courier new같은데 저 폰트 시퀀스 파일 저장할 때 많이 써먹음. 고정폭이라 일정 bp가 한 줄을 차지해서 좋습니다. 아무튼... 

 

> plot2=ggplot(data=data_carrot,aes(x=연산,y=조수입.백만원.,fill=연산))+geom_bar(stat="identity")+geom_text(y=70000,label="Carrot",family="나눔손글씨 바른히피")
> plot2

근데 이건 왜 되는거임? 

 

> plot2=ggplot(data=data_carrot,aes(x=연산,y=조수입.백만원.,fill=연산))+geom_bar(stat="identity")+geom_text(y=70000,label="Carrot",family="나눔손글씨 바른히피")+ggtitle("제주도 당근 현황")+theme(plot.title=element_text(family="나눔손글씨 바른히피",face="bold",size=18))

아니 왜 돼요? 

 

> plot=ggplot(data=data_cabbage,aes(x=연산,y=조수입.백만원.,fill=연산))+geom_bar(stat="identity")+geom_text(x=2,y=110000,label="Cabbage",family="나눔손글씨 바른히피")+ggtitle("제주도 당근 현황")+theme(plot.title=element_text(family="나눔손글씨 바른히피",face="bold",size=18))+theme(axis.title.x=element_text(family="나눔손글씨 바른히피"))+theme(axis.title.y=element_text(family="나눔손글씨 바른히피"))

궁서체로 왜 됨??? 

 

ggplot(data=data_cabbage,aes(x=연산,y=조수입.백만원.,fill=연산))+geom_bar(stat="identity")+geom_text(x=2,y=110000,label="Cabbage",family="나눔손글씨 바른히피")+ggtitle("제주도 당근 현황")+theme(plot.title=element_text(family="나눔손글씨 바른히피",face="bold",size=18))+theme(axis.title.x=element_text(family="나눔손글씨 바른히피"))+theme(axis.title.y=element_text(family="나눔손글씨 바른히피"))+theme(legend.title=element_text(family="나눔손글씨 바른히피"))+theme(legend.text=element_text(family="나눔손글씨 바른히피"))+theme(axis.text.x=element_text(family="나눔손글씨 바른히피"))+theme(axis.text.y=element_text(family="나눔손글씨 바른히피"))

아니 진짜 이렇게 된다고?????? 아니 실화냐고