Define the color palette of your plots
When visualizing multiple time series, it can be difficult to differentiate between various colors in the default color scheme.
To remedy this, you can define each color manually, but this may be time-consuming. Fortunately, it is possible to leverage the colormap
argument to .plot()
to automatically assign specific color palettes with varying contrasts. You can either provide a matplotlib colormap
as an input to this parameter, or provide one of the default strings that is available in the colormap()
function available in matplotlib
(all of which are available here).
For example, you can specify the 'viridis'
colormap using the following command:
df.plot(colormap='viridis')
This exercise is part of the course
Visualizing Time Series Data in Python
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Plot time series dataset using the cubehelix color palette
ax = meat.plot(colormap=____, fontsize=15)
# Additional customizations
ax.set_xlabel('Date')
ax.legend(fontsize=18)
# Show plot
plt.show()