.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/06_visual/plot_04_design.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code or to run this example in your browser via Binder. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_06_visual_plot_04_design.py: Design: palettes, chart styles, faces and network drawings ========================================================== Interactive evolution has served graphic design since the 1990s (Takagi, 2001). The design problems here mix judged qualities with computable constraints: a colour palette must keep text legible (WCAG contrast ratio of at least 4.5 : 1); a chart style should be clean and readable; Chernoff faces (Chernoff, 1973) map ten numbers to facial features that people read instantly; a network drawing should show the structure of Zachary's karate club without clutter. .. GENERATED FROM PYTHON SOURCE LINES 15-17 Random designs -------------- .. GENERATED FROM PYTHON SOURCE LINES 17-34 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np import easyiec as ei from easyiec.problems import ChartStyle, ChernoffFace, ColorPalette, GraphLayout from easyiec.strategies import InteractiveCMAES rng = np.random.default_rng(6) families = [ColorPalette(), ChartStyle(), ChernoffFace(), GraphLayout()] fig, axes = plt.subplots(4, 6, figsize=(10, 7)) for row, p in zip(axes, families): for ax in row: ax.imshow(p.to_image(p.random(rng), 140)) ax.axis("off") row[0].set_title(p.title, fontsize=8, loc="left") fig.tight_layout() .. image-sg:: /auto_examples/06_visual/images/sphx_glr_plot_04_design_001.png :alt: Colour palette, Chart style, Chernoff face, Network drawing :srcset: /auto_examples/06_visual/images/sphx_glr_plot_04_design_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 35-40 A legible palette ----------------- The default utility of :class:`~easyiec.problems.ColorPalette` rewards WCAG contrast between text and background and between the data series and the background, and a spread of hues. .. GENERATED FROM PYTHON SOURCE LINES 40-46 .. code-block:: Python problem = ColorPalette() user = ei.SimulatedUser(problem, target="default", noise=0.03, seed=2) res = ei.run(problem, InteractiveCMAES(pop_size=8), user, generations=12, seed=2) print({k: round(v, 2) for k, v in problem.objectives(res.best.genome).items()}) ei.viz.plot_history(res.log, problem, steps=[0, 5, 11], max_items=8, size=1.1) plt.show() .. image-sg:: /auto_examples/06_visual/images/sphx_glr_plot_04_design_002.png :alt: plot 04 design :srcset: /auto_examples/06_visual/images/sphx_glr_plot_04_design_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none {'text_contrast': 6.13, 'series_contrast': 4.12, 'hue_spread': 0.66} .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.140 seconds) .. _sphx_glr_download_auto_examples_06_visual_plot_04_design.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/ComplexSystemsIntelligence/easyiec/main?urlpath=lab/tree/notebooks/auto_examples/06_visual/plot_04_design.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_04_design.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_04_design.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_04_design.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_