Home > Net >  R - Ggplot dataframe do not sort data properly
R - Ggplot dataframe do not sort data properly

Time:12-09

I am trying to plot data from a plot

How can I sort it in the correct numeric order?

CodePudding user response:

Your code is working fine just as data you need to use winequality_red and for the x=winequality_red$quality and y=winequality_red$alcohol. Also below an example how to convert your data, to delimit the columns.

winequality_red <- read_delim("HERE SPECIFY YOUR DATA LOCATION", 
  ";", escape_double = FALSE, trim_ws = TRUE)

ggplot(winequality_red , aes(x=winequality_red$quality, y=winequality_red$alcohol))   
  scale_fill_continuous(type = "viridis")  
  geom_bin2d(binwidth=1)

enter image description here

CodePudding user response:

Something like this?

library(tidyverse)

df <- winequality_red
df %>% 
  select(quality, alcohol) %>% 
  ggplot(aes(x = quality, y=alcohol)) 
  scale_fill_continuous(type = "viridis") 
  geom_bin2d(binwidth = 1)

enter image description here

  • Related