How to provide color to ggplot scatter chart depending on field value

0 votes

How to provide color to ggplot scatter chart depending on field value?

I tried below code but i want different colors and not in the same blue scale. What to do?

ggplot(mpg, aes(cty,hwy,col= km$cluster)) + geom_point()
Jul 16, 2019 in Data Analytics by anonymous
835 views

1 answer to this question.

0 votes
cyl is a continuous value field, so it cannot show different colors

One way is to change the color scale to Viridis using scale_col_continuous(type = "Viridis")

Or change the field to a discrete scale.
answered Nov 2, 2019 by anonymous
• 33,030 points

Related Questions In Data Analytics

+1 vote
2 answers

How to replace a value in a data frame based on a conditional 'If' statement?

It's easier to convert alpha to characters ...READ MORE

answered Jun 6, 2018 in Data Analytics by Sahiti
• 6,370 points
36,682 views
0 votes
1 answer
0 votes
1 answer

How to create dummy variables based on a categorical variable of lists in R?

You can use mtabulate in the following way: library(qdapTools) cbind(data[1], ...READ MORE

answered Apr 13, 2018 in Data Analytics by CodingByHeart77
• 3,750 points
2,657 views
0 votes
4 answers

How to change font size of text and axes on R plots ?

To change the font size of text ...READ MORE

answered Dec 16, 2020 in Data Analytics by Gitika
• 65,770 points
123,000 views
0 votes
1 answer

How to edit the labels and limit if a plot using ggplot? - R

Add a limit to axis ticks using ...READ MORE

answered Nov 3, 2019 in Data Analytics by anonymous
• 33,030 points
728 views
0 votes
1 answer

which to use fill or color to show colors in R plots?

The color attribute is only used for ...READ MORE

answered Nov 4, 2019 in Data Analytics by komal
1,796 views
0 votes
1 answer

plot a line chart along with point labels in the plot

Follow the below steps: 1. Create a ggplot ...READ MORE

answered Nov 2, 2019 in Data Analytics by anonymous
• 33,030 points
1,717 views
0 votes
1 answer

Add custom lines/sentences within ggplot

Use geom_text along with position and text ...READ MORE

answered Nov 2, 2019 in Data Analytics by Cherukuri
• 33,030 points
884 views
0 votes
1 answer

How to add labels on bars in bar chart in ggplot?

Use geom_text() to add labels on the ...READ MORE

answered Aug 20, 2019 in Data Analytics by anonymous
• 33,030 points
3,986 views
0 votes
1 answer

How to provide xpath value for web scraping?

Hey Karthik, XPath uses path expressions to select ...READ MORE

answered Sep 18, 2019 in Data Analytics by anonymous
• 33,030 points
1,016 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP