#! /usr/bin/env python # use non-interactive backend import matplotlib matplotlib.use("Agg") from openturns.viewer import View import openturns as ot # Curve graph = ot.Normal().drawCDF() # graph.draw('curve1.png') view = View(graph, plot_kwargs={"color": "blue"}) # view.save('curve1.png') view.show(block=False) # Contour graph = ot.Normal([1, 2], [3, 5], ot.CorrelationMatrix(2)).drawPDF() # graph.draw('curve2.png') view = View(graph) # view.save('curve2.png') view.show(block=False) # Histogram tests normal = ot.Normal(1) size = 100 sample = normal.getSample(size) graph = ot.VisualTest.DrawHistogram(sample, 10) # graph.draw('curve3.png') view = View(graph)
try: # use non-interactive backend import matplotlib matplotlib.use('Agg') from openturns.viewer import View import openturns as ot # Curve graph = ot.Normal().drawCDF() # graph.draw('curve1.png') view = View(graph, pixelsize=(800, 600), plot_kwargs={'color': 'blue'}) # view.save('curve1.png') view.show(block=False) # Contour graph = ot.Normal([1, 2], [3, 5], ot.CorrelationMatrix(2)).drawPDF() # graph.draw('curve2.png') view = View(graph) # view.save('curve2.png') view.show(block=False) # Histogram tests normal = ot.Normal(1) size = 100 sample = normal.getSample(size) graph = ot.VisualTest.DrawHistogram(sample, 10) # graph.draw('curve3.png') view = View(graph)
import os import traceback import sys try: from openturns.viewer import View import openturns as ot # Curve graph = ot.Normal().drawCDF() # graph.draw('curve1.png') view = View(graph, pixelsize=(800, 600), plot_kw={'color': 'blue'}) # view.save('curve1.png') view.show() # Contour graph = ot.Normal([1, 2], [3, 5], ot.CorrelationMatrix(2)).drawPDF() # graph.draw('curve2.png') view = View(graph) # view.save('curve2.png') view.show() # Histogram tests normal = ot.Normal(1) size = 100 sample = normal.getSample(size) graph = ot.HistogramFactory().build(sample, 10).drawPDF() # graph.draw('curve3.png') view = View(graph)
# Graph section # We build 2 curves # each one is function of frequency values ind = ot.Indices(2) ind.fill() # Some cosmetics : labels, legend position, ... graph = ot.Graph("Estimated spectral function - Validation", "Frequency", "Spectral density function", True, "topright", 1.0, ot.GraphImplementation.LOGY) # The first curve is the estimate density as function of frequency curve1 = ot.Curve(plotSample.getMarginal(ind)) curve1.setColor('blue') curve1.setLegend('estimate model') # The second curve is the theoritical density as function of frequency ind[1] = 2 curve2 = ot.Curve(plotSample.getMarginal(ind)) curve2.setColor('red') curve2.setLegend('Cauchy model') graph.add(curve1) graph.add(curve2) fig = plt.figure(figsize=(10, 4)) plt.suptitle('Spectral model estimation') graph_axis = fig.add_subplot(111) view = View(graph, figure=fig, axes=[graph_axis], add_legend=False) view.show()