Cleveland Dot Plots

Cleveland Dot Plot

matplotlib
plt.figure(figsize=(20,10))
plt.hlines(y=my_range, xmin=0, xmax=df['fare'], color='skyblue')
plt.grid(True)
plt.plot(df['fare'], my_range, "o")
plt.yticks(my_range, df['name'])
plt.title("Ticket Price Dot Plot", loc='left')
plt.xlabel('Ticket Price')
plt.ylabel('Name')

png

Multiple Dots

matplotlib

Sorting has to be done through dataframe only.

plt.figure(figsize=(20,10))
plt.hlines(y=my_range, xmin=0, xmax=df['fare'], color='skyblue')
plt.hlines(y=my_range, xmin=0, xmax=df['age'], color='red')

plt.grid(True)
plt.plot(df['fare'], my_range, "o")
plt.plot(df['age'], my_range, "o")

plt.yticks(my_range, ordered_df['name'])
plt.title("Ticket Price Dot Plot", loc='left')
plt.xlabel('Ticket Price')
plt.ylabel('Name')

png