Sponsored Content
Top Forums Programming Adding labels on the scatterplot with R Post 302960831 by avina on Friday 20th of November 2015 01:54:46 AM
Old 11-20-2015
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")

 

5 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Tape labels

Hello using solaris 2.6 I need to know how to find out the name of DLT tapes connected to the box as dev0. It tried somethings along the lines on mt stat but to no avail. If anyone can help It would be a great help. Thanks Jonathan (1 Reply)
Discussion started by: Jonathan
1 Replies

2. UNIX for Dummies Questions & Answers

Creating mailing labels using gawk!

Hello, I've got another thread going in this forum section about calculating a particular field of data using a gawk script, but I need help on another issue. I need to create mailing labels using a gawk script on a data file that looks like this: Doe|John|12345 Main... (2 Replies)
Discussion started by: Trellot
2 Replies

3. Programming

Locally Declared Labels

Hi guys. in the Locally Declared Labels section in "The Definitive Guide to GCC" book there is block of code: #define SEARCH(array, target) ({ __label__ found; typeof (target) _SEARCH_target = (target); typeof (*(array)) *_SEARCH_array = (array); int i, j; int value;... (1 Reply)
Discussion started by: majid.merkava
1 Replies

4. UNIX for Dummies Questions & Answers

Labels in VI

Hi, Is there a concept of lables in vi editor. In mainframes ISPF editor there is a concept of labels where one can label a line say ".a" and after that wherever you are in the file, if one want to go back to that particular line where the label was set...he could do by "l .a"....Is there... (1 Reply)
Discussion started by: whoami191
1 Replies

5. Shell Programming and Scripting

Sum elements of 2 arrays excluding labels

I'm looking for an efficient way to sum elements from 2 arrays using AWK and preserve header as well as sample names in the output array. I have Ubuntu 16.04 LTS. For example; ARRAY 1 SAMPLE DERIVED ANCESTRAL Sample1 14352 0 Sample2 14352 0 Sample3 14352 0 Sample4 ... (8 Replies)
Discussion started by: Geneanalyst
8 Replies
Gtk2::PageSetup(3)					User Contributed Perl Documentation					Gtk2::PageSetup(3)

NAME
Gtk2::PageSetup HIERARCHY
Glib::Object +----Gtk2::PageSetup METHODS
pagesetup = Gtk2::PageSetup->new pagesetup = Gtk2::PageSetup->new_from_file ($file_name) o $file_name (localized file name) May croak with a Glib::Error in $@ on failure. Since: gtk+ 2.12 pagesetup = Gtk2::PageSetup->new_from_key_file ($key_file, $group_name) o $key_file (Glib::KeyFile) o $group_name (string or undef) May croak with a Glib::Error in $@ on failure. Since: gtk+ 2.12 double = $setup->get_bottom_margin ($unit) o $unit (Gtk2::Unit) $setup->set_bottom_margin ($margin, $unit) o $margin (double) o $unit (Gtk2::Unit) double = $setup->get_left_margin ($unit) o $unit (Gtk2::Unit) $setup->set_left_margin ($margin, $unit) o $margin (double) o $unit (Gtk2::Unit) $setup->load_file ($file_name) o $file_name (string) May croak with a Glib::Error in $@ on failure. Since: gtk+ 2.14 $setup->load_key_file ($key_file, $group_name) o $key_file (Glib::KeyFile) o $group_name (string or undef) May croak with a Glib::Error in $@ on failure. Since: gtk+ 2.14 pageorientation = $setup->get_orientation $setup->set_orientation ($orientation) o $orientation (Gtk2::PageOrientation) double = $setup->get_page_height ($unit) o $unit (Gtk2::Unit) double = $setup->get_page_width ($unit) o $unit (Gtk2::Unit) double = $setup->get_paper_height ($unit) o $unit (Gtk2::Unit) $setup->set_paper_size_and_default_margins ($size) o $size (Gtk2::PaperSize) papersize = $setup->get_paper_size $setup->set_paper_size ($size) o $size (Gtk2::PaperSize) double = $setup->get_paper_width ($unit) o $unit (Gtk2::Unit) double = $setup->get_right_margin ($unit) o $unit (Gtk2::Unit) $setup->set_right_margin ($margin, $unit) o $margin (double) o $unit (Gtk2::Unit) $setup->to_file ($file_name) o $file_name (localized file name) May croak with a Glib::Error in $@ on failure. Since: gtk+ 2.12 $setup->to_key_file ($key_file, $group_name) o $key_file (Glib::KeyFile) o $group_name (string or undef) Since: gtk+ 2.12 double = $setup->get_top_margin ($unit) o $unit (Gtk2::Unit) $setup->set_top_margin ($margin, $unit) o $margin (double) o $unit (Gtk2::Unit) ENUMS AND FLAGS
enum Gtk2::PageOrientation o 'portrait' / 'GTK_PAGE_ORIENTATION_PORTRAIT' o 'landscape' / 'GTK_PAGE_ORIENTATION_LANDSCAPE' o 'reverse-portrait' / 'GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT' o 'reverse-landscape' / 'GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE' enum Gtk2::Unit o 'pixel' / 'GTK_UNIT_PIXEL' o 'points' / 'GTK_UNIT_POINTS' o 'inch' / 'GTK_UNIT_INCH' o 'mm' / 'GTK_UNIT_MM' SEE ALSO
Gtk2, Glib::Object COPYRIGHT
Copyright (C) 2003-2008 by the gtk2-perl team. This software is licensed under the LGPL. See Gtk2 for a full notice. perl v5.12.1 2010-07-05 Gtk2::PageSetup(3)
All times are GMT -4. The time now is 08:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy