VOOZH about

URL: https://www.geeksforgeeks.org/data-visualization/visualization-and-prediction-of-crop-production-data-using-python/

⇱ Visualization and Prediction of Crop Production data using Python - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Visualization and Prediction of Crop Production data using Python

Last Updated : 23 Jul, 2025

Prerequisite: Data Visualization in Python

Visualization is seeing the data along various dimensions. In python, we can visualize the data using various plots available in different modules.

In this article, we are going to visualize and predict the crop production data for different years using various illustrations and python libraries.

Dataset

The Dataset contains different crops and their production from the year 2013 – 2020.

Requirements

There are a lot of python libraries which could be used to build visualization like matplotlib, vispy, bokeh, seaborn, pygal, folium, plotly, cufflinks, and networkx. Of the many, matplotlib and seaborn seems to be very widely used for basic to intermediate level of visualizations.

However, two of the above are widely used for visualization i.e.

  • Matplotlib: It is an amazing visualization library in Python for 2D plots of arrays, It is a multi-platform data visualization library built on NumPy arrays and designed to work with the broader SciPy stack. Use the below command to install this library:        
pip install matplotlib
  • Seaborn: This library sits on top of matplotlib. In a sense, it has some flavors of matplotlib while from the visualization point, it is much better than matplotlib and has added features as well. Use the below command to install this library: 
pip install seaborn

Step-by-step Approach

  • Import required modules
  • Load the dataset.
  • Display the data and constraints of the loaded dataset.
  • Use different methods to visualize various illustrations from the data.   

Visualizations

Below are some programs which indicates the data and illustrates various visualizations of that data:

Example 1:

Output:

👁 Image

These are the top 5 rows of the dataset used.

Example 2:

Output:

👁 Image

These are the data constraints of the dataset.

Example 3:

Output:

👁 Image

The above program depicts the crop production data in the year 2011 using histogram.

Example 4:

Output:

👁 Image

The above program depicts the crop production data in the year 2012 using histogram.

Example 4:

Output:

👁 Image

The above program depicts the crop production data in the year 2013 using histogram.

Example 5:

Output:

👁 Image

The above program depicts the crop production data of all the available time periods(year) using multiple histograms.

Example 6:

Output:

👁 Image

Comparing crop productions in the year 2013 and 2014 using box plot.

Example 7:

 
 

Output:


 

👁 Image


 

Comparing crop production in the year 2013 and 2014 using scatter plot.


 

Example 8:


 

Output:

👁 Image

Comparing crop productions in the year 2013 and 2014 using line plot. 

Example 9:

Output:

👁 Image

Applying linear regression to visualize and compare predicted crop production data between the year 2017 and 2018. 

Example 10:

Output:

👁 Image

Applying linear regression to visualize and compare predicted crop production data between the year 2016 and 2017. 

Demo Video

This video shows how to depict the above data visualization and predict data, using Jupyter Notebook from scratch.

In this way various data visualizations and predictions can be computed. 

Comment