Python 3 Matplotlib Library to Generate Random Color Hexadecimal Codes and Plot in Graph Using Random Full Project For Beginners

Python 3 Matplotlib Library to Generate Random Color Hexadecimal Codes and Plot in Graph Using Random Full Project For Beginners

 

Welcome folks today in this blog post we will be generating random color with hexadecimal code using matplotlib and random library in python. All the full source code of the application is given below.

 

 

Get Started

 

 

In order to get started we need to install the following library using the below command as shown below

 

pip install matplotlib

 

pip install random

 

After installing this library you need to make an app.py file and copy paste the following code

 

app.py

 

import matplotlib.pyplot as plt
import random

number_of_colors = 8

color = ["#"+''.join([random.choice('0123456789ABCDEF') for j in range(6)])
             for i in range(number_of_colors)]
print(color)
for i in range(number_of_colors):
    plt.scatter(random.randint(0, 10), random.randint(0,10), c=color[i], s=200)

plt.show()

 

 

Now execute the python script by typing the below command as shown below

See also  Python 3 Script to Generate Wifi QRCode to Set Password & Wifi QRCode Scanner to Read Password Using wifi-qrcode-generator Library Full Project For Beginners

 

python app.py

 

 

Leave a Reply