[R] Scale y-labels based on a value with 'lattice'
Duncan Mackay
dulcalma at bigpond.com
Fri May 27 07:51:11 CEST 2016
Hi
If you want to change the cex of the labels see
library(lattice)
?yscale.components.default
Possibly an easier way is to size the symbols
I will use Jims data.frame to plot with lattice
dotplot(Group.2 ~ x, data = kedf,
scales = list(y = list(labels = kedf[,"Group2"], cex = = kedf[,"Freq"])))
If you want to magnify the size of the symbol according to Freq
dotplot(Group.2 ~ x, data = kedf,
cex = kedf[,"Freq"])
or with modifications
dotplot(Group.2 ~ x, data = kedf,
col = "black",
pch = 15,
cex = kedf[,"Freq"])
If you wanted to go further
dotplot(Group.2 ~ x, data = kedf,
par.settings = list(dot.symbol = list(col = "black",
pch = 15) ),
cex = kedf[,"Freq"])
without further work cex will not work as it is in par settings
Regards
Duncan
Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mackay at northnet.com.au
-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of K. Elo
Sent: Friday, 27 May 2016 00:52
To: r-help at r-project.org
Subject: [R] Scale y-labels based on a value with 'lattice'
Dear R-helpers!
I have a data frame storing data for word co-occurrences, average
distances and co-occurence frequency:
Group.1 Group.2 x Freq
1 deutschland achtziger 2.00 1
2 deutschland alt 1.25 4
3 deutschland anfang -2.00 1
4 deutschland ansehen 1.00 2
5 deutschland arbeit 0.50 2
6 deutschland arbeitslos -2.00 1
Now I want to plot a lattice 'dotplot' with the formula 'Group.2~x'.
This works fine.
However, I would like to scale the y-label (based on 'Group.2' according
the 'Freq' value using a log-scaled value (log(Freq+.5)). In other
words: the higher the 'Freq' value of a term, the bigger its label
should be printed in my dotplot.
The problem is that I cannot figure out how to tell lattice to scale
each y-label with according 'Freq' value. I am quite sure I should build
a function for scales=list(y=...), but I don't know how to it.
Many thanks in advance for your help!
Best,
Kimmo Elo
--
Åbo Akademi University / German studies
Turku, Finland
______________________________________________
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list