![]() ![]() Scatter diagrams are especially useful when applying linear regression. You may notice that a negative relationship exists between those two variables, meaning that when the Unemployment Rate increases, the Stock Index Price falls. ![]() Once you run the Python code, you’ll get the following Scatter plot:Īs indicated earlier, this plot depicts the relationship between the Unemployment Rate and the Stock Index Price. Plt.ylabel('Stock Index Price', fontsize=14) Plt.xlabel('Unemployment Rate', fontsize=14) Plt.title('Unemployment Rate Vs Stock Index Price', fontsize=14) Plt.scatter(Unemployment_Rate, Stock_Index_Price, color='green') Your full Python code would look like this: import matplotlib.pyplot as plt To create the scatter plot based on the above data, you can apply the generic syntax that was introduced at the beginning of this guide. You can create simple lists, which will contain the values for the Unemployment Rate and the Stock Index Price: Unemployment_Rate = I’ll use 2 different approaches to capture the data in Python via: Here is the dataset associated with those two variables: Unemployment_Rateīefore you plot that data, you’ll need to capture it in Python. Scatter plots are used to depict a relationship between two variables.įor example, let’s say that you want to depict the relationship between: How to Create Scatter Plots using Matplotlib Let’s now review the steps to create a Scatter plot. Line chart import matplotlib.pyplot as pltīar chart import matplotlib.pyplot as plt In this guide, I’ll show you how to create Scatter, Line and Bar charts using matplotlib.īut before we begin, here is the general syntax that you may use to create your charts using matplotlib: Scatter plot import matplotlib.pyplot as plt Matplotlib is a popular Python module that can be used to create charts. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |