I'm new to data analysis using python and I'm trying to create a very basic visualization of some Premier League football data. One of these visualizations is the number of corners per home team in the 2018/19 Season.
I've managed to plot the graph I'm looking for, but the names on the X-axis are all over each other and, therefore, unreadable, as seen below:
import pandas as pd
import seaborn as sb
dataset = pd.read_csv("/Users/lfarias/Downloads/england-premier-league-matches-2018-to-2019-stats.csv")
dataset.columns
cantos = sb.barplot(x = 'home_team_name', y = 'home_team_corner_count', data = dataset)
cantos.tick_params(labelsize=14)
cantos.set_ylabel("Número de escanteios",fontsize=15)
cantos.set_xlabel("",fontsize=1)
Is there any way I can fix this?
P.S.: I've seen another question similar to the one I'm asking, but it ended up not being useful to me.
Thanks in advance.
CodePudding user response:
You can rotate the x-tick labels; this will produce a nicer-looking plot than if you just widen the bars enough to make the text not overlap.
Just change the rotation
value until you find an angle you like. horizontalalignment
can also be set to right
or left
.
cantos.set_xticklabels(cantos.get_xticklabels(), rotation = 45, horizontalalignment = 'center')