One thing I need to do is to plot the time span (in years) for each
single type of pottery ("Tipo" is a factor in my data frame), and I
found that geom_rect is what I should use, because I have xmin
(beginning of production) and xmax values (end of production). The
problem comes out with ymin and ymax.
http://bitbucket.org/steko/pottery-ggplot2/src/d0a1742356f2/durata_forme.r
here is my script, I have tried using
ymin = Tipo, ymax = Tipo + 1
ymin = factor(Tipo), ymax = factor(Tipo)
and others, including the current version
ggplot(tsa) + geom_rect(aes(xmin=cron_inizio, xmax=cron_fine,
ymin=reorder(Tipo, cron_inizio), ymax=reorder(Tipo,cron_inizio),
alpha=1, colour="red", size=2)) + theme_bw()
So far, the only part of this that is working is colour="red" (it
draws the rectangle borders as a single segment), but I need to have a
true rectangle and not a straight line. Data is like the sample at
http://pastebin.com/NCKBzwtX
Thanks,
Stefano
ggplot(tsa) +
geom_segment(aes(x=cron_inizio, xend=cron_fine,
y=reorder(Tipo, cron_inizio),
yend=reorder(Tipo,cron_inizio)),
alpha=1, colour="red", size=4)+
theme_bw()
--
Ben Bolker
Associate professor, Biology Dep't, Univ. of Florida
bol...@ufl.edu / people.biology.ufl.edu/bolker
GPG key: people.biology.ufl.edu/bolker/benbolker-publickey.asc
Yes, geom_segment is what I need, rather than geom_rect. Now I have to
play with my data and the options a little further, because apparently
different types are plotted on the same "row". Thanks!
Ciao,
Stefano
tsa <- na.omit(tsa)
ggplot(tsa) +
geom_segment(aes(x=cron_inizio, xend=cron_fine,
y=reorder(Tipo,cron_inizio),
yend=reorder(Tipo,cron_inizio)),
alpha = 1, size=2, fill="#ff0000") +
opts(title="Arco cronologico dei tipi") +
xlab("Cronologia") +
ylab("Tipi") +
theme_bw()
Your suggestion pretty worked good!
Ciao,
Stefano