• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 222
  • Last Modified:

Include plot title in R

Hello,

I am attempting to include a title on a scatterplot in R. I am able to run the code directly below for creating the plot just fine:

pnf2.resid0 <- residuals(pnf2.glmssn0)
names( getSSNdata.frame(pnf2.resid0) )
plot(pnf2.resid0)

Open in new window


However, when I attempt to add a title using main = (as shown below), I receive an error message that reads: "formal argument 'main' matched by multiple actual arguments"

pnf2.resid0 <- residuals(pnf2.glmssn0)
names( getSSNdata.frame(pnf2.resid0) )
plot(pnf2.resid0, main = "Residual Plot")

Open in new window


Any suggestions for how to include a title on the plot?
0
dougf1r
Asked:
dougf1r
  • 6
  • 5
1 Solution
 
d-glitchCommented:
Looks correct.  Try getting rid of the spaces around the equal sign.
0
 
dougf1rAuthor Commented:
I get the same error after removing the spaces.

The problem seems to have something to do with having .resid0 after pnf2. I get the same error when attempting to add a title to a histogram. The first histogram function (shown below) works fine. However, the second fails with the same error.

par(mfrow = c(1, 2))
hist(pnf2, "Response", main = "Spatial")
hist(pnf2.resid_dn)

Open in new window

0
 
dougf1rAuthor Commented:
...that is, the second histogram function fails if I try adding , main = "Residual Plot" to the function.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
trinitrotolueneCommented:
try using title()

plot(pnf2.resid_0)
title(main="Residual Plot", col.main="red", font.main=4)

Open in new window

0
 
dougf1rAuthor Commented:
Using title() as a separate function does include a title at the top of the page. However, the plot includes a default title and this default title remains on the plot, so there are now two titles (attached).
0
 
dougf1rAuthor Commented:
Attachment for comment above.
Rplot.jpeg
0
 
trinitrotolueneCommented:
This is probably the reason why the first error happened. Let me check this out and I'll let you know.

Can you upload the whole source file. I would like to see how you are initializing
0
 
trinitrotolueneCommented:
you also need to give the complete error message. Pretty difficult seeing where the argument matching is going awry without this info
0
 
trinitrotolueneCommented:
plot(pnf2.resid0, main = "Residual Plot")

Open in new window


looking at your original code. You are defining main to be "Res....Plot"

If you trace into the plot call there will already exist a definition for main and that is the reason you are getting the multiple arguments error.
I suspect main is being set to the default string you uploaded in your last post.


Hope this helps.

Else just upload your whole source file and the whole error message. Use traceback() to get the whole call sequence leading up to the error
0
 
dougf1rAuthor Commented:
yes. this helps. thank you for the helpful comments. I can get it working now.
0
 
trinitrotolueneCommented:
Glad it worked. Could you show me the code  you put in to fix the problem.?
Just the relevant snippet should do.
Interested from a technical angle.
0
 
dougf1rAuthor Commented:
Your comment and suggestion of using traceback() to get the whole call sequence leading up to the error is a sufficient answer to my question. However, I am occupied by other tasks at the moment, so I am not able to implement the solution at this time.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now