【问题标题】:Change size of box title in bwplot (lattice)更改 bwplot(格子)中框标题的大小
【发布时间】:2022-11-18 01:38:26
【问题描述】:

我有这个用 lattice 包制作的 bwplot。唯一的问题是我想放大 y 轴上“早上”和“中午”文本的大小(这是脚本中称为 Period 的 2 级因子)。知道怎么做吗?到目前为止我的情节和剧本:

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")



【问题讨论】:

    标签: r lattice text-size bwplot


    【解决方案1】:

    您需要使用 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")
    


    使用的数据

    虽然包含一个可重现的数据示例总是更好,但出于此图的目的,我创建了一个与您自己同名的示例集:

    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')))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-11-30
      • 2019-02-06
      • 2018-02-21
      • 2020-06-14
      • 2015-10-05
      • 1970-01-01
      • 2015-03-30
      相关资源
      最近更新 更多