簡體   English   中英

更改 bwplot(格子)中框標題的大小

[英]Change size of box title in bwplot (lattice)

我有這個用格子 package 制作的 bwplot。唯一的問題是我想放大 y 軸上“早上”和“中午”文本的大小(這是腳本中稱為 Period 的 2 級因子)。 知道怎么做嗎? 到目前為止,我的 plot 和腳本:

my_settings<- list(par.main.text = list(cex = 2, just = "left", x = grid::unit(5, "mm")), box.rectangle=list(lwd=2)) # change title position and size

#the plot
bwplot(dfmh2$Period~dfmh2$count^0.5|dfmh2$microhabitat, #count - morning/midday: midday more
      par.settings = my_settings,
      par.strip.text = list(cex =1.7),
      ylab= list(label = "Period of Day", fontsize = 20), xlab= list(label = "Count (n)", 
      fontsize = 20), 
      main="A) Count")



在此處輸入圖像描述

您需要使用scales參數。 這需要一個列表,它本身就是 x 和 y 組件的列表。 y 組件可以有一個cex參數來調整文本大小:

library(lattice)

bwplot(dfmh2$Period ~ dfmh2$count^0.5 | dfmh2$microhabitat,
       par.settings = my_settings,
       par.strip.text = list(cex = 1.7),
       ylab = list(label = "Period of Day", fontsize = 20), 
       xlab = list(label = "Count (n)", fontsize = 20),
       scales = list(y = list(cex = 1.5)),
       main="A) Count")

在此處輸入圖像描述


使用的數據

雖然包含一個可重現的數據示例總是更好,但出於此 plot 的目的,我創建了一個與您自己同名的示例集:

set.seed(1)

dfmh2 <- data.frame(
  Period = factor(rep(rep(c('morning', 'midday'), each = 10), 6)),
  count  = rpois(60, 10),
  microhabitat = factor(rep(c('Avicennia open water', 'Mixed fringe', 
                              'Mixed open water', 'Rhizophora forest', 
                              'Rhizophora fringe', 
                              'Avicennia Pneumatophores'), each = 20),
                        c('Rhizophora forest', 'Rhizophora fringe',
                          'Avicennia Pneumatophores',
                          'Avicennia open water', 'Mixed fringe', 
                          'Mixed open water')))

暫無
暫無

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

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