How to make a color graph using matplotlib?

This recipe helps you make a color graph using matplotlib

Recipe Objective

How to make a color graph using matplotlib?

Step 1 - Importing Libraries.

import matplotlib.pyplot as plt import numpy as np

Step 2 - Creating two different sets of Array.

x=np.array([2,5,7,9,10,11,15,18,21,24,27,33,38,40,55,64]) y=np.array([5,1,9,5,10,13,19,15,21,24,28,35,41,45,50,71]) a=np.array([2,6,9,11,14,17,19,18,22,29,28,30,32,38,39,63,67,89]) b=np.array([6,9,1,11,17,19,22,25,31,34,40,47,48,55,76,81,90,91])

Step 3 - We will plot the Bar Graphs for two different sets of the array by assigning two different colors two them.

plt.bar(x, y, label = "set-1", color='r') plt.bar(a, b, label = "set-2", color='g') plt.xlabel('xaxis') plt.ylabel('yaxis') plt.legend()

What Users are saying..

profile image

Anand Kumpatla

Sr Data Scientist @ Doubleslash Software Solutions Pvt Ltd
linkedin profile url

ProjectPro is a unique platform and helps many people in the industry to solve real-life problems with a step-by-step walkthrough of projects. A platform with some fantastic resources to gain... Read More

Relevant Projects

Build Regression (Linear,Ridge,Lasso) Models in NumPy Python
In this machine learning regression project, you will learn to build NumPy Regression Models (Linear Regression, Ridge Regression, Lasso Regression) from Scratch.

Build a Text Classification Model with Attention Mechanism NLP
In this NLP Project, you will learn to build a multi class text classification model with attention mechanism.

Expedia Hotel Recommendations Data Science Project
In this data science project, you will contextualize customer data and predict the likelihood a customer will stay at 100 different hotel groups.

Build a Multi Class Image Classification Model Python using CNN
This project explains How to build a Sequential Model that can perform Multi Class Image Classification in Python using CNN

Model Deployment on GCP using Streamlit for Resume Parsing
Perform model deployment on GCP for resume parsing model using Streamlit App.

Deep Learning Project for Beginners with Source Code Part 1
Learn to implement deep neural networks in Python .

Deep Learning Project for Text Detection in Images using Python
CV2 Text Detection Code for Images using Python -Build a CRNN deep learning model to predict the single-line text in a given image.

Time Series Classification Project for Elevator Failure Prediction
In this Time Series Project, you will predict the failure of elevators using IoT sensor data as a time series classification machine learning problem.

NLP Project for Beginners on Text Processing and Classification
This Project Explains the Basic Text Preprocessing and How to Build a Classification Model in Python

PyCaret Project to Build and Deploy an ML App using Streamlit
In this PyCaret Project, you will build a customer segmentation model with PyCaret and deploy the machine learning application using Streamlit.