Skip to content

R-alpha: R 0.50.a3: title( .. adj= x) AND mtext( .. adj= x)

3 messages · Martin Maechler, Peter Dalgaard, Ross Ihaka

#
Kurt> Not sure if I already reported this ... it seems that as of
    Kurt> 0.50.a2, the adj graphics parameter is completely ignored.  Try
    Kurt> e.g.
    Kurt>	plot(1:10)
    Kurt>	title(main = "This is a title", adj = 0)
    Kurt>	title(main = "This is a title", adj = 1)

    Kurt> No difference ...

true.
	{{are you sure if your example worked before ??}}


For  'mtext(..)'  adj does something but not the proper one :

	plot(1:10)#-- or just in the plot above..

	mtext( "This is an 'mtext(.. adj=0)'", adj = 0)
	mtext( "This is an 'mtext(.. adj=1)'", adj = 1)
	## is different but result is WRONG: adj=1 is LEFT of adj=0


for  'text(..)'   adj works as it should, at least in the cases I used it.
					 [ -> see the example in  ?text]
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#
Martin Maechler <maechler@stat.math.ethz.ch> writes:
-- as it should be! adj=0 is left-aligned, adj=1 is right-aligned

(take a string, attach a scale 0 to 1 along it, mark the value of adj
on scale, attach that point to the anchor point, i.e. the midpoint of
the plotting frame).
seems to work exactly the same!

The confusion seems to come from wanting 0/0.5/1 to mean
left/center/right-*justified* along the plot frame, which it really
doesn't. 

Even if it did, it wouldn't help, the control really needs to be
two-dimensional: you might want text left/center/right aligned with
the top of the y-axis. The at= parameter *almost* does it, but it is
in user coordinates, rather than frame coordinates. Perhaps we want an
anchor= parameter? -- or even better, a way of attaching units to plot
lengths. This kind of problem also appears with text() and legend()
(ever tried to produce plots with different scales but the legends in
the exact same spot?).
#
Peter Dalgaard BSA writes:
 > (ever tried to produce plots with different scales but the legends in
 > the exact same spot?).

There is a barely documented (and nearly forgotten) R "feature" which you
might find useful ...

The functions xinch() and yinch() convert inches (xcm() and ycm() are
left as an exercise) to "usr" coordinates.

For example, to plot a point half an inch up from the lower left
corner of a plot you can use:

	ll <- par("usr")[c(1,3)] + c(xinch(0.5), yinch(0.5))
	points(ll[1], ll[2])

The same trick works for placing legends in "usr" coordinates.
	Ross


PS: I am making the "adj" feature behave like S.  Again this was
ignorance on my part, not malice.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-