Changes
Jump to navigation
Jump to search
← Older edit
Newer edit →
Matplotlib
(edit)
Revision as of 17:49, 12 February 2022
581 bytes added
,
17:49, 12 February 2022
m
→Stack
Line 39:
Line 39:
</syntaxhighlight>
</syntaxhighlight>
−
==== Fill between ====
+
====Fill between====
<syntaxhighlight lang="python3">
<syntaxhighlight lang="python3">
import pandas as pd
import pandas as pd
Line 196:
Line 196:
plt.title("My Awesome Stack Plot")
plt.title("My Awesome Stack Plot")
plt.tight_layout()
plt.tight_layout()
+
plt.show()
+
</syntaxhighlight>
+
+
=== Histogram ===
+
<syntaxhighlight lang="python3">
+
import pandas as pd
+
from matplotlib import pyplot as plt
+
+
plt.style.use('fivethirtyeight')
+
+
data = pd.read_csv('data.csv')
+
ids = data['Responder_id']
+
ages = data['Age']
+
+
bins = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
+
+
plt.hist(ages, bins=bins, edgecolor='black', log=True)
+
+
median_age = 29
+
color = '#fc4f30'
+
+
plt.axvline(median_age, color=color, label='Age Median', linewidth=2)
+
+
plt.legend()
+
+
plt.title('Ages of Respondents')
+
plt.xlabel('Ages')
+
plt.ylabel('Total Respondents')
+
+
plt.tight_layout()
+
plt.show()
plt.show()
</syntaxhighlight>
</syntaxhighlight>
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