Dalthorp, Daniel
2016-Jul-27 21:01 UTC
[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]]
Jeff Newmiller
2016-Jul-27 21:46 UTC
[R] font size in graphs...can R read Windows settings?
What if it is being used on a platform other than Windows? This problem is more challenging than you seem to think it is. I would suggest including a kind of "par" argument to your function that lets the user change your defaults. -- Sent from my phone. Please excuse my brevity. On July 27, 2016 2:01:37 PM PDT, "Dalthorp, Daniel" <ddalthorp at usgs.gov> wrote:>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
Duncan Mackay
2016-Jul-28 03:43 UTC
[R] font size in graphs...can R read Windows settings?
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.
Dalthorp, Daniel
2016-Jul-28 23:22 UTC
[R] font size in graphs...can R read Windows settings?
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]]