Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Python
  3. Question
Python

15- Add x and y labels to a pandas plot

Asked by Ava Black May 20, 2021 1.3K views 1 answer
Share

About this question

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

 import pandas as pd
values = [[1, 2], [2, 5]]
df2 = pd.DataFrame(values, columns=['Type A', 'Type B'], 
                   index=['Index 1', 'Index 2'])
df2.plot(lw=2, colormap='jet', marker='.', markersize=10, 
         title='Video streaming dropout by category')

image

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 to that.

Your answer

1 Answer

More Python discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Python Blogs

Guides, tips and career advice on Python from JanBask experts.