[r] How can I label points in this scatterplot?

Can you help me on putting labels on the following graph?

http://img849.imageshack.us/img849/7594/snap1034.png

The code i use is:

valbanks<-scan("banks.txt", what=list(0,0,""), sep="", skip=1, comment.char="#")
valbanks

valj2007<-valbanks[[1]]
valj2009<-valbanks[[2]]
namebank<-valbanks[[3]]

percent_losses<-(valj2009-valj2007)/valj2007
percent_losses

abs_losses<-(valj2007-valj2009)
abs_losses

plot(abs_losses, percent_losses,main="Absolute Losses vs. Relative Losses(in%)",xlab="Losses (absolute, in miles of millions)",ylab="Losses relative (in % of January´2007 value",col="blue", pch = 19, cex = 1, lty = "solid", lwd = 2,text(percet_losses, abs_losses,namebank))

text(percet_losses, abs_losses,labels=namebank, cex= 0.7, offset = 10)

and the data is:

Value_Jan_2007  Value_Jan_2009  Bank    #
49  16  Morgan_Stanley
120 4.6 RBS
76  10.3    Deutsche_Bank
67  17  Credit_Agricole
80  26  Societé_Generale
91  7.4 Barclays
108 32.5    BNP-Paribas
93  26  Unicredit
116 35  UBS
75 27   Credit_Suise
100 35  Goldman_Sachs
116 64  Santander
255 19  Citigroup
165 85  JP_Morgan
215 97  HSBC

Thank you very much

What is the option to put the label at the bottom, right, up, left,... ?

Summarizing: I want a graph similar that the one that is in the second message from this post but there is no the code there.

What code i have to put?


if i put text(percet_losses, abs_losses,namebank), i obtain nothing: the graph continue without changes.

Could you show me the code i need to put?

Thanks

This question is related to r label point scatter-plot

The answer is


You should use labels attribute inside plot function and the value of this attribute should be the vector containing the values that you want for each point to have.


I have tried directlabels package for putting text labels. In the case of scatter plots it's not still perfect, but much better than manually adjusting the positions, specially in the cases that you are preparing the draft plots and not the final one - so you need to change and make plot again and again -.


For just plotting a vector, you should use the following command:

text(your.vector, labels=your.labels, cex= labels.size, pos=labels.position)

Examples related to r

How to get AIC from Conway–Maxwell-Poisson regression via COM-poisson package in R? R : how to simply repeat a command? session not created: This version of ChromeDriver only supports Chrome version 74 error with ChromeDriver Chrome using Selenium How to show code but hide output in RMarkdown? remove kernel on jupyter notebook Function to calculate R2 (R-squared) in R Center Plot title in ggplot2 R ggplot2: stat_count() must not be used with a y aesthetic error in Bar graph R multiple conditions in if statement What does "The following object is masked from 'package:xxx'" mean?

Examples related to label

How to set label size in Bootstrap How do I change the text size in a label widget, python tkinter Change grid interval and specify tick labels in Matplotlib Editing legend (text) labels in ggplot How to change Label Value using javascript React ignores 'for' attribute of the label element How to dynamically update labels captions in VBA form? why I can't get value of label with jquery and javascript? What does "for" attribute do in HTML <label> tag? Get Application Name/ Label via ADB Shell or Terminal

Examples related to point

Pointtype command for gnuplot How can I label points in this scatterplot? Java: Calculating the angle between two points in degrees Convert Pixels to Points

Examples related to scatter-plot

Matplotlib scatter plot legend Matplotlib scatter plot with different text at each data point How can I label points in this scatterplot? How to change the font size and color of x-axis and y-axis label in a scatterplot with plot function in R? Setting different color for each series in scatter plot on matplotlib scatter plot in matplotlib How to do a scatter plot with empty circles in Python? Control the size of points in an R scatterplot? How to make a 3D scatter plot in Python?