Home > Blockchain >  How to create a scatterplot of data using `matplotlib.pyplot.scatter`
How to create a scatterplot of data using `matplotlib.pyplot.scatter`

Time:03-19

I've problem with matplotlib.pyplot.scatter.

Firstly, I need to download the data on Iris classification and paste headlines.

        import numpy as np
    import pandas as pd
    import matplotlib.pyplot as plt
    import seaborn as sns
    
    plt.style.use('seaborn')
    
    %matplotlib inline
    
    df = pd.read_csv('http://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data', header = None)
    df_names = ['sepal length in cm', 'sepal width in cm', 'petal length in cm', 'petal width in cm', 'class']
    df.columns = df_names
    df

Secondly, I should Create a scatterplot of data using matplotlib.pyplot.scatter in a following manner:

    * for x and y coordinates use sepal length and width respectively
    * for size use the petal length
    * for alpha (opacity/transparency) use the petal width
    * illustrate iris belonging to each class by using 3 distinct colours (RGB for instance, but be creative if you want)
    * *some columns will need to be scaled, to be passed as parameters; you might also want to scale some other columns to increase the readability of the illustration.

Then, I found this site: Your desire output

  • Related