[R] font size in graphs...can R read Windows settings?

Dalthorp, Daniel ddalthorp at usgs.gov
Fri Jul 29 01:22:20 CEST 2016


Thanks, Duncan. This is close to what I was looking for. But I'm not using
lattice. And the fontsize$text and fontsize$points are independent of
display settings in Windows (screen resolution and 'size of objects').

I need to make my graphs [esp. placement and size of text(), mtext()] look
good regardless of display settings.

Here's what I'm working with at the moment...

When package is loaded, I store the default graph size ('din') which is
correlated with OS display parameters. Then, I simply multiple my current
'cex' values by the stored 'din' divided by 7 (which is the 'din'
associated with the display parameters that I created the figs in
initially). It seems to work just fine for my text() and mtext() text
sizes.

But some of my algorithms for placing text and subfigs in margins still
need fixing...combinations of 'plt' and 'usr' seem to be working, but it's
tedious.

-Dan

On Wed, Jul 27, 2016 at 8:43 PM, Duncan Mackay <dulcalma at bigpond.com> wrote:

> Hi  Dan
>
> For devices png, pdf, postscript and ? others the pointsize argument
> controls the font size which is modified by cex
>
> For lattice there are the settings in trellis.par.get()
>
> trellis.par.get()$fontsize
> $text
> [1] 12
>
> $points
> [1] 8
>
> which you can set and there is no real need to change font size except if
> you need to change main.
> trellis.par.get()$grid.pars  are the settings for grid elements if used  eg
> text
>
> these could be set globally by trellis.par.set() or individually with
> argument par.settings eg
> xyplot(y ~ x, data = datm,
>              par.settings = list(strip.background = list(col =
> "transparent"),
>                                                  fontsize = list(text = 16,
>
> points = 12),  # large size;  need to refine
>                                                 superpose.polygon= list(col
> = c("red","blue"),
>
> border = c("red","blue"))),
>             type = "b")
>
> Regards
>
> Duncan
>
> Duncan Mackay
> Department of Agronomy and Soil Science
> University of New England
> Armidale NSW 2351
> Email: home: mackay at northnet.com.au
>
> -----Original Message-----
> From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Dalthorp,
> Daniel
> Sent: Thursday, 28 July 2016 07:02
> To: r-help at R-project.org (r-help at r-project.org)
> Subject: [R] font size in graphs...can R read Windows settings?
>
> Hi All,
> I am putting together a package that (among other things) draws some nice
> graphs for users. I place some explanatory text on figs using "text" and
> "mtext". But the size of the text depends on the Windows display settings:
> Smaller (100%), medium (125%) or larger (150%) (In Windows 7... Control
> panel | Appearance and personalization | Display | Make text and other
> items smaller or larger). If I create figs that look good with one setting,
> the text is too big (or too small) if another setting is used in Windows.
> If I know the Windows setting, I can use cex in R to make the right sized
> labels, but if I don't know a user's Windows display size setting...is
> there a way for R to read the setting? Or is there another way to control
> label size so that text labels on graphs look good regardless of WIndows
> display size setting?
>
> Many thanks for Ideas,
>
> -Dan
> --
> Dan Dalthorp, PhD
> USGS Forest and Rangeland Ecosystem Science Center
> Forest Sciences Lab, Rm 189
> 3200 SW Jefferson Way
> Corvallis, OR 97331
> ph: 541-750-0953
> ddalthorp at usgs.gov
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>
>


-- 
Dan Dalthorp, PhD
USGS Forest and Rangeland Ecosystem Science Center
Forest Sciences Lab, Rm 189
3200 SW Jefferson Way
Corvallis, OR 97331
ph: 541-750-0953
ddalthorp at usgs.gov

	[[alternative HTML version deleted]]



More information about the R-help mailing list