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 in Data Analytics by anonymous
25 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 by anonymous
• 32,260 points

Related Questions In Data Analytics

0 votes
1 answer

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 darklord
• 6,190 points
507 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,690 points
616 views
0 votes
1 answer

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

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

answered Apr 20, 2018 in Data Analytics by zombie
• 3,710 points
103 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 in Data Analytics by anonymous
• 32,260 points
24 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 in Data Analytics by komal
26 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 in Data Analytics by anonymous
• 32,260 points
28 views
0 votes
1 answer

Add custom lines/sentences within ggplot

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

answered Nov 2 in Data Analytics by Cherukuri
• 32,260 points
22 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 in Data Analytics by anonymous
• 32,260 points
32 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 in Data Analytics by anonymous
• 32,260 points
27 views