Skip to content

Adding a title to a plot

5 messages · D, Eric Berger, Duncan Murdoch +1 more

D
#
Greetings!

I am currently using R x64 4.0.4.

I used the box-cox power transformation to create a range of lambdas and
log-likelihood values using the equation.

b1=boxcox (DV ~ IV1 + IV2, data= newdata)

The above codes automatically created a plot with lambdas and
log-likelihood values.

I want to add a main and subtitle to the plot. Would you please provide me
with codes? Any help would be appreciated. Thank you.
#
Untested

b1=boxcox( DV ~ IV1 + IV2, data= newdata, main="My main title\n My
Subtitle")
On Thu, Mar 4, 2021 at 11:56 AM DY Kim <dykim7411 at gmail.com> wrote:

            

  
  
#
On 04/03/2021 8:41 a.m., DY Kim wrote:
The MASS:::boxcox.default method doesn't support adding a title.  If you 
want one, you'll have to edit the function to put in a title in the call 
to plot().  For example:

   boxcox.default <- MASS:::boxcox.default
   fix(boxcox.default)

and then edit this line

   plot(xl, loglik, xlab = xlab, ylab = ylab, type = "l",
             ylim = range(loglik, lim))

to

   plot(xl, loglik, xlab = xlab, ylab = ylab, type = "l",
             ylim = range(loglik, lim), main = "My title")

and save the result.  (You could make a slightly more sophisticated 
change such as adding "main" as an argument to the function, and using 
"main = main" in the call to plot(). )

Duncan Murdoch
#
Wow, that was an unnecessarily complicated suggestion.

Just run

  title("My title")

after running boxcox().

Duncan Murdoch
On 04/03/2021 12:30 p.m., Duncan Murdoch wrote:
#
Kim

See plot.boxcox function which has main = NULL, sub = NULL arguments

Jeff

-----Original Message-----
From: R-help <r-help-bounces at r-project.org> On Behalf Of DY Kim
Sent: Thursday, March 4, 2021 7:42 AM
To: r-help at r-project.org
Subject: [R] Adding a title to a plot

Greetings!

I am currently using R x64 4.0.4.

I used the box-cox power transformation to create a range of lambdas and
log-likelihood values using the equation.

b1=boxcox (DV ~ IV1 + IV2, data= newdata)

The above codes automatically created a plot with lambdas and log-likelihood
values.

I want to add a main and subtitle to the plot. Would you please provide me
with codes? Any help would be appreciated. Thank you.


______________________________________________
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.