![]() ![]() Note: This method works only for continuous (interval) variables. Column WHA2F14 will read 3.1 in the bar chart. So for example if you change the column width to 3. Change the width from 10 to whatever specified length you want. # Importing the relevant fuction to format the y axisįrom matplotlib.ticker import FuncFormatterĪx.t_major_formatter(FuncFormatter(lambda y, _: ''. Right click on the columns that are in the graph. # Creating the plot that will show survival % per age group and genderĪx = survival_per_age_ot(kind='bar', color='green')Īx.set_title("Survivors by Age Group", fontsize=14, fontweight='bold') Then you can plot your graph as follows: survival_per_age_group = oupby('AgeGroup').mean() The graph would end up actually looking something like this:įirst of all it would be better if you create a function that splits your data in age groups # This function splits our data frame in predifined age groups The following bins look to be 90%, 50%, 10% respectively, and so on. I would like this bin to line up against the y-axis at 65%. To select or deselect a range of adjacent rows or columns, hold down the Shift key and click the first and last row or column in the range. ![]() For adjacent bars, hold down the Shift key and double-click the right-most bar. The first bin on the graph shows roughly 65% survived in that age group. For non-adjacent bars, hold down the Ctrl key, click the non-adjacent bars, and then double-click one bar. Rather than alter the y-axis values, I'm looking to change the actual shape of the bars based on the percentage that survived. if a bin contained the ages between 10-20 years of age and 60% of people aboard the titanic in that age group survived, then the height would line up 60% along the y-axis.Įdit: I may have given a poor explanation to what I'm looking for. I would like to alter the chart to show a single chart per bin of the percentage in that age group that survived. I've plotted a stacked histogram which shows ages that survived and died upon the titanic. ![]() Specifically I'm dealing with the Kaggle Titanic dataset. ![]()
0 Comments
Leave a Reply. |