Re: [R] how to enlarge the legend
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 __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to enlarge the legend
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 __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to enlarge the legend
Nope. Sorry. Ignore my comment. box.lwd changes the width of the box line, bot the width of the box. -- Bert On Sun, Oct 9, 2022 at 8:08 AM Bert Gunter wrote: > Did you use the 'box.lwd' argument to set the width of the box? If so, why > does this not work for you? If not, set it to a bigger value. > > Cheers, > Bert > > On Sun, Oct 9, 2022 at 7:55 AM 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 >> >> __ >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to enlarge the legend
Did you use the 'box.lwd' argument to set the width of the box? If so, why does this not work for you? If not, set it to a bigger value. Cheers, Bert On Sun, Oct 9, 2022 at 7:55 AM 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 > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to enlarge the legend
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 __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.