ggplot2 line graph - scaled?

28 views
Skip to first unread message

Lighton Phiri

unread,
Dec 11, 2012, 1:10:13 PM12/11/12
to ggp...@googlegroups.com
I am having trouble telling ggplot2 to graph this dataset [1]. The
resulting plot [2] is nothing compared to what I get [3] when I use R
base graphics.

I suspect ggplot2 is automatically scaling the data; how do I go about
getting the results I get when I use base graphics?

ggplot2 code


[1] See attachement (dataset.dat)
[2] See attachment (ggplot2-graphics.png)
[3] See attachment (base-graphics.png)

Lighton Phiri
http://lightonphiri.org
ggplot2-graphics.png
base-graphics.png
dataset.dat

Lighton Phiri

unread,
Dec 11, 2012, 1:11:31 PM12/11/12
to ggp...@googlegroups.com
Accidentally hit the send button before I finished writing... the
ggplot2 code I used is below

ggplot(data=info, aes(x=Workload, y=value, color=variable)) +
geom_line(aes(group=variable)) + geom_point()
Lighton Phiri
http://lightonphiri.org

baptiste auguie

unread,
Dec 11, 2012, 1:21:49 PM12/11/12
to Lighton Phiri, ggp...@googlegroups.com
Your base graphic seems to use a log scale for the x axis.

HTH,

b.

--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility

To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2

Lighton Phiri

unread,
Dec 11, 2012, 1:37:40 PM12/11/12
to baptiste auguie, ggplot2
Is there a way around getting ggplot2 do what base graphics are doing?
Incidentally, using LibreOffice Impress results in a plot similar to
that of base graphics...
Lighton Phiri
http://lightonphiri.org

adam.l...@pnc.com

unread,
Dec 11, 2012, 1:49:49 PM12/11/12
to Lighton Phiri, ggp...@googlegroups.com
Here's the easiest way....

ggplot(data=tst.melt, aes(x=as.factor(Workload), y=value, color=variable)) +
+ geom_line(aes(group=variable)) + geom_point()



Adam Loveland




From: Lighton Phiri <lighto...@gmail.com>
To: baptiste auguie <baptist...@gmail.com>
Cc: ggplot2 <ggp...@googlegroups.com>
Date: 12/11/2012 01:37 PM
Subject: Re: ggplot2 line graph - scaled?
Sent by: ggp...@googlegroups.com



The contents of this email are the property of PNC. If it was not addressed to you, you have no legal right to read it. If you think you received it in error, please notify the sender. Do not forward or copy without permission of the sender. This message may contain an advertisement of a product or service and thus may constitute a commercial electronic mail message under US Law. The postal address for PNC is 249 Fifth Avenue, Pittsburgh, PA 15222. If you do not wish to receive any additional advertising or promotional messages from PNC at this e-mail address, click here to unsubscribe. https://pnc.p.delivery.net/m/u/pnc/uni/p.asp
By unsubscribing to this message, you will be unsubscribed from all advertising or promotional messages from PNC. Removing your e-mail address from this mailing list will not affect your subscription to alerts, e-newsletters or account servicing e-mails.


Lighton Phiri

unread,
Dec 11, 2012, 1:59:49 PM12/11/12
to adam.l...@pnc.com, ggplot2
Neat! Exactly what I wanted --thank you very much Adam. I am curious as to why ggplot2 behaves like it did by default though...

Ista Zahn

unread,
Dec 11, 2012, 2:09:57 PM12/11/12
to Lighton Phiri, adam.l...@pnc.com, ggplot2
On Tue, Dec 11, 2012 at 1:59 PM, Lighton Phiri <lighto...@gmail.com> wrote:
>
> Neat! Exactly what I wanted --thank you very much Adam. I am curious as to
> why ggplot2 behaves like it did by default though...

ggplot2 is not doing anything unusual. You mapped a numeric vector on
the x axis, and did not change the default x-axis scale, so you got a
plot where the x-axis intervals map to the numeric difference between
each successive x-axis value. If that's not what you want you can
change it--either by telling ggplot to ignore the numeric values of
Workload (as Adam suggested) or by using a log scale (as baptiste
suggested)--but it is the reasonable default.

Best,
Ista

Lighton Phiri

unread,
Dec 11, 2012, 2:19:57 PM12/11/12
to Ista Zahn, adam.l...@pnc.com, ggplot2
That makes sense, thank you for this.
Lighton Phiri
http://lightonphiri.org
Reply all
Reply to author
Forward
0 new messages