[R] Datetime misrepresented on x-axis of a multiple plot: Problem Fixd

Ogbos Okike g||ted|||e2014 @end|ng |rom gm@||@com
Sat May 2 04:36:32 CEST 2020


Dear Jim and Rolf Turner,
This is great!!!!!!!!!!!!!!!!
The labels on x-axis are now correctly displayed. Jim, your singular code:
axis.POSIXct(1,dta$datetime,format="%a")
made all the required adjustment, making life quite easy for me.

The abline commands are indeed meant to draw a common vertical line across
the different panels. I have quickly achieved that with:
abline(v=as.POSIXct("1978-09-29 00:00:00"))

I have successfully added the rest of the data, displaying seven/more
variables on a single plot and using some common vertical lines to indicate
the variations in several solar wind plasma data/cosmic rays at Earth at
the time of coronal mass ejections from the sun. It makes an interesting
plot to those in our field.

Confusion or "misleading impressions" do not arise at all as the data used
as well as date plotted are usually online for easy verification by
experts/anyone.

Many thanks for all your contributions.

Warmest regards
Ogbos



On Fri, May 1, 2020 at 11:47 PM Jim Lemon <drjimlemon using gmail.com> wrote:

> Hi Ogbos,
> The following code may get you close to what you want. I have used the
> names of the columns in "dta" as it is less confusing for me. I think
> you meant to request horizontal ablines as none appeared in the
> example. In order to get the axis tick label "Sun" you would have to
> increase the x axis limits beyond your data.
>
> plot(dta$datetime,dta$B,type="l",axes=FALSE)
> # this is out of range and doesn't appear
> abline(h=-3,col="red")
> axis(2)
> plot(dta$datetime,dta$LAT,type="l",axes=FALSE)
> abline(h=-3,col="red")
> axis(2)
> plot(dta$datetime,dta$BX,type="l",axes=FALSE)
> abline(h=-3,col="red")
> axis(2)
> axis.POSIXct(1,dta$datetime,format="%a")
> mtext("A1", side = 1, outer = TRUE, line = 2.2)
> mtext("B1", side = 2, outer = TRUE, line = 2.2,at =0.2)
> mtext("B2", side = 2, outer = TRUE, line = 2.2,at =0.5)
> mtext("B2", side = 2, outer = TRUE, line = 2.2,at =0.8)
>
> Jim
>
> On Sat, May 2, 2020 at 2:47 AM Ogbos Okike <giftedlife2014 using gmail.com>
> wrote:
> >
> > Dear Contributors,
> > I am trying to do a plot with multiple y-axis on a common x-axis. I have
> > made some progress but I am having difficulties with datetime appearing
> on
> > x-axis. Instead of as date, it appears as large numbers.
> > ...
> > If I do a simple plot of x and B, the x-axis will be fine, appearing as
> > Thu, Fri, Sat, Sun.
> > Please let me know what I am doing wrong with the multiple plot code
> above.
> > I want the same Thu, Fri, Sat, Sun to appear on the common x-axis.
> >
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list