Use parameter cmap to assign the color map to be used.Use parameter c from the scatter method to assign the color sequence.Take the day category as a parameter, so the corresponding color can be mapped.To paint each dot according to its day category I need to introduce a few new components in the code Pick the colors yourself using tools like Adobe Kuler’s color wheel.Since we have the day category we can also try identifying each dot in our plot with a different color.įor that you can choose from two different approaches: There is still a bit of overlap, but at least the transparency improved the readability of the majority of the dots. ![]() ![]() ![]() Import pandas as pd import matplotlib.pyplot as plt #loading dataset df = pd.read_csv(‘workout_log.csv’) df.columns = def scatterplot(df, x_dim, y_dim): x = df y = df fig, ax = plt.subplots(figsize=(10, 5)) #customizes alpha for each dot in the scatter plot ax.scatter(x, y, alpha=0.70) #adds a title and axes labels ax.set_title('Distance vs Workout Duration') ax.set_xlabel('Distance (Km)') ax.set_ylabel('Workout Duration (min)') #removing top and right borders ax.t_visible(False) ax.t_visible(False) #adds major gridlines ax.grid(color='grey', linestyle='-', linewidth=0.25, alpha=0.5) plt.show() scatterplot(df, ‘distance_km’, ‘duration_min’)
0 Comments
Leave a Reply. |