Plot - Scatter

from gemseo.api import configure_logger
from gemseo.core.dataset import Dataset
from import Scatter
from matplotlib import pyplot as plt
from numpy import linspace
from numpy import pi
from numpy import sin



<RootLogger root (INFO)>

Build a dataset

inputs = linspace(0, 1, 20)[:, None]
outputs = sin(2 * pi * inputs)
color = ["b" if abs(output) > 0.5 else "r" for output in outputs]

dataset = Dataset()
dataset.add_variable("x", inputs, "inputs")
dataset.add_variable("y", outputs, "outputs", cache_as_input=False)

Plot y vs x

We can use the Scatter plot

plot = Scatter(dataset, "x", "y")
plot.color = color
plot.execute(show=False, save=False)
# Workaround for HTML rendering, instead of ``show=True``
plot scatter

Total running time of the script: ( 0 minutes 0.122 seconds)

Gallery generated by Sphinx-Gallery