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

Label points in geom_point

Asked by David Piper Jul 12, 2021 775 views 1 answer
Share

About this question

 The data I'm playing with comes from the internet source listed below

nba <- read.csv("http://datasets.flowingdata.com/ppg2008.csv", sep=",")

What I want to do, is create a 2D points graph comparing two metrics from this table, with each player representing a dot on the graph. I have the following code:

nbaplot <- ggplot(nba, aes(x= MIN, y= PTS, colour="green", label=Name)) + 
                  geom_point() 

This gives me the following:

NBA Plot

What I want is a label of the player's name right next to the dots. I thought the label function in ggplot's aesthetics would do this for me, but it didn't.

I also tried text() function and the textxy() function from the library(calibrate), neither of which appears to work with ggplot.

How can I add name labels to these points?

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.