[R] [R studio] Plotting of line chart for each columns at 1 page
Subhamitra Patra
@ubh@mitr@@p@tr@ @ending from gm@il@com
Fri Dec 14 06:22:03 CET 2018
Dear Sir,
The method you suggested for arranging multiple plots in 1 pdf page has
finally worked.
Thank you very much.
But, I have 3 more queries as follows.
1. Is there any way that I can merge the respective plots from the
different excel files into 1? For instance, I have 3 excel files (i.e. EMs
1, EMs 2 and EMs 3) having 4 plots each. I want to merge 1st plots from 3
excel files into 1, 2nd plots from 3 excel files into 1, similarly 3rd and
4th plots from each respective files into 1?
2. Is there any way to range the scale of Y-axis for all plots because I
think if the range of the Y-axis for each plot is same, it can be easy to
interpret and compare the results. I used Ylim function. But, after using
the Ylim function, the plot is looking unclear than before. For your
convenience, I am providing my code.
pdf("EMs.pdf",width=20,height=20)
par(mfrow=c(5,4))
# import your first sheet here (38 columns)
ncolumns<-ncol(EMs1)
for(i in 1:ncolumns)
plot(EMs1[,i],type="l",col = "Red", xlab="Time",
ylab="APEn", ylim=c(0.1,2), main=names(EMs1)[i])
library(zoo)
*APEn=zoo(EMs1, seq(from = as.Date("1994-01-01"), to =
as.Date("2017-08-03"), by = 1))*
#import your second sheet here, (10 columns)
ncolumns<-ncol(EMs2)
for(i in 1:ncolumns)
plot(EMs2[,i],type="l",col = "Red", xlab="Time",
ylab="APEn",ylim=c(0.1,2), main=names(EMs2)[i])
*APEn=zoo(EMs2, seq(from = as.Date("1994-01-01"), to =
as.Date("2017-08-03"), by = 1))*
# import your Third sheet here, (2 columns)
ncolumns<-ncol(EMs3)
for(i in 1:ncolumns)
plot(EMs3[,i],type="l",col = "Red", xlab="Time",
ylab="APEn", ylim=c(0.1,2), main=names(EMs3)[i])
*APEn=zoo(EMs3, seq(from = as.Date("1996-01-01"), to =
as.Date("2017-08-03"), by = 1)) *
# finish plotting
dev.off()
3. I want the corresponding date column (which is the daily date) on X-axis
of each plot. Thus, I added 1 line after the plot in the above (i.e. the
bold line). Please suggest me Is it the correct way that I am doing?
Sir, I am new in R and doing by learning.
Kindly suggest me regarding my previous queries for which I shall be always
grateful to you.
Thank you very much for educating a new R learner.
On Wed, Nov 21, 2018 at 3:20 PM Subhamitra Patra <subhamitra.patra using gmail.com>
wrote:
> Thank you very much for your suggestions and help.
>
> [image: Mailtrack]
> <https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> Sender
> notified by
> Mailtrack
> <https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> 11/21/18,
> 3:19:55 PM
>
> On Wed, Nov 21, 2018 at 3:09 PM Subhamitra Patra <
> subhamitra.patra using gmail.com> wrote:
>
>> OK, Sir. I will try as per your suggestions.
>>
>> Thank you very much for your kind help.
>>
>> [image: Mailtrack]
>> <https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> Sender
>> notified by
>> Mailtrack
>> <https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> 11/21/18,
>> 3:07:47 PM
>>
>> On Wed, Nov 21, 2018 at 2:41 PM Jim Lemon <drjimlemon using gmail.com> wrote:
>>
>>> 1. xaxt="n" means "Don't display the X axis". See the help for "par" in
>>> the graphics package
>>>
>>> 2. axis(1,at=1:nrows,labels=names(MPG3))
>>> This means, "Display the bottom axis (1) with ticks at 1 to the number
>>> of rows in the data frame"
>>> "Use the values of MPG$Year as labels for the ticks". see the help for
>>> "axis" in the graphics package
>>> Note that this should be in the same loop as "plot"
>>>
>>> Now I can see that my guess at the structure of the data was wrong. What
>>> you could do is to collapse the daily records into the means for the years.
>>> As I don't know what your spreadsheet looks like, I could only guess a
>>> method for this.
>>>
>>> You seem to be saying that you plot all 5655 values, but you want the
>>> axis to show just the years.Rather than tell you to convert your data to a
>>> time series, I'll suggest a quick hack.
>>>
>>> axis(1,at=seq(1,5655,by=365),labels=1994:2014)
>>>
>>> This _may_ work for you. I offer it because I can see that you do not
>>> have a lot of experience in R and you want to get the job done. If you
>>> can't get it to work, I apologize and you can blamelessly move to something
>>> else.
>>>
>>> Jim
>>>
>>> PS - If you don't know how to start HTML help - help.start()
>>>
>>> On Wed, Nov 21, 2018 at 7:26 PM Subhamitra Patra <
>>> subhamitra.patra using gmail.com> wrote:
>>>
>>>> Sir, in the bold portion of the below code, I have some confusion
>>>> which I am mentioning below that
>>>>
>>>> "ylab="MPG",main=names(MPG3)[i],*xaxt="n"*)
>>>> axis(*1*,at=1:nrows,*labels=MPG3$Year*)"
>>>>
>>>> 1. Here, what *xaxt="n"* indicates? I think it indicates the no. of
>>>> rows, right?
>>>> 2. 1 in the 2nd line represents the no. of graphs. Let suppose, 38
>>>> plots are having the same row, I need to mention them as *axis(38,
>>>> at=1:nrows)*, right?
>>>> 3. *labels=**MPG3$Year *will give the name of all years in the X-axis,
>>>> right?
>>>>
>>>> Kindly correct me if I am wrong.
>>>>
>>>> Sir, here one thing I would like to ask, my data frequency is not
>>>> yearly. I obtained results from the daily data of the period from
>>>> 1994-2017 (that means the no. of rows will be 5655). But, as the daily
>>>> period is very unclear to mention in the X-axis, I wanted to give year name
>>>> as the name of the X-axis (that means, 1995, 1997, 1999 with the increment
>>>> of 2 years up to 2017).
>>>>
>>>> Sir, please suggest me how to proceed with this?
>>>>
>>>>
>>
>> --
>> *Best Regards,*
>> *Subhamitra Patra*
>> *Phd. Research Scholar*
>> *Department of Humanities and Social Sciences*
>> *Indian Institute of Technology, Kharagpur*
>> *INDIA*
>>
>
>
> --
> *Best Regards,*
> *Subhamitra Patra*
> *Phd. Research Scholar*
> *Department of Humanities and Social Sciences*
> *Indian Institute of Technology, Kharagpur*
> *INDIA*
>
--
*Best Regards,*
*Subhamitra Patra*
*Phd. Research Scholar*
*Department of Humanities and Social Sciences*
*Indian Institute of Technology, Kharagpur*
*INDIA*
[[alternative HTML version deleted]]
More information about the R-help
mailing list