Plot9

MatPlotLib

Replicate Python Data Science Handbook Scatter Plot https://github.com/jakevdp/PythonDataScienceHandbook/blob/master/notebooks/04.02-Simple-Scatter-Plots.ipynb with plotnine/ggplot

In [1]:
from sklearn.datasets import load_iris
iris = load_iris()
features = iris.data.T
In [2]:
import matplotlib.pyplot as plt
In [3]:
plt.scatter(features[0], features[1], alpha=0.2,
            s=100*features[3], c=iris.target, cmap='viridis')
plt.xlabel(iris.feature_names[0])
plt.ylabel(iris.feature_names[1]);
In [ ]:
 
In [ ]:
 

Plot9 GGPLOT

In [4]:
import plotnine as p9
from plotnine import *
import pandas as pd
p9.options.figure_size = (5, 3.5)
In [5]:
from sklearn.datasets import load_iris
df = pd.DataFrame(load_iris(as_frame=True).data) # create a df from Bunch
In [6]:
## ggplot pipeline
( 
    ggplot( df, aes(df.columns[0], df.columns[1], color = df.columns[2], size = df.columns[3]))
    + geom_point()
)
Out[6]:
<ggplot: (129433389469)>