TQ 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.

p.pdf


TQ User guide <<< >>>

tq/ug/draw.txt · Last modified: 2016/04/27 18:55 by vlado
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki