Tam Le
2010-Feb-02 01:25 UTC
[R] Plot questions: grid line do not correspond to tick marks and 2 line axis label
Hello list, Thank you very much for replying to my earlier questions. I have a few new questions about R plots: Example: tempdata: RDate Price 2009-12-09 12:00 100 2009-12-09 15:00 99 2009-12-09 18:00 102 .... 2009-12-10 8:00 120 2009-12-10 10:00 110 2009-12-10 16:00 105 My code: (RDate already in R date-time class) plot (price~RDate, data=tempdata, "l") axis.POSIXct(1, at=seq(min(data$RDate), max(data$RDate)+60, by="3 hours"), format="%H:%M") grid(lwd=1) 1. The default grid lines do not seem to correspond with the ticks in my axis. Grid has options for absolute numbers of grid lines, but I would not want to paste an absolute number here, as I don't know the number of ticks generated by seq. 2. The tick label on the x axis should be in 2 lines. My x axis is the time and date (2009/12/09 12:00), I want to show the time on the first line and some of the dates on the second, visually as below: -------|----------------|------------------|------------------------ 12:00 15:00 18:00 12/09 12/09 How should I specify this? 3. I don't want line to automatically connect the between the missing periods, i.e., suppose my data was hourly from 12/09 to 12/10, but there is no data between 2009-12-09 18:00 and 2009-12-10 8:00, the two data points at these dates should not be connected. 4. I would like to label the uppermost values of the axes, which R does not seem to label. 5. Is there a graphic package where perhaps all these details have been figured out? Thank you very much for your help! Tam [[alternative HTML version deleted]]
Reasonably Related Threads
- Plot: Distance between tick and tick label on y-axis
- in axis() suppressing axis line but keeping tick marks
- [ggplot] controlling axis and major/minor tick marks
- Lattice graphics: minor tick marks and panel.axis() question(s)
- [R] grid(): defaults of nx and ny do not correspond with axis() (PR#2282)