Raghuraman Ramachandran
2015-Feb-25 13:32 UTC
[R] plotting multiple time series under one panel
Dear guRus I have data frame as: str(voldf) 'data.frame': 130 obs. of 8 variables: $ Date: Date, format: "2014-08-01" "2014-08-05" "2014-08-08" ... $ kc : num 0.453 0.424 0.468 0.481 0.485 ... $ sb : num 0.1128 0.123 0.1272 0.1128 0.0949 ... $ qc : num 0.0626 0.0661 0.0777 0.0765 0.0763 ... $ c : num 0.167 0.182 0.183 0.21 0.215 ... $ w : num 0.21 0.271 0.282 0.351 0.345 ... $ s : num 0.249 0.253 0.295 0.332 0.35 ... $ ct : num 0.212 0.22 0.228 0.188 0.181 ... I am trying to plot multiple line charts for each of the columns and show them together in the same panel. Is it possible please using ggplot? I tried melting dfm=melt(voldf, id.vars="Date") and then plotted this but it gives me all graphs in one panel which did not help. Any assistance is greatly appreciated. Many thx Raghu
Your request is confusing. You first say "trying to plot ... together in the same panel" and then complain "all graphs in one panel which did not help". For ggplot at least, melting seems likely to help, so this would really be a good time for you to follow the request included in every message on this list by providing a reproducible example and clarifying what you want as output. You may find [1] helps you with making your example useful. [1] http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example --------------------------------------------------------------------------- Jeff Newmiller The ..... ..... Go Live... DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --------------------------------------------------------------------------- Sent from my phone. Please excuse my brevity. On February 25, 2015 5:32:07 AM PST, Raghuraman Ramachandran <optionsraghu at gmail.com> wrote:>Dear guRus > >I have data frame as: >str(voldf) >'data.frame': 130 obs. of 8 variables: > $ Date: Date, format: "2014-08-01" "2014-08-05" "2014-08-08" ... > $ kc : num 0.453 0.424 0.468 0.481 0.485 ... > $ sb : num 0.1128 0.123 0.1272 0.1128 0.0949 ... > $ qc : num 0.0626 0.0661 0.0777 0.0765 0.0763 ... > $ c : num 0.167 0.182 0.183 0.21 0.215 ... > $ w : num 0.21 0.271 0.282 0.351 0.345 ... > $ s : num 0.249 0.253 0.295 0.332 0.35 ... > $ ct : num 0.212 0.22 0.228 0.188 0.181 ... > >I am trying to plot multiple line charts for each of the columns and >show them together in the same panel. Is it possible please using >ggplot? > >I tried melting dfm=melt(voldf, id.vars="Date") and then plotted this >but it gives me all graphs in one panel which did not help. > >Any assistance is greatly appreciated. > >Many thx >Raghu > >______________________________________________ >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.
This is a plain text mailing list, and HTML gets munged on the list. It doesn't help your cause when you don't follow the Posting Guide (or my previous recommendations).>From the attached image, you do seem to want separate panels/facets. That is accomplished with the facet_wrap function with ggplot. If that tip is not sufficient, then re-read my previous response to guide you in posting a more complete question.--------------------------------------------------------------------------- Jeff Newmiller The ..... ..... Go Live... DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --------------------------------------------------------------------------- Sent from my phone. Please excuse my brevity. On February 25, 2015 6:21:14 AM PST, Raghuraman Ramachandran <optionsraghu at gmail.com> wrote:>Apologies for the mis-communication Jeff. > >Here is what I intended to do: > >?The above chart is multiple line charts which I obtained by converting >the >same dataframe into an xts and then using plot.zoo. But for aesthetics >I >wanted to use ggplot2 which might have yielded better colours and >visuals. >Can I get something like the above using ggplot2 please? > >Cheers >Raghu > >On Wed, Feb 25, 2015 at 1:59 PM, Jeff Newmiller ><jdnewmil at dcn.davis.ca.us> >wrote: > >> Your request is confusing. You first say "trying to plot ... together >in >> the same panel" and then complain "all graphs in one panel which did >not >> help". >> For ggplot at least, melting seems likely to help, so this would >really be >> a good time for you to follow the request included in every message >on this >> list by providing a reproducible example and clarifying what you want >as >> output. You may find [1] helps you with making your example useful. >> >> [1] >> >http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example >> >--------------------------------------------------------------------------- >> Jeff Newmiller The ..... ..... Go >Live... >> DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live >> Go... >> Live: OO#.. Dead: OO#.. >Playing >> Research Engineer (Solar/Batteries O.O#. #.O#. with >> /Software/Embedded Controllers) .OO#. .OO#. >rocks...1k >> >--------------------------------------------------------------------------- >> Sent from my phone. Please excuse my brevity. >> >> On February 25, 2015 5:32:07 AM PST, Raghuraman Ramachandran < >> optionsraghu at gmail.com> wrote: >> >Dear guRus >> > >> >I have data frame as: >> >str(voldf) >> >'data.frame': 130 obs. of 8 variables: >> > $ Date: Date, format: "2014-08-01" "2014-08-05" "2014-08-08" ... >> > $ kc : num 0.453 0.424 0.468 0.481 0.485 ... >> > $ sb : num 0.1128 0.123 0.1272 0.1128 0.0949 ... >> > $ qc : num 0.0626 0.0661 0.0777 0.0765 0.0763 ... >> > $ c : num 0.167 0.182 0.183 0.21 0.215 ... >> > $ w : num 0.21 0.271 0.282 0.351 0.345 ... >> > $ s : num 0.249 0.253 0.295 0.332 0.35 ... >> > $ ct : num 0.212 0.22 0.228 0.188 0.181 ... >> > >> >I am trying to plot multiple line charts for each of the columns and >> >show them together in the same panel. Is it possible please using >> >ggplot? >> > >> >I tried melting dfm=melt(voldf, id.vars="Date") and then plotted >this >> >but it gives me all graphs in one panel which did not help. >> > >> >Any assistance is greatly appreciated. >> > >> >Many thx >> >Raghu >> > >> >______________________________________________ >> >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. >> >>