Skip to content
Prev 343114 / 398506 Next

scale_*_manual in ggplot2

There is a difference between specifying a scale inside the aes or 
aes_string functions, and doing it in the arguments to the geom function. 
Inside the aes function call it creates a mapping from your input data to 
the layer variables, and you do not want to specify strings such as 
"Cusum" but rather always specify variables such as Cusum. Outside the aes 
function among the geom parameters, you can create ad-hoc settings for 
that geom that might specify colors as strings.  However, AFAIK you cannot 
build a legend in ggplot2 that describes those ad-hoc settings, so if you 
want a legend that mentions them then you need to create your data to 
contain e.g. all colour settings in one or more columns of a "long" 
version of your data (it definitely works best to have them all in one 
column). You can use the subset option to partition your "long" data among 
the different geoms even while having all the colour settings in the same 
column. The "reshape2" package is useful for creating these special 
display-ready data frames that stack variables together to fit the 
graphic you are mapping it to.

I could not get your sample code to run, and I am daunted by the 
complexity of your sample code. Perhaps the above tips will help, or you 
can post a simpler example.  One way or another, you will need to learn 
the language of visualization that ggplot2 is designed around... perhaps 
read Hadley Wickhams "ggplot" book. If that paradigm doesn't fit your way 
of thinking, then you might have more success using lattice plots.
On Wed, 13 Aug 2014, Pavneet Arora wrote:

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