Skip to content
Advertisement

Add x and y labels to a pandas plot

Suppose I have the following code that plots something very simple using pandas:

JavaScript

Output

How do I easily set x and y-labels while preserving my ability to use specific colormaps? I noticed that the plot() wrapper for pandas DataFrames doesn’t take any parameters specific for that.

Advertisement

Answer

In Pandas version 1.10 you can use parameters xlabel and ylabel in the method plot:

JavaScript

enter image description here

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement