Fork me on GitHub

ggplot from ŷhat


geom_density

Usage

geom_density(position = 'identity', stat = 'density')

Arguments

Name Description
position Position adjustments to points. identity
stat he statistical transformation to use on the data for this layer. density | identity

Aesthetics

ggplot(aes(x='pageviews'), data=pageviews) + \
    geom_density()
import pandas as pd
import numpy as np

df = pd.DataFrame({
    "x": np.random.normal(0, 10, 1000),
    "y": np.random.normal(0, 10, 1000),
    "z": np.random.normal(0, 10, 1000)
})
df = pd.melt(df)

ggplot(aes(x='value', color='variable'), data=df) + \
    geom_density()
ggplot(aes(x='value', color='variable', fill='variable'), data=df) + \
    geom_density(alpha=0.6)
ggplot(movies, aes(x='rating')) + \
    geom_density()
movies['decade'] = movies.year.round(-1)
ggplot(movies, aes(x='rating', colour='factor(decade)')) + \
    geom_density()