簡體   English   中英

GGPLOT-在B_W模式下在一幅圖中的兩條曲線

[英]GGPLOT - two curves in one plot in B_W mode

我有以下一段代碼,我正在編寫這些代碼來為我的論文在文章中生成黑白圖像。

require(ggplot2) 
require(extrafont)

#loadfonts(device="pdf")

#set the x-axis now 
xaxis <- seq(0,1, by=0.01)

#set the functions here 
aij <- sqrt(1 - (1-xaxis)**1.02)
bij <- 1 - (1 - xaxis)**1.50 

#plot using commands 

ggplot(,aes(xaxis)) + geom_line(aes(y=aij, colour="aij")) + 
      geom_line(aes(y=bij,colour="bij"),linetype="dashed") + 
      theme_bw() + 
      xlab("x ratio") + 
      ylab("Function values") + 
      theme(text=element_text(family="Times New Roman", face="bold", size=12))
ggsave('myGraph.pdf')

順便說一句,我觀察到以下幾點:

(1)必須刪除圖例標題(2)圖形必須為黑白(3)我需要一條曲線為連續線(aij),另一條曲線為虛線(bij)。

需要在上面的代碼中添加什么?

(1)

theme(legend.title = element_blank())

(2)

scale_colour_manual(values = rep("black", 2))

(3)

scale_linetype_manual(values = c("solid", "dashed"))

一起例如:

ggplot(transform(stack(data.frame(aij, bij)), x = xaxis), 
       aes(x = x, y = values, linetype = ind)) +
  geom_line() + 
  theme_bw() + 
  xlab("x ratio") + 
  ylab("Function values") + 
  theme(text=element_text(family="Times New Roman", face="bold", size=12), 
        legend.title = element_blank()) + 
  scale_linetype_manual(values = c("solid", "dashed"))

這使

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM