MCPcopy Index your code
hub / github.com/pyfa-org/Pyfa / draw

Method draw

graphs/gui/canvasPanel.py:104–286  ·  view source on GitHub ↗
(self, accurateMarks=True)

Source from the content-addressed store, hash-verified

102 self.mplOnReleaseHandler = None
103
104 def draw(self, accurateMarks=True):
105 self.subplot.clear()
106 self.subplot.grid(True)
107 allXs = set()
108 allYs = set()
109 plotData = {}
110 legendData = []
111 chosenX = self.graphFrame.ctrlPanel.xType
112 chosenY = self.graphFrame.ctrlPanel.yType
113 self.subplot.set(
114 xlabel=self.graphFrame.ctrlPanel.formatLabel(chosenX),
115 ylabel=self.graphFrame.ctrlPanel.formatLabel(chosenY))
116
117 mainInput, miscInputs = self.graphFrame.ctrlPanel.getValues()
118 view = self.graphFrame.getView()
119 sources = self.graphFrame.ctrlPanel.sources
120 if view.hasTargets:
121 iterList = tuple(itertools.product(sources, self.graphFrame.ctrlPanel.targets))
122 else:
123 iterList = tuple((f, None) for f in sources)
124
125 # Draw plot lines and get data for legend
126 for source, target in iterList:
127 # Get line style data
128 try:
129 colorData = BASE_COLORS[source.colorID]
130 except KeyError:
131 pyfalog.warning('Invalid color "{}" for "{}"'.format(source.colorID, source.name))
132 continue
133 color = colorData.hsl
134 lineStyle = 'solid'
135 if target is not None:
136 try:
137 lightnessData = LIGHTNESSES[target.lightnessID]
138 except KeyError:
139 pyfalog.warning('Invalid lightness "{}" for "{}"'.format(target.lightnessID, target.name))
140 continue
141 color = lightnessData.func(color)
142 try:
143 lineStyleData = STYLES[target.lineStyleID]
144 except KeyError:
145 pyfalog.warning('Invalid line style "{}" for "{}"'.format(target.lightnessID, target.name))
146 continue
147 lineStyle = lineStyleData.mplSpec
148 color = hsv_to_rgb(hsl_to_hsv(color))
149
150 # Get point data
151 try:
152 xs, ys = view.getPlotPoints(
153 mainInput=mainInput,
154 miscInputs=miscInputs,
155 xSpec=chosenX,
156 ySpec=chosenY,
157 src=source,
158 tgt=target)
159 if not self.__checkNumbers(xs, ys):
160 pyfalog.warning('Failed to plot "{}" vs "{}" due to inf or NaN in values'.format(source.name, '' if target is None else target.name))
161 continue

Callers 3

markXApproximateMethod · 0.95
unmarkXMethod · 0.95
OnMplCanvasReleaseMethod · 0.95

Calls 15

__checkNumbersMethod · 0.95
_getLimitsMethod · 0.95
_interpolateXMethod · 0.95
hsl_to_hsvFunction · 0.90
roundToPrecFunction · 0.85
formatLabelMethod · 0.80
getValuesMethod · 0.80
getPlotPointsMethod · 0.80
replaceMethod · 0.80
clearMethod · 0.45
setMethod · 0.45
getViewMethod · 0.45

Tested by

no test coverage detected