Changes
Jump to navigation
Jump to search
← Older edit
Newer edit →
Matplotlib
(edit)
Revision as of 18:55, 12 February 2022
604 bytes added
,
18:55, 12 February 2022
m
→Histogram
Line 199:
Line 199:
</syntaxhighlight>
</syntaxhighlight>
−
=== Histogram ===
+
===Histogram===
<syntaxhighlight lang="python3">
<syntaxhighlight lang="python3">
import pandas as pd
import pandas as pd
Line 224:
Line 224:
plt.xlabel('Ages')
plt.xlabel('Ages')
plt.ylabel('Total Respondents')
plt.ylabel('Total Respondents')
+
+
plt.tight_layout()
+
+
plt.show()
+
</syntaxhighlight>
+
+
=== Scatter plot ===
+
<syntaxhighlight lang="python3">
+
import pandas as pd
+
from matplotlib import pyplot as plt
+
+
plt.style.use('seaborn')
+
+
data = pd.read_csv('2019-05-31-data.csv')
+
view_count = data['view_count']
+
likes = data['likes']
+
ratio = data['ratio']
+
+
plt.scatter(view_count, likes, c=ratio, cmap='summer',
+
edgecolor='black', linewidth=1, alpha=0.75)
+
+
cbar = plt.colorbar()
+
cbar.set_label('Like/Dislike Ratio')
+
+
plt.xscale('log')
+
plt.yscale('log')
+
+
plt.title('Trending YouTube Videos')
+
plt.xlabel('View Count')
+
plt.ylabel('Total Likes')
plt.tight_layout()
plt.tight_layout()
Rafahsolis
Bureaucrats
,
Administrators
2,306
edits
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
Variants
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
Special pages
Printable version