Semantic differential: Labels for secondary axis

1,326 views
Skip to first unread message

igreg

unread,
Mar 20, 2012, 6:18:50 PM3/20/12
to ggplot2
dear ggploters

i would like to plot a semantic differential with ggplot2.

http://en.wikipedia.org/wiki/Semantic_differential

my example:

library (ggplot2)
library (scales)
library (grid)

positive <- rep(c("hot","good","wet"),4)
negative <- rep(c("cold","bad","dry"),4)
brands <- rep(c("Audi","Mercedes","BMW","Fiat"),3)
values <- c(5.5,4,6,3,4.5,2,6,3.2,4.7,3.9,2.8,1.9)
df <- data.frame (cbind (positive,negative,brands,values))
df <- df[order(brands) ,]


pl <- ggplot(df, aes(x=positive, y=values, colour=brands))
pl <- pl + geom_line(aes(group=brands))
pl <- pl + geom_point(size=4)
pl <- pl + opts(legend.position = "bottom")
pl <- pl + coord_flip ()
pl

question:

how to label the axis on the right side with the "negativ"
concepts... ? the concepts should appear in the same font/size etc.

any ideas?
thanks, greg

Kohske Takahashi

unread,
Mar 21, 2012, 1:34:52 AM3/21/12
to igreg, ggplot2
In the future version you may do like:

positive <- c("hot","good","wet")
negative <- c("cold","bad","dry")
Q <- gl(3, 4)


brands <- rep(c("Audi","Mercedes","BMW","Fiat"),3)
values <- c(5.5,4,6,3,4.5,2,6,3.2,4.7,3.9,2.8,1.9)

df <- data.frame (Q,brands,values)

ggplot(df, aes(values, Q, colour = brands, group = brands)) + geom_path() +
scale_y_discrete(guide = list(
guide_axis(label = positive),
guide_axis(position = "right", label = negative))) +
guides(colour = guide_legend())

This is under development.

If you want to use, try installing from github:

install.packages('dev_tools")
dev_mode()
install_github("ggplot2", "kohske", "feature/pguide")

Note that I cannot make sure if all things work.

kohske

2012年3月21日7:18 igreg <zoor...@gmx.net>:


>
> positive <- rep(c("hot","good","wet"),4)
> negative <- rep(c("cold","bad","dry"),4)
> brands <- rep(c("Audi","Mercedes","BMW","Fiat"),3)
> values <- c(5.5,4,6,3,4.5,2,6,3.2,4.7,3.9,2.8,1.9)
> df <- data.frame (cbind (positive,negative,brands,values))

--
--
Kohske Takahashi <takahash...@gmail.com>

Research Center for Advanced Science and Technology,
The University of Tokyo, Japan.
http://www.fennel.rcast.u-tokyo.ac.jp/profilee_ktakahashi.html

plot.png

igreg

unread,
Mar 21, 2012, 6:45:54 AM3/21/12
to ggplot2

Kohske! you are my hero :-)
that's exactly what I need!

i will try to install the dev version...
and hope to see your developments soon in the next release version of
ggplot2...

thank you. greg

Timothy Bates

unread,
Mar 21, 2012, 8:59:55 AM3/21/12
to ggplot2
hi Kohske,

Is dev_tools itself available (OS X)?

install.packages('dev_tools')
Warning message:
In getDependencies(pkgs, dependencies, available, lib) :
package ‘dev_tools’ is not available (for R version 2.14.1)

> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
> <plot.png>

R. Michael Weylandt

unread,
Mar 21, 2012, 9:13:26 AM3/21/12
to Timothy Bates, ggplot2
I'd guess that was a typo and Koshke meant devtools which is on CRAN.

Michael

Reply all
Reply to author
Forward
0 new messages