Q: Overlapping labels: how to group names on the same tick? I have been struggling with plots in Python and the problems of overlapping. I have a dataset similar to this:
ID  TV            Start
1  gameofthrones   21:34:00
2  beverlyhills    21:34:00
3  modernfamiily   00:34:00
4  housemd         01:34:00
5  hunters         01:34:00
4  housed          01:34:00
7  beautiful       01:34:00
8  theoffice       01:34:00
...
9  lacasadepapel   16:34:00
10 mrroobot        16:34:00

and when I plot it I get this awful result:

by using this code:
import matplotlib.pyplot as plt 

plt.figure(figsize=(16,8))
plt.plot(df['TV'],df['Start'])
plt.show()

I also tried to rotate labels (plt.xticks(rotation=70)): nothing, still horrible!
I have thought that probably, since there are a lot of TV series names having the same start time (on the x-axis they are ordered in terms of appearance, i.e. from 00:00 to 23:59), it could be a possible solution to group the TV names on the same time in a list in order to not visualise an overlap of names. But I do not know how to do it.
I am interested in any further suggestions for avoiding overlapping.

A: *

*Time is the independent variable and should be on the x-axis.  This will also resolve the issue with too many values on the x-axis.

*The Start column is a string not a datetime, so the plot api won't order them consecutively, therefore use sort_values.

*This is discrete, not continuous data, so it shouldn't be plotted with a line plot.


import pandas as pd
import seaborn as sns
import maplotlib.pyplot as plt

# plot config parameters
plt.rcParams['figure.figsize'] = (16.0, 10.0)
plt.style.use('ggplot')

# data
data = {'ID': [1, 2, 3, 4, 5, 4, 7, 8, 9, 10],
        'TV': ['gameofthrones', 'beverlyhills', 'modernfamiily', 'housemd', 'hunters', 'housed', 'beautiful', 'theoffice', 'lacasadepapel', 'mrroobot'],
        'Start': ['21:34:00', '21:34:00', '00:34:00', '01:34:00', '01:34:00', '01:34:00', '01:34:00', '01:34:00', '16:34:00', '16:34:00']}

# dataframe
df = pd.DataFrame(data)

# sort by Start
df.sort_values('Start', inplace=True)

# plot
p = sns.scatterplot('Start', 'TV', data=df)


