In this post, How to Create Line Chart in Python. Previously I have covered the How to Create Pie Chart in Python. That was specific to the pie chart data and also the thing about this chart is that it is easy to create and see in the results. Now for this video I am going to show you how to create line chart in Python.
Now today I want to cover the basic line chart. And that has been pretty cool. I have noticed that if anyone wants to make use of the simple linear or the non linear data chart and want to make use of the output there you can use the line chart for the same. I prefer giving that an option where you can use the Line chart in Python. I guess this should work for you for most of the data.
I am using the Python for coding here. You can use the Rstudio and also you can make use of the visual studio code. And that would get you started with the design. Some of the really good charts and the output can be managed like that. In that context choose the editor that suits your case. I am sure you would love the tutorial below and also I feel for workflow side it kind of is a good option.
And I have created a video to give you an overview on How to Create Line Chart in Python. You should give this one a try.
Firs thing we are going to be looking at is the data. But before that make sure to have the libraries that we need for this tutorial.
pip install numpy, jupyter matplotlib
You can now check the version of python and other libraries too.
python --version
Now that you have checked for the python version and have the libraries installed. Next thing is making sure to add up on the sample data.
year = [1920, 1930, 1940, 1950, 1960, 1970, 1980, 1990, 2000, 2010]
powerdrop_rate = [9.8, 12, 8, 7.2, 6.9, 7, 6.5, 6.2, 5.5, 6.3]
Here in this two variables we have year and also the power drop rate. So we are going to be plotting the line chart for this data. If you have any other data to use and make sure to add up on the same there.
Here's the complete code.
import matplotlib.pyplot as plt
year = [1920, 1930, 1940, 1950, 1960, 1970, 1980, 1990, 2000, 2010]
powerdrop_rate = [9.8, 12, 8, 7.2, 6.9, 7, 6.5, 6.2, 5.5, 6.3]
plt.plot(year, powerdrop_rate)
plt.title('powerdrop_rate vs year')
plt.xlabel('year')
plt.ylabel('powerdrop_rate')
plt.show()
Now we can run the code in the terminal. And we will get output when we type in below command.
python example.py
Below is the output of that chart.
As you can see this is nor really linear chart. But you can get all the specific variables and that would be something you can plot and see the same in the output. You can experiment with the variety of the variables. That in itself is a good thing for anyone who wants to try out the data in this for the chart. I would recommend experimenting with the data and that would be a good thing to work with as well.
Next few charts in the list are - histogram and the area chart. You can have that in the upcoming weeks. So things are lined up for the next few sunday for the tutorials here. I hope by now you have go an idea on how these charts with the matplotlib work. So make sure to experiment with some of the data here and also see which plot works for you. I would be adding more such charts and also customization for specific charts which we can do there.
I am working harder on the content. And also the YouTube channel has been worked upon really well. But the traffic, subscribers and likes are really slow. So I appreciate if you can help me on that regard. I would love to get your support for the channel. You can share the above listed video in the whatsapp group or any forum of your choice. If that helps out to you and other people that would be a good thing as well. Any kind of support to help me grow would be appreciated.
If you happen to like this content, do give me feedback over there and that would help me improve my efforts in near future.
Thanks for your contribution to the STEMsocial community. Feel free to join us on discord to get to know the rest of us!
Please consider delegating to the @stemsocial account (85% of the curation rewards are returned).
You may also include @stemsocial as a beneficiary of the rewards of this post to get a stronger support.
Congratulations @devpress! You have completed the following achievement on the Hive blockchain And have been rewarded with New badge(s)
You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word
STOP
Check out our last posts: