Tutorial for Violin Plot in ggplot2 with Examples

df <- read.table("ford.csv",header=TRUE,sep=',') 
options( warn = -1 ) 
head(df)
Out[0]:

Loading ggplot2

First, let us load the ggplot2 library as shown below.
In [1]:
library(ggplot2)
# Basic violin plot 
ggplot(df, aes(x=transmission, y=price)) + geom_violin()
Out[2]:
Out[3]:
Out[4]:

Example 5 – Add Manual Color to Violin Plot with scale_fill_manual()

Out[5]:
Out[6]:
Out[7]:
Out[8]:
Out[9]:
Out[10]:
  • Veer Kumar

    I am passionate about Analytics and I am looking for opportunities to hone my current skills to gain prominence in the field of Data Science.

    View all posts

Follow Us

Leave a Reply

Your email address will not be published. Required fields are marked *