Changes

Jump to navigation Jump to search
581 bytes added ,  17:49, 12 February 2022
m
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>

Navigation menu