[[:TQ|TQ]] [[tq:ug|User guide]]
====== Drawing ======
The drawing procedure ''plotTime'' is implemented in R because it supports different output formats. The Python procedure will provide additional options. It has the following parameters
''plotTime(L,tMin,tMax,times,lTimes,wMax,file="testPic.pdf",step=5,dt=10,h=60,PDF=FALSE,col="red",main="Temporal quantity")''
The data are exchanged between Python and R in the JSON format.
For example: we first store selected temporal quantities in Python into a dictionary ''tqs'' and save it to a file ''tqs.json'' in JSON format.
>>> tqs = {}
>>> tqs['a'] = a
>>> tqs['b'] = b
>>> tqs['s'] = s
>>> tqs['p'] = p
>>> import json
>>> with open('tqs.json',mode='w',encoding='utf-8') as f:
json.dump(tqs,f,indent=2)
>>>
Afterward in R, we read the dictionary and draw selected temporal quantities.
> wdir <- 'C:/Users/batagelj/work/Python/temporal'
> setwd(wdir)
> source("C:\\Users\\batagelj\\work\\Python\\temporal\\plotTime.R")
> library(rjson)
> T <- fromJSON(file="tqs.json")
> names(T)
[1] "p" "a" "s" "b"
> p <- T[[1]] # or p <- T$p
> a <- T[[2]]
> tMin <- 1; tMax <- 21; lTimes <- as.character(tMin:tMax)
> times <- c(1,5,10,15,20); wMax <- 10
> plotTime(a,tMin,tMax,times,lTimes,wMax,h=100,main='a')
> plotTime(p,tMin,tMax,times,lTimes,wMax,h=100,main='p')
> plotTime(p,tMin,tMax,times,lTimes,wMax,h=100,main='p',file='p.pdf',PDF=TRUE)
Note: we could store in T also variables tMin, tMax, lTimes, times, wMax, etc.
{{tq:pics:p.pdf}}