Adding a title to a plot

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
dk
Reply | Threaded
Open this post in threaded view
|

Adding a title to a plot

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

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Adding a title to a plot

Eric Berger
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 <[hidden email]> wrote:

> 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.
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Adding a title to a plot

Duncan Murdoch-2
In reply to this post by dk
On 04/03/2021 8:41 a.m., DY Kim wrote:

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

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

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Adding a title to a plot

Duncan Murdoch-2
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:

> On 04/03/2021 8:41 a.m., DY Kim wrote:
>> 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.
>
> 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
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Adding a title to a plot

reichmaj
In reply to this post by dk
Kim

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

Jeff

-----Original Message-----
From: R-help <[hidden email]> On Behalf Of DY Kim
Sent: Thursday, March 4, 2021 7:42 AM
To: [hidden email]
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.

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.

______________________________________________
[hidden email] 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.