def plot_ICBounds(x_test, y_test, nTest, sigma) : vUp = [[x_test[i][0], y_test[i][0] + sigma ] for i in range(nTest)] vLow = [[x_test[i][0], y_test[i][0] - sigma ] for i in range(nTest)] polyData = [[vLow[i], vLow[i+1], vUp[i+1], vUp[i]] for i in range(nTest-1)] polygonList = [ot.Polygon(polyData[i], "grey", "grey") for i in range(nTest-1)] boundsPoly = ot.PolygonArray(polygonList) return boundsPoly
def CreatePolygonArray(polyData, color): numberOfPolygons = len(polyData) polygonList = [ ot.Polygon(polyData[i], color, color) for i in range(numberOfPolygons) ] polygonArray = ot.PolygonArray(polygonList) return polygonArray
def drawInTheBounds(vLow,vUp,n_test): """ Draw the area within the bounds. """ palette = ot.Drawable.BuildDefaultPalette(2) myPaletteColor = palette[0] polyData = [[vLow[i], vLow[i+1], vUp[i+1], vUp[i]] for i in range(n_test-1)] polygonList = [ot.Polygon(polyData[i], myPaletteColor, myPaletteColor) for i in range(n_test-1)] boundsPoly = ot.PolygonArray(polygonList) return boundsPoly
def fill_between(lower, upper, legend, color): """Draw a shaded area between two curves.""" disc = len(lower) poly_data = [[lower[i], lower[i + 1], upper[i + 1], upper[i]] for i in range(disc - 1)] polygon = [ ot.Polygon(poly_data[i], color, color) for i in range(disc - 1) ] bounds_poly = ot.PolygonArray(polygon) bounds_poly.setLegend(legend) return bounds_poly
def plot_kriging_bounds(vLow,vUp,n_test): ''' From two lists containing the lower and upper bounds of the region, create a PolygonArray. ''' palette = ot.Drawable.BuildDefaultPalette(2) myPaletteColor = palette[1] polyData = [[vLow[i], vLow[i+1], vUp[i+1], vUp[i]] for i in range(n_test-1)] polygonList = [ot.Polygon(polyData[i], myPaletteColor, myPaletteColor) for i in range(n_test-1)] boundsPoly = ot.PolygonArray(polygonList) boundsPoly.setLegend("95% bounds") return boundsPoly
def fill_between_(lower, upper, legend): """Draw a shaded area between two curves.""" disc = len(lower) palette = ot.Drawable.BuildDefaultPalette(2)[1] poly_data = [[lower[i], lower[i + 1], upper[i + 1], upper[i]] for i in range(disc - 1)] polygon = [ ot.Polygon(poly_data[i], palette, palette) for i in range(disc - 1) ] bounds_poly = ot.PolygonArray(polygon) bounds_poly.setLegend(legend) return bounds_poly
def plot_kriging_bounds(dataLower, dataUpper, n_test, color=[120, 1.0, 1.0]): """ From two lists containing the lower and upper bounds of the region, create a PolygonArray. Default color is green given by HSV values in color list. """ vLow = [[x_test[i, 0], dataLower[i, 0]] for i in range(n_test)] vUp = [[x_test[i, 0], dataUpper[i, 0]] for i in range(n_test)] myHSVColor = ot.Polygon.ConvertFromHSV(color[0], color[1], color[2]) polyData = [[vLow[i], vLow[i+1], vUp[i+1], vUp[i]] for i in range(n_test-1)] polygonList = [ot.Polygon(polyData[i], myHSVColor, myHSVColor) for i in range(n_test-1)] boundsPoly = ot.PolygonArray(polygonList) return boundsPoly
# graph.draw('curve11.png') view = View(graph) # view.save('curve11.png') view.ShowAll(block=True) # PolygonArray generator = ot.Normal(2) size = 5 array = ot.PolygonCollection(size) palette = ot.Drawable.BuildDefaultPalette(size) palette[0] = 'blue' for i in range(size): vertices = generator.getSample(3) array[i] = ot.Polygon(vertices, palette[i], palette[size - i - 1]) graph = ot.Graph('An array of polygons', 'x', 'y', True, 'topright') parray = ot.PolygonArray(array) parray.setLegend('array of polys') graph.add(parray) # graph.draw('curve12.png') view = View(graph) # view.save('curve12.png') # BipartiteGraph.draw graph = ot.BipartiteGraph([[0, 1, 2], [0, 1, 2]]).draw() view = View(graph) # FORM reliability index marginal parameter sensitivity f = ot.SymbolicFunction(['E', 'F', 'L', 'I'], ['-F*L^3/(3*E*I)']) dim = f.getInputDimension() mean = [50.0, 1.0, 10.0, 5.0] sigma = ot.Point(dim, 1.0)
myPolygon1 = ot.Polygon(data1) myPolygon1.setColor('blue') graph.add(myPolygon1) myPolygon2 = ot.Polygon(data2) myPolygon2.setColor('red') graph.add(myPolygon2) # graph.draw('curve11.png') view = View(graph) # view.save('curve11.png') view.show(block=False) # PolygonArray generator = ot.Normal(2) size = 5 array = ot.PolygonCollection(size) palette = ot.Drawable.BuildDefaultPalette(size) palette[0] = 'blue' for i in range(size): vertices = generator.getSample(3) array[i] = ot.Polygon(vertices, palette[i], palette[size - i - 1]) graph = ot.Graph('An array of polygons', 'x', 'y', True, '') graph.add(ot.PolygonArray(array)) # graph.draw('curve12.png') view = View(graph) # view.save('curve12.png') view.show() except: traceback.print_exc() os._exit(1)
graph_meta = meta.draw(xMin, xMax) data = graph_meta.getDrawable(0).getData() xGrid = data.getMarginal(0) covGrid = result.getConditionalCovariance(xGrid) a = ot.DistFunc.qNormal(0.975) c = ot.Cloud([data[2]]) c.setPointStyle("square") c.setColor("green") c.setLegend("95% confidence bound") dataLower = [[data[i, 0], data[i, 1] - a * covGrid[i, i]] for i in range(len(data))] dataUpper = [[data[i, 0], data[i, 1] + a * covGrid[i, i]] for i in range(len(data))] bounds = ot.PolygonArray([ ot.Polygon( [dataLower[i], dataLower[i + 1], dataUpper[i + 1], dataUpper[i]], "green", "green") for i in range(len(dataLower) - 1) ]) graph = ot.Graph() graph.setLegendPosition("bottomright") graph.setAxes(True) graph.setGrid(True) graph.add(c) graph.add(bounds) d = f.draw(xMin, xMax).getDrawable(0) d.setLineStyle("dashed") d.setColor("magenta") d.setLineWidth(2) graph.add(d) graph.add(graph_meta)