r - Plot histograms as lines -
i want plot several histograms of time data (1 week long) on same plot lines.
i have time data:
> dput(head(ts)) structure(c(1364421605.227, 1364375025.034, 1364376298.393, 1364375002.928, 1364393158.084, 1364423268.856), class = c("posixct", "posixt"))
and want plot histogram. hist(ts,breaks=7*24)
works fine, uses h
plot type obscure other histogram plots want add (i know can use transparent colors - rainbow
alpha=0.5
, want see lines).
i tried
> hist(ts, breaks = 7*24, type="l") warning messages: 1: in title(main = main, sub = sub, xlab = xlab, ylab = ylab, ...) : graphical parameter "type" obsolete calls: hist -> hist.posixt -> myplot -> plot -> plot.histogram -> title 2: in axis(2, ...) : graphical parameter "type" obsolete calls: hist -> hist.posixt -> myplot -> axis 3: in axis(side, @ = z, labels = labels, ...) : graphical parameter "type" obsolete calls: hist -> hist.posixt -> myplot -> axis.posixct -> axis
why hist
passing type
title
?
i can create histogram object , plot separately:
> h <- hist(ts, breaks=7*24, plot=false) > plot(x=h$mids, y=h$density, type="l")
but x
axis labeled numbers (e.d., "1364421605") not dates (e.g., "mar 25").
i guess supposed use axis
, rather not handle myself - after all, hist
constructs axis want!
thanks!
the following looks weird because gave 6 data points in dput
. can plot line plot without x-axis , add afterwards so:
h <- hist(ts, breaks=7*24, plot=false) plot(x=h$mids, y=h$density, type="l", xaxt="n") axis(1,at=ts,labels=format(ts,"%b-%d"))
Comments
Post a Comment