Unix/Linux Go Back    


Programming Post questions about C, C++, Java, SQL, and other programming languages here.

Adding labels on the scatterplot with R

Programming


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 11-20-2015   -   Original Discussion by avina
avina's Unix or Linux Image
avina avina is offline
Registered User
 
Join Date: Nov 2015
Last Activity: 20 November 2015, 2:21 AM EST
Posts: 3
Thanks: 1
Thanked 1 Time in 1 Post
Adding labels on the scatterplot with R

I would like to label points on a scatterplot. I used the following code.


Code:
d1 <- structure(list(x1 = c(31.7858,25.8623,23.7758,30.1564,28.179,25.3966,31.5879,40.3233,28.8774,27.4434,37.6055,38.2847,40.5864,38.586,32.5489,38.2273,45.6876,52.3452,42.6654,49.8273), y1 = c(3.62,2.38,1.98,2.71,2.25,2.37,2.28,2.30,3.06,2.22,2.66,2.83,4.16,2.83,3.10,3.00,4.52,5.61,3.95,6.45)), .Names = c("x1", "y1"), class = "data.frame", row.names = c(NA, 
-20L))
d2 <- structure(list(x2 = c(22.5824,17.8283,21.4613,20.0485,24.5318,23.0919,23.3925,27.2867,23.7026,23.7338,25.4886,26.7058,25.6673,24.991,25.2346,18.7816,26.2372,25.9479,25.819,25.1697), y2 = c(2.12,1.55,1.65,1.52,1.80,1.77,1.68,1.46,2.05,1.63,1.59,1.85,2.53,1.98,2.32,1.66,2.09,2.51,2.25,2.54)), .Names = c("x2", "y2"), class = "data.frame", row.names = c(NA, -20L))
library(reshape2)
library(ggplot2)
names(d2) <- c("x1", "y2")
df <- rbind(melt(d1, id.vars = "x1"), melt(d2, id.vars = "x1"))
ggplot(df, aes(x1, y = value, colour = variable)) + 
  geom_point() + labs(x = "x", y = "y") +
  scale_colour_manual(values = c("red", "blue"), labels = c("d1", "d2"))

How can I label the points?


Code:
labels=c("L", "K", "D", "E", "N", "Q", "S", "G", "H", "W" , "A", "P", "Y", "V", "M", "C", "R", "F", "I", "T")

Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Labels in VI whoami191 UNIX for Dummies Questions & Answers 1 03-29-2012 08:10 PM
Locally Declared Labels majid.merkava Programming 1 09-23-2010 05:47 AM
Tape labels Jonathan UNIX for Dummies Questions & Answers 1 07-25-2002 10:50 PM



All times are GMT -4. The time now is 12:22 AM.