+ Reply to Thread
Results 1 to 9 of 9

Thread: How can you put 2 lines on a graph? Please help.

  1. #1
    Points: 3,030, Level: 33
    Level completed: 87%, Points required for next Level: 20

    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How can you put 2 lines on a graph? Please help.



    I am doing an MPH, and am learning to use R, but have got totally lost.

    I have been given this question,

    Plot the monthly deaths from pneumonia/influenza, and respiratory illness on
    the same graph?

    What would be the code for this?

    Any help is greatly wellcom.

  2. #2
    TS Contributor
    Points: 5,172, Level: 46
    Level completed: 11%, Points required for next Level: 178

    Location
    Athens , Greece
    Posts
    330
    Thanks
    0
    Thanked 4 Times in 2 Posts
    This is part of a code of mine.I plot the density of beta.draws nad overlay the density of another model using lines()

    Code: 
    plot(density(fix.m7.1n.rj$beta.draws[i,]),ylim=c(0,k),main="",col="steelblue")
    lines(density(fix.m7.1n.mc3$beta.draws[i,]),col="red");grid()
    You should be careful regarding the plotting regions,though!

  3. #3
    Points: 3,030, Level: 33
    Level completed: 87%, Points required for next Level: 20

    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you for your help. i have tried to fit you code into what i want, but its not working, what am i doing wrong?


    > plot(tapply(deaths$pneu,deaths$year,mean),ylim=c(0,400),col="steelblue")lines(tapply(deaths$resp,deaths$year,mean),col="red");grid()
    Error: unexpected symbol in "plot(tapply(deaths$pneu,deaths$year,mean),ylim=c(0,400),col="steelblue")lines"
    >

  4. #4
    TS Contributor
    Points: 5,172, Level: 46
    Level completed: 11%, Points required for next Level: 178

    Location
    Athens , Greece
    Posts
    330
    Thanks
    0
    Thanked 4 Times in 2 Posts
    It's the lines() part! You forgot the ";" in order to send all the commands at one time...

    plot(tapply(deaths$pneu,deaths$year,mean),ylim=c(0 ,400),col="steelblue");lines(tapply(deaths$resp,dea ths$year,mean),col="red");grid()

  5. #5
    Points: 309, Level: 6
    Level completed: 18%, Points required for next Level: 41

    Location
    germany
    Posts
    7
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: How can you put 2 lines on a graph? Please help.

    there should be a tool, that "or"s two pictures ?! (.bmp)

  6. #6
    RotParaTon
    Points: 46,287, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Awards:
    Discussion EnderPosting AwardFrequent PosterCommunity AwardMaster Tagger
    Dason's Avatar
    Location
    Ames, IA
    Posts
    9,083
    Thanks
    211
    Thanked 1,609 Times in 1,379 Posts

    Re: How can you put 2 lines on a graph? Please help.

    Quote Originally Posted by gsgs View Post
    there should be a tool, that "or"s two pictures ?! (.bmp)
    I recognize all of these words on their own. But put together it looks like gibberish.
    "His programming is malfunctioning. It begins! Get your weapons, he's going to become a killbot!!!" - bryangoodrich

  7. #7
    Points: 309, Level: 6
    Level completed: 18%, Points required for next Level: 41

    Location
    germany
    Posts
    7
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: How can you put 2 lines on a graph? Please help.

    it's AND, not OR since 255 is white. Make 2 charts in .bmp (one with each line) and merge them
    by ANDing the pixeldata. I just thought, that would be useful so I tried it.
    In C, not in R and I don't know what MPH is.
    I found this by searching for influenza

  8. #8
    RotParaTon
    Points: 46,287, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Awards:
    Discussion EnderPosting AwardFrequent PosterCommunity AwardMaster Tagger
    Dason's Avatar
    Location
    Ames, IA
    Posts
    9,083
    Thanks
    211
    Thanked 1,609 Times in 1,379 Posts

    Re: How can you put 2 lines on a graph? Please help.

    Ok - but the approach where you just plot two lines (given back in 2008) seems a lot simpler and more appropriate...
    "His programming is malfunctioning. It begins! Get your weapons, he's going to become a killbot!!!" - bryangoodrich

  9. #9
    Points: 309, Level: 6
    Level completed: 18%, Points required for next Level: 41

    Location
    germany
    Posts
    7
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: How can you put 2 lines on a graph? Please help.


    often I have the problem that I copy and paste a chart that I find on the web -
    - then another one
    - then I want them both in one chart
    I'm using MS-paint ... maybe other software can do it

    so I thought it's useful to have an ANDing of .bms utilities from commandline
    also a colorchange (before the AND), change colorx to colory in whatever.bmp
    and a size-change

    in general I prefer working with DOS-commandline than with Windows


    also a program that extracts the pixel positions from a chart
    and stores the estimates function-values as data

+ Reply to Thread

Similar Threads

  1. Labels and Lines
    By rsmullen in forum R
    Replies: 3
    Last Post: 11-15-2010, 06:57 AM
  2. Plotting 3 Lines on the same Plot
    By techintern4000 in forum SAS
    Replies: 0
    Last Post: 07-08-2009, 01:39 PM
  3. Replies: 1
    Last Post: 09-27-2008, 09:02 PM
  4. Scatterplot lines intercepting?
    By misguided_will in forum Statistics
    Replies: 1
    Last Post: 07-31-2008, 09:51 AM
  5. Comparing two lines?
    By ThePensive in forum Statistics
    Replies: 0
    Last Post: 05-08-2007, 02:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts








Advertise on Talk Stats