Displaying 20 results from an estimated 168 matches for "strwidth".
2007 Oct 30
3
strwidth of bold font
Hi!
Is there a way to get the string width of the bold typefaces?
like: strwidth("text", family = "serif", font = 2).
Thanks
Roland
2000 Nov 08
1
Graphics-Device-Size vs. Window-Size
I want to layout on screen a graphic bigger than the screen (width=16.53543,
height=11.69291) but strwidth() and strheight() give wrong results.
> x11(width=42/2.54, height=29.7/2.54, pointsize=12)
> plot(1,1, type="n", xlim=c(0, 1), ylim=c(-1, 0), xlab="", ylab="",
axes=FALSE)
> strwidth("Whatever")
[1] 0.08471151
> # Now resize the window and repeat...
2000 Nov 08
1
Graphics-Device-Size vs. Window-Size
I want to layout on screen a graphic bigger than the screen (width=16.53543,
height=11.69291) but strwidth() and strheight() give wrong results.
> x11(width=42/2.54, height=29.7/2.54, pointsize=12)
> plot(1,1, type="n", xlim=c(0, 1), ylim=c(-1, 0), xlab="", ylab="",
axes=FALSE)
> strwidth("Whatever")
[1] 0.08471151
> # Now resize the window and repeat...
2004 Nov 20
1
Error with strwidth after lattice graphic drawn
In
platform i386-pc-linux-gnu
arch i386
os linux-gnu
system i386, linux-gnu
status
major 2
minor 0.1
year 2004
month 11
day 15
language R
I'm getting an error when using strwidth after a lattice graphic is drawn:
library(lattice)
xyplot(runif(20) ~ runif(20))
strwidth('xxx')
Error in strwidth("xxx") : invalid graphics state
Any help appreciated. I have version 2.0.1 of grid and version 0.10-14
of lattice.
--
Frank E Harrell Jr Professor and Chair...
2002 Aug 14
1
strwidth
Dear plotting experts,
I need to determine the width of a string before plotting it to the
current device because I want to adjust `mai' to have
the necessary space available. It seems to me that this is an "hen and
egg" problem:
R> a <- "test"
R> strwidth(a)
Error in strwidth(a) : plot.new has not been called yet
# ok, I need an open device
R> plot(1:2, type="n")
R> strwidth(a)
[1] 0.04760034
fine. But I can't continue to plot to the current device because I need to
reset `mai', so I need a second one ...
This is not re...
2005 Jun 11
1
Wishlist: strwidth allow for rotation of text (PR#7931)
Hi,
This is not a bug, but an enhancement suggestion. "strwidth" only gives the
width of the text according to the x-axis user coordinates, and similarly
for "strheight". Even if the par setting "srt" is changed to rotate the
text, the resulting width (resp. height) is in terms of the non-rotated
text. Currently, if I want to know h...
2007 Nov 07
1
strwidth and strheight for rotated text
Dear All,
I would like to plot text with a box around it. I used strwidth and
strheight to compute the size of the box which is plotted with rect:
z <- rnorm(10)
# horizontal text works
plot(rnorm(10))
x1 <- 5
y1 <- 0
label <- "Label"
cha <- paste(" ", label, " ", sep = "")
xh <- strwidth(cha, cex = par("c...
2008 Jun 30
2
Plotting question: Problem with strwidth in 2.7.1
R users,
I have a problem with function strwidth in 2.7.1. I'm trying to set
the plot margins in a way that horizontal
column labels will fit to the graph. tmp.t is a list of data.frame
objects. This code works well in 2.6.0.
...snip..
library(gplots)
for (i in names(tmp.t)) {
bmp(filename=paste(i, "_", Sys.Date(), "...
2009 Jan 05
1
strwidth to lines
Dear members,
Is there a way to turn a strwidth of a string into a number of lines
that ist needed to display the string when using par(mar = c(?,4,4,2))
####
x = 1:5
names(x) = c("ZZZZZ","ZZZZZzzzzz","ZZZlllll","TTTTT","Zzhtsddfg" )
par(mfrow = c(1,2))
par(mar = c(8,4,4,2))
barplot(x, las = 3,...
2002 Apr 17
1
Using strwidth before plotting
In the plotcorr() function in the ellipse package, I want to position
things differently depending on the size of the labels. I can use
strwidth to find out the length of the labels, but only when there's a
plot window open: it won't open one.
Question: What function call says: make sure there's a window open
(i.e. do what plot() does before it starts plotting)?
I don't think I can use plot.new() or frame(), because I d...
2002 Sep 03
1
Properly initializing a plot
I have many functions for high-level plotting that early on in their code do something like strwidth('string', units='inches') before plotting. I do this before plot() to set the correct margins with par(mai=...), to leave room for wide text on the left or right margins.
If the plotting device is not opened strwidth( ) causes an error that plot.new() needs to be called. I can se...
2011 Aug 12
1
Grid unit width and font face
Dear R-users,
When one defines a grid unit object using the 'strwidth' dimension, it
seems that the default plain font is assumed as the following example
illustrates. Is there a way to either make use of a font option when
creating a unit object or to know the factor that exists between the
width of the same text printed in plain and in bold? This might be
depen...
2010 Apr 15
2
graphic question
Hello,
I have a simple question that I could not really figure out. I am plotting labels within a graph using the text function. I first plot the first label by specifying the x and y coordinates on the graph. Then to plot the second label next to it, I am using te strwidth function to get the width of the previous label in user coordinate then add the maximum width to the x value. However, this is not working:
Here is an example:
lab1<-c("Hocine & Ruba 2000", "Yasmine 2004","Ziad was born in 2006")
lab2<-c(20,22,45)
lab3<...
2007 Aug 14
1
{grid} plain units with non NULL data arguments
In help(unit) I read:
The 'data' argument must be a list when the 'unit.length()'
is greater than 1. For example, 'unit(rep(1, 3), c("npc",
"strwidth", "inches"), data=list(NULL, "my string", NULL))'.
In the newest R-versions it is not anymore allowed to let strings
in the data-argument for plain units, otherwise one gets the
following error:
Non-NULL value supplied for plain unit
I have some labels. Between th...
2005 Jun 01
1
panel.axis() & grid/lattice settings
...er, I am interested in determining values for cex and rot based on the
current panel / viewport and device. More specifically, I would like to make
adjustments when tick labels overlap on the x-axis, such as labels of a
factor. If I use base graphics, par("cin") or par("cxy") or strwidth(), etc.
can be used to develop an algorithm to adjust cex or/and rot if needed.
I am trying to determine the parameters/settings in grid analogous to
par("cin"), etc. mentioned above, knowing that par() has no effect in
lattice / grid. I have dug around the sources for grid and lattice b...
2007 Oct 31
1
textplot() in gplots causes problems (0x9)
...="left")
I am getting these error messages:
Warning messages:
1: In FUN(c("C", "a", "l", "l", ":", "l", "m", "(", "f", "o", "r", :
font width unknown for character 0x9
2: In strwidth(object, cex = cex) : font width unknown for character 0x9
3: In FUN(c("C", "a", "l", "l", ":", "l", "m", "(", "f", "o", "r", :
font width unknown for character 0x9
4: In strwidth(object,...
1997 Nov 03
1
R-beta: math in legends
A non-text attachment was scrubbed...
Name: not available
Type: text
Size: 478 bytes
Desc: not available
Url : https://stat.ethz.ch/pipermail/r-help/attachments/19971103/ae2f1119/attachment.pl
2000 Nov 09
1
RE: [R] Graphics-Device-Size vs. Window-Size
...ce to know my device has 8 inches
and that text x needs y inches in width. But the adress space in which
plotting is done are the "user" coordinates. So, for the simplest example,
specifying xlim=c(0,1) generates a stable reference WHICH DOES NOT CHANGE ON
RESIZING THE GRAPHICS WINDOW. As strwidth(units="user") DOES CHANGE ON
RESIZING THE GRAPHICS WINDOW the units arguably ARE NOT the user
coordinates.
I tend to believe this is a BUG. Same for units="figure".
I also tend to believe, that resizing a graphics window should rescale the
font size used ON SCREEN, because cur...
2004 Mar 03
3
Adding text (coefts) to pairs panels
...NULL, nsmall = 0, justify =
"left", ...)
const<-paste(prefix, const, sep="")
slope<-format(reg[2], trim = FALSE, digits = NULL, nsmall = 0, justify =
"left", ...)
slope<-paste(prefix, slope, sep="")
if(missing(cex.cor)) cex <- 0.8/strwidth(const)
text(0.1, 0.5, const, cex=cex)
if(missing(cex.cor)) cex <- 0.8/strwidth(slope)
text(0.5, 0.1, slope, cex=cex)
}
pairs(USJudgeRatings[1:5], lower.panel=panel.smooth, diag.panel=panel.hist,
upper.panel=panel.myfitline)
Mark Van De Vyver
PhD
Lecturer
Finance Discipline
School of...
2010 Mar 27
1
string width calculation
...trings here and the same font was used for both strings - even under these circumstances, it does not work correctly):
> STRING1 <- "0123456789 0"
> STRING2 <- " x "
> pdf("GREEK.pdf", width=10, height=8)
> par(mfrow=c(1,1))
> WIDTH1 <- strwidth("0123456789", cex=1, units="inches", family="", font=1)
> WIDTH2 <- strwidth("0", cex=1, units="inches", family="", font=1)
> plot(1,1,type="n", axes=F, xlab="", ylab="")
> mtext(line=-1...