Skip to content
Back to formatted view

Raw Message

Message-ID: <1cb44de8-69dc-100a-58cf-de4f15df97c0@yeah.net>
Date: 2022-10-10T01:01:36Z
From: Jinsong Zhao
Subject: how to enlarge the legend
In-Reply-To: <0211aa20-1f31-719f-3165-b6f7b2534719@statistik.tu-dortmund.de>

Thank you very much for the example. It works well.

Best,
Jinsong

On 2022/10/10 3:48, Uwe Ligges wrote:
> I'd propose:
> 
> plot.new()
> ltext <- "text"
> lobj <- legend("bottom", "", text.width=strwidth(ltext), fill = "gray", 
> cex = 2)
> text(lobj$text, ltext)
> 
> Best,
> Uwe Ligges
> 
> 
> On 09.10.2022 16:54, Jinsong Zhao wrote:
>> Hi there,
>>
>> in the following code, I'd like to enlarge the filled box but not the 
>> legend text.
>>
>> plot.new()
>>
>> legend("topleft", "text", fill = "gray") # filled box is too small
>>
>> legend("top", "text", fill = "gray", cex = 2) # filled box is ok but 
>> text is too large
>>
>> # I can use point to mimic filled box, but can not fill it with pattern
>>
>> legend("left", "text", pch = 22, pt.bg = "gray", pt.cex =3)
>>
>> I'd like to get filled box enlarged but with text not to be changed. 
>> Is it possible?
>>
>> Thanks in advance!
>>
>> Best,
>>
>> Jinsong
>>