Error "sufficient values in manual scale. 10 needed but only 7 provided"

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Error "sufficient values in manual scale. 10 needed but only 7 provided"

greg holly
Hi Dear all;

I am getting the "sufficient values in manual scale. 10 needed but only 7
provided." problem when running the followings. Your help is highly
appreciated.

Regards,
Greg

p2<-p1+scale_color_manual(name="Diseases",
labels=c("Myocardial Infarction", "Coronary artery disease", "Stroke",
"Hypertension", "Depression Anxiety Emotional Problems",  "Circulatory
Problems", "Diabetes"),

values=c("Myocardial Infarction"="red",  "Coronary artery
disease"="purple","Stroke"="darkgreen",
 "Hypertension"="orange",  "Depression Anxiety Emotional
Problems"="darkblue",
 "Circulatory  Problems"="darkred","Diabetes"="blue"))

        [[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: Error "sufficient values in manual scale. 10 needed but only 7 provided"

Jeff Newmiller
Problem is in your data not matching your values, but you did not share your data. Try using the unique() function to see what values you have in your data.

I will say that when I want to assign discrete colors I always start by converting my character column in the data frame to a factor and specify the order I want to see the levels presented in that conversion step. Then the colors only need to be specified in that same order and I don't need to keep repeating the labels in multiple places.

library(ggplot2)

mpg$classf <- factor( mpg$class
                   , levels = c( "2seater"
                               , "subcompact"
                               , "compact"
                               , "midsize"
                               , "minivan"
                               , "suv"
                               , "pickup"
                               )
                   )

class_colours <- rainbow( length( levels( mpg$classf ) ) )
ggplot( mpg, aes( x = classf, y = cty, colour=classf ) ) +
 geom_boxplot() +
 scale_colour_manual( name="Class", values = class_colours )




On January 23, 2019 3:12:26 PM PST, greg holly <[hidden email]> wrote:

>Hi Dear all;
>
>I am getting the "sufficient values in manual scale. 10 needed but only
>7
>provided." problem when running the followings. Your help is highly
>appreciated.
>
>Regards,
>Greg
>
>p2<-p1+scale_color_manual(name="Diseases",
>labels=c("Myocardial Infarction", "Coronary artery disease", "Stroke",
>"Hypertension", "Depression Anxiety Emotional Problems",  "Circulatory
>Problems", "Diabetes"),
>
>values=c("Myocardial Infarction"="red",  "Coronary artery
>disease"="purple","Stroke"="darkgreen",
> "Hypertension"="orange",  "Depression Anxiety Emotional
>Problems"="darkblue",
> "Circulatory  Problems"="darkred","Diabetes"="blue"))
>
> [[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.

--
Sent from my phone. Please excuse my brevity.

______________________________________________
[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: Error "sufficient values in manual scale. 10 needed but only 7 provided"

greg holly
Hi Jeff;

I figured out the problem. I do apologize to you and members in the list to
bother you with this simple problem.

Regards,
Greg

On Wed, Jan 23, 2019 at 6:46 PM Jeff Newmiller <[hidden email]>
wrote:

> Problem is in your data not matching your values, but you did not share
> your data. Try using the unique() function to see what values you have in
> your data.
>
> I will say that when I want to assign discrete colors I always start by
> converting my character column in the data frame to a factor and specify
> the order I want to see the levels presented in that conversion step. Then
> the colors only need to be specified in that same order and I don't need to
> keep repeating the labels in multiple places.
>
> library(ggplot2)
>
> mpg$classf <- factor( mpg$class
>                    , levels = c( "2seater"
>                                , "subcompact"
>                                , "compact"
>                                , "midsize"
>                                , "minivan"
>                                , "suv"
>                                , "pickup"
>                                )
>                    )
>
> class_colours <- rainbow( length( levels( mpg$classf ) ) )
> ggplot( mpg, aes( x = classf, y = cty, colour=classf ) ) +
>  geom_boxplot() +
>  scale_colour_manual( name="Class", values = class_colours )
>
>
>
>
> On January 23, 2019 3:12:26 PM PST, greg holly <[hidden email]>
> wrote:
> >Hi Dear all;
> >
> >I am getting the "sufficient values in manual scale. 10 needed but only
> >7
> >provided." problem when running the followings. Your help is highly
> >appreciated.
> >
> >Regards,
> >Greg
> >
> >p2<-p1+scale_color_manual(name="Diseases",
> >labels=c("Myocardial Infarction", "Coronary artery disease", "Stroke",
> >"Hypertension", "Depression Anxiety Emotional Problems",  "Circulatory
> >Problems", "Diabetes"),
> >
> >values=c("Myocardial Infarction"="red",  "Coronary artery
> >disease"="purple","Stroke"="darkgreen",
> > "Hypertension"="orange",  "Depression Anxiety Emotional
> >Problems"="darkblue",
> > "Circulatory  Problems"="darkred","Diabetes"="blue"))
> >
> >       [[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.
>
> --
> Sent from my phone. Please excuse my brevity.
>

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