Verified Commit 83ce73bc authored by Yunus Sevinchan's avatar Yunus Sevinchan
Browse files

Use latest utopya; upgrade .plot.ca `limits` syntax to vmin/vmax

This also makes use of parameter validation shorthands that became
available in the latest utopya version.
parent 86c0b93a
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -89,7 +89,7 @@ if (NOT PYTHON_PACKAGE_wheel_FOUND)
endif()

# -- utopya
set(UTOPYA_REQUIRED_VERSION 1.1.1)
set(UTOPYA_REQUIRED_VERSION 1.1.3)

if(NOT UTOPYA_FROM_PYPI)
    set(UTOPYA_FROM_PYPI On)
+11 −19
Original line number Diff line number Diff line
@@ -34,6 +34,9 @@ _default_style: &default_style
.flush_cmap:
  cmap: ~




# -----------------------------------------------------------------------------
# Failing plots for usage/eval/dag/debug.rst

@@ -191,8 +194,6 @@ debug_DAG_advanced_print_examples:





# -----------------------------------------------------------------------------
# Demonstrates a basic line plot
density_basic:
@@ -205,6 +206,7 @@ density_basic:
      transform:
        - .sel: [!dag_prev , { kind: [infected] }]


# Demonstrates a basic line plot with style adjustments
### Start --- line_plot
line_plot:
@@ -239,6 +241,7 @@ line_plot:
      title: Density of infected agents
### End --- line_plot


# Demonstrates a stacked line plot
stacked_kinds:
  based_on:
@@ -264,6 +267,7 @@ stacked_kinds:
    set_title:
      title: Density of agent kinds


# Demonstrates an animated cellular automaton
### Start --- .plot.ca.
animated_ca:
@@ -289,8 +293,8 @@ animated_ca:

  to_plot:
    kind:
      limits: [0, 3]
      # Use a custom cmap; these colors must be globally defined somewhere
      # Will automatically be mapped to values [0, 1, 2, 3]
      cmap:
        empty: *white
        susceptible: *lightgreen
@@ -305,6 +309,7 @@ animated_ca:
    font.size: 10
### End --- .plot.ca.


# Demonstrates a simple 2D scatter plot
scatter_2d_simple:
  based_on:
@@ -343,7 +348,8 @@ scatter_2d_simple:
    set_title:
      title: ~

# Demonstrates a 2D scatterplot with an additional variable plotted on the 'hue'

# Demonstrates a 2D scatterplot with an additional variable plotted on 'hue'
### Start --- scatter_2d
scatter_2d:
  based_on:
@@ -387,7 +393,6 @@ scatter_2d:
  color: ~



# Demonstrates a 3D scatter plot with hue
### Start --- scatter_3d
scatter_3d:
@@ -466,6 +471,7 @@ scatter_2d_colorful:
      0.8: *lightblue
      1: *darkblue


# Demonstrates some PlotHelper features
helper_demo:
  based_on:
@@ -513,17 +519,3 @@ helper_demo:
        major:
          locs: [0, 0.1, 0.2, 0.3, 0.4]
          labels: ['No', more, trouble, with, tick labels]

ca/state:
  based_on:
    - .creator.universe
    - .plot.ca
  enabled: false

  select:
    kind: kind
  to_plot:
    kind:
      title: State
      limits: [0, 7]
  suptitle_fstr: False
+10 −6
Original line number Diff line number Diff line
@@ -44,7 +44,6 @@ A particularly common case is animating cellular automata, such as the :ref:`SEI
.. code-block:: yaml

    animated_ca:

      # Base your plot on .plot.ca
      based_on:
        - .creator.universe
@@ -57,8 +56,9 @@ A particularly common case is animating cellular automata, such as the :ref:`SEI
      # .plot.ca requires a 'to_plot' key
      to_plot:
        kind:
          limits: [~, 3]
          # title: My title
          vmin: 0
          vmax: 3
          cmap:
            empty: white
            susceptible: lightgreen
@@ -68,8 +68,9 @@ A particularly common case is animating cellular automata, such as the :ref:`SEI
:code:`.plot.ca` requires a :code:`to_plot` key, specifying what to put into each subplot.
The keys (here: ``kind``) need to correspond to the selected data entries.

In addition, it is used to specify the limits of the colormap (and other information like a subplot title).
Here, we are only plotting the susceptible, infected, and recovered agents, so we set the limits to :code:`[0, 3]`, and define the colors we want for each :code:`kind`:
In addition, it is used to specify the limits of the colormap (``vmin`` and ``vmax``) and other information like the subplot's title.
Here, we are only plotting empty cells and cells with susceptible, infected, and recovered agents, denoted by the integer ``kind`` values of ``0`` to ``3``.
To ensure that the colormap stays in that range, we set ``vmin`` and ``vmax`` accordingly and define the colors we want for each ``kind``; they are associated depending on the order within ``cmap``, starting at ``vmin`` and going up to ``vmax`` in integer steps:

.. raw:: html

@@ -103,9 +104,12 @@ Simply add

      frames_isel: !range [30, 60]

This will only plot the frames from 30 to 60. You can also manually specify an array, i.e. :code:`frames_isel: [10, 20, 30, 40]`.
This will only plot the frames from 30 to 59.
You can also manually specify a list, i.e. :code:`frames_isel: [10, 20, 30, 40]`.

.. hint::

You can also use the ``.plot.facet_grid`` base configuration with ``kind: pcolormesh`` to animate heatmaps.
    As an alternative for plotting heatmaps that is not specialized on CA, you can use the ``.plot.facet_grid.pcolormesh`` base configuration.
    See the :ref:`article on heatmaps <pcolormesh>` for more details.


+7 −10
Original line number Diff line number Diff line
@@ -5,7 +5,8 @@
.variables:
  base_path: &base_path data/ContDisease

  colors:                                   # state value
  colors: &cmap                             # state value
    # NOTE Order is very important here!
    empty: &color_empty darkkhaki           # 0
    tree: &color_tree forestgreen           # 1
    infected: &color_infected firebrick     # 2
@@ -150,13 +151,7 @@ ca/forest:
  to_plot:
    kind:
      title: Forest State
      limits: [0, 4]
      cmap:
        empty: *color_empty
        tree: *color_tree
        infected: *color_infected
        source: *color_source
        stone: *color_stone
      cmap: *cmap

# ... The forest age ..........................................................
ca/forest_age:
@@ -171,7 +166,8 @@ ca/forest_age:
    age:
      title: Forest Age
      cmap: YlGn
      limits: [0, max]
      vmin: 0
      vmax: max

# ... The clusters ............................................................
ca/clusters:
@@ -192,6 +188,7 @@ ca/clusters:
  to_plot:
    cluster_id:
      title: Clusters
      limits: [0, 20]
      cmap: tab20
      vmin: 0
      vmax: 20
      no_cbar_markings: true
+4 −2
Original line number Diff line number Diff line
@@ -158,7 +158,8 @@ ca/state:
    some_state:
      title: Some State
      cmap: Greens
      limits: [min, max]
      vmin: min
      vmax: max

ca/trait:
  based_on:
@@ -172,4 +173,5 @@ ca/trait:
    some_trait:
      title: Some Trait
      cmap: Blues
      # limits: [0, ~]
      # vmin: 0
      # vmax: ~
Loading