Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of myshare
> Sent: Wednesday, May 13, 2009 5:59 PM
> To: r-help at r-project.org
> Subject: [R] plotting multiple data sources
>
> hi,
>
> Excuse me asking three questions in a row for a day, but I had
> collected those questions
> as I'm still experimenting with R.
> This one is how do you compose plots with alot of data in one graph.
> First what I currently do is after i generated all the data I need to
> plot.. let say 5-6 arrays
> I do a plot() and then I created a function to scale the other data to
> approx fit the initial range
> so it can fit plotted data and then draw it with lines().
>
> Here is the example function I use.
>
> Blah.scale_to_range = function(self,data,range_low=0,range_high,
> skip_cond=(data > 0) ) {
> ratio <- (range_high - range_low) / (max(data) - min(data))
> ((data - min(data)) * ratio) + (range_high - range_low)/2
> }
>
> so far so good.. the problem I have is that I want the x axis to be
> Date range.
> I can plot( x$date, x$values, type='l'), but then later if I want to
> plot the other data with lines()
> I can't plot them anymore, cause it seems that the lines() wants the
> other data X-axis values to
> be dates. I think I was able to draw them referencing the x$date i.e.
> something like this :
>
> lines(x$date,scaled_array1)
>
> but isn't there some easier way, especially if it can autoscale the
> new data too.
> Then my next question is how to change the axis labels so it does show
> x-axis label only every
> n-th tick.
> AFAIR I was able to force it to show date every tick with axis() and
> even positioned it vertically,
> but all the dates are overlapped..
> By default dates are very sparsed, so that is why I want to be able to
> control when
> the x-labels-dates to show up.
>
>
> thanx
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.