Search code examples
pythonmatplotlibcolor-mapping

Unrepeated colors in multiple line plots using matplotlib


I have 20 columns to plot using unrepeated colors. I would like to use tab20 color map. How do I use it?

I am finding all the online resources difficult to understand as I am still naive Python user.


Solution

  • In general this is how you can do it:

    import matplotlib
    cmap = matplotlib.cm.get_cmap(your_cmap) #your_cmap='tab20'
    df.plot(cmap=cmap)
    plot.show()
    

    Here you can find the references: https://matplotlib.org/examples/color/colormaps_reference.html