How To Plot Data in Python 3 Using matplotlib

Introduction:

Python is good at data analysis. Often, the data will contain several variables and institutions, so it is difficult to get an idea of what's going on. Demonstration of data is an effective way to help identify patterns of data.

For example, tell us you are a real estate agent and you are trying to understand the relationship between the age and the price. If the data is 1 block, five units, it will not be easy to get an idea of what's happening. However, you think you want to use the data in the city of 500. It will be very difficult to understand how the old age has affected the price. The image of the image, including the appearance of the image and age, can make a light for the relationship between the two.

A demonstration is a quick and easy way to forward high overall thinking, especially those who do not know your information. When working on a data profile it is often a part of the analysis.
We will use the 2D photo template, matplotlib library, which originally wrote John D. Hunter since becoming an open project to promote a more active society. It allows you to produce high-quality lines, split scanners, histograms, ice cubes, and much more. Each panel presents the data to another format which is often useful to test the different types of diagrams before deciding on the most relevant data about you. This is good to keep in mind that the theory is a combination of art and science.

Taking into account the importance of the vision, this learning explains how to write Python data using matplotlib. We will walk through the banquet with small data, including information such as the name and the legend and the image, and create a place by changing the appearance of the position. By doing these lessons, you will be able to represent Python's data!

Terms:

In this exercise, you must have Python 3, as well as the local programming program, supported by your computer. If this is, you can improve search by following the installation according to the installation guide for the operating system.

Grades 1 - Matlot Involvement:

Before we can start working on Python, we often make sure that the module is installed on matplotlib. On the phone line, check the matlotlib by performing the following order:

$ python -c "import matplotlib"

Grades 2 - To generate the data for the plan:

Written in Python, we will do some data to work with. We work in 2D, so we need X and Y coordinators at any time.
To better understand how matplotlib works, we combine the data into real-life situations. Let's say we have a coffee shop and we do not like the relationship between the average yearly average and the total number of coffee. Our impact on X will be calculated on the number of frozen fats sold per month and the Y change to the Fahrenheit average monthly average.

                             scatter.py
import matplotlib.pyplot as plt
X = [590,540,740,130,810,300,320,230,470,620,770,250]
Y = [32,36,39,52,61,72,77,75,68,57,48,48]
Python's pods to us, we make a list of two variables: X (frozen vegetable seeds) and Y (average temperature). Every item on our list is on a monthly basis (January to December). For example, the average temperature in January is 32 degrees Celsius and coffee shops sold for 590 kcal refrigerators.

Grades 3 - Required image information:

The diagonal diagram is great to detect the relationship between two variables, and we will use this type of weight for this population.

                      scatter.py
import matplotlib.pyplot as plt
X = [590,540,740,130,810,300,320,230,470,620,770,250]
Y = [32,36,39,52,61,72,77,75,68,57,48,48]
plt.scatter(X,Y)
plt.show()

 To generate cyclists using matplotlib, we use spellcheck (). It takes two arguments, which mean X and Y values.
                                       Alt Scatter plot with a title and X/Y labels.

Grades 4 - Adding addresses and labels:

Now we know the true nature of our work, we can start by adding the data to the plan. Let us verify the information we represent on you, and we will also add the title tags to each line.

                   scatter.py
import matplotlib.pyplot as plt
X = [590,540,740,130,810,300,320,230,470,620,770,250]
Y = [32,36,39,52,61,72,77,75,68,57,48,48]
plt.scatter(X,Y)
plt.title('Relationship Between Temperature and Iced Coffee Sales')
plt.show()
                                       
                                Alt Scatter plot with a title and X/Y labels.

Let's start by adding a header. We can add the title before plt.show () on the line.

Grades 5 - To create a specific location:

In each information sheet, we work with the desire to reach it and it is important to be able to organize what we want to show on our information. Remember that vision is a craft, so be creative! Matplotlib contains many forms of use, such as different colors, symbols

                      scatter.py
import matplotlib.pyplot as plt
X = [590,540,740,130,810,300,320,230,470,620,770,250]
Y = [32,36,39,52,61,72,77,75,68,57,48,48]
plt.scatter(X,Y)
plt.xlim(0,1000)
plt.ylim(0,100)
plt.title('Relationship Between Temperature and Iced Coffee Sales')
plt.show()
...

Grades 6 - Diagram:

Now we have completed our code, we will be running to see the new pocket we have.
                                          Alt Final scatter plot with title and X/Y labels and customized with larger, red, triangle points.
Then save the diagram by pressing the button, located on the bottom of the icon. View the image is saved as PNG file rather than the interactive website. Now you have your own custom charts, congratulations!

Conclusion:

In this exercise, you'll learn how to design matplotlib data in Python. Now you can see and split the data graphs.
Continue to train with matplotlib, you can follow our guide "How to solve matplotlib words with Python 3."

Comments

Popular posts from this blog

Python – Functions

Python Global Keyword