1
2 """Creates subclasses of GeneralPlotTimelines"""
3
4 from GnuplotTimelines import GnuplotTimelines
5 from MatplotlibTimelines import MatplotlibTimelines
6 from QwtPlotTimelines import QwtPlotTimelines
7 from DummyPlotTimelines import DummyPlotTimelines
8
9 from CustomPlotInfo import CustomPlotInfo
10
11
12 from PyFoam import configuration
13 from PyFoam.Error import error
14
15 lookupTable = { "gnuplot" : GnuplotTimelines ,
16 "matplotlib" : MatplotlibTimelines,
17 "qwtplot" : QwtPlotTimelines,
18 "dummy" : DummyPlotTimelines }
19
20 -def createPlotTimelines(timelines,
21 custom,
22 implementation=None,
23 showWindow=True,
24 registry=None):
25 """Creates a plotting object
26 @param timelines: The timelines object
27 @type timelines: TimeLineCollection
28 @param custom: specifies how the block should look like
29 @param implementation: the implementation that should be used
30 """
31 if implementation==None:
32 implementation=configuration().get("Plotting","preferredImplementation")
33
34 if implementation not in lookupTable:
35 error("Requested plotting implementation",implementation,
36 "not in list of available implementations",lookupTable.keys())
37
38 return lookupTable[implementation](timelines,
39 custom,
40 showWindow=showWindow,
41 registry=registry)
42
43 -def createPlotTimelinesDirect(name,
44 timelines,
45 persist=None,
46 raiseit=True,
47 with_="lines",
48 alternateAxis=[],
49 forbidden=[],
50 start=None,
51 end=None,
52 logscale=False,
53 ylabel=None,
54 y2label=None,
55 implementation=None):
56 """Creates a plot using some prefefined values
57 @param timelines: The timelines object
58 @type timelines: TimeLineCollection
59 @param persist: Gnuplot window persistst after run
60 @param raiseit: Raise the window at every plot
61 @param with_: how to plot the data (lines, points, steps)
62 @param alternateAxis: list with names that ought to appear on the alternate y-axis
63 @param forbidden: A list with strings. If one of those strings is found in a name, it is not plotted
64 @param start: First time that should be plotted. If undefined everything from the start is plotted
65 @param end: Last time that should be plotted. If undefined data is plotted indefinitly
66 @param logscale: Scale the y-axis logarithmic
67 @param ylabel: Label of the y-axis
68 @param y2label: Label of the alternate y-axis
69 @param implementation: the implementation that should be used
70 """
71
72 ci=CustomPlotInfo(name=name)
73 ci.persist=persist
74 ci.raiseit=raiseit
75 ci.with_=with_
76 ci.alternateAxis=alternateAxis
77 ci.forbidden=forbidden
78 ci.start=start
79 ci.end=end
80 ci.logscale=logscale
81 ci.ylabel=ylabel
82 ci.y2label=y2label
83
84 return createPlotTimelines(timelines,ci,implementation=implementation)
85