
Last chance! 50% off unlimited learning
Sale ends in
s[i]
on
the current plotting device in user coordinates, inches
or as fraction of the figure width par("fin")
.strwidth(s, units = "user", cex = NULL, font = NULL, vfont = NULL, ...)
strheight(s, units = "user", cex = NULL, font = NULL, vfont = NULL, ...)
as.graphicsAnnot
.s
is measured;
should be one of "user"
, "inches"
, "figure"
;
partial matching is performed.par("cex")
yields the final character size; the
default NULL
is equivalent to 1
."family"
:
see text
.s
, giving the estimate of
width or height for each s[i]
. NA
strings are given
width and height 0 (as they are not plotted)."\n"
) it contains: it is the (number of
linefeeds - 1) times the line spacing plus the height of "M"
in
the selected font. For an expression it is the height of the
bounding box as computed by plotmath. Thus in both cases it is
an estimate of how far above the final baseline the typeset
object extends. (It may also extend below the baseline.) The
inter-line spacing is controlled by cex
,
par("lheight")
and the ‘point size’ (but not the
actual font in use). Measurements in "user"
units (the default) are only available
after plot.new
has been called -- otherwise an error is
thrown.text
, nchar
str.ex <- c("W","w","I",".","WwI.")
op <- par(pty = "s"); plot(1:100, 1:100, type = "n")
sw <- strwidth(str.ex); sw
all.equal(sum(sw[1:4]), sw[5])
#- since the last string contains the others
sw.i <- strwidth(str.ex, "inches"); 25.4 * sw.i # width in [mm]
unique(sw / sw.i)
# constant factor: 1 value
mean(sw.i / strwidth(str.ex, "fig")) / par('fin')[1] # = 1: are the same
## See how letters fall in classes
## -- depending on graphics device and font!
all.lett <- c(letters, LETTERS)
shL <- strheight(all.lett, units = "inches") * 72 # 'big points'
table(shL) # all have same heights ...
mean(shL)/par("cin")[2] # around 0.6
(swL <- strwidth(all.lett, units = "inches") * 72) # 'big points'
split(all.lett, factor(round(swL, 2)))
sumex <- expression(sum(x[i], i=1,n), e^{i * pi} == -1)
strwidth(sumex)
strheight(sumex)
par(op) #- reset to previous setting
Run the code above in your browser using DataLab