code: def polygon_generator(data, scale, style, permutation=None):
      """Generator for the vertices of the polygon to be colored and its color,
      depending on style. Called by heatmap."""
  
      # We'll project the coordinates inside this function to prevent
      # passing around permutation more than necessary
      project = functools.partial(
          project_point, permutation=permutation
      )
  
      if isinstance(data, dict):
          data_gen = data.items()
      else:
          # Only works with style == 'h'
          data_gen = data
  
      for key, value in data_gen:
          if value is None:
              continue
          i = key[0]
          j = key[1]
          k = scale - i - j
          if style == "h":
              # Note here we permute first and then project normally, in
              # contrast to the cases below.
              i, j, k = list(
                  permute_point([i, j, k], permutation=permutation)
              )
              vertices = hexagon_coordinates(i, j, k)
              yield map(project_point, vertices), value
          elif style == "d":
              # Upright triangles
              if (i <= scale) and (j <= scale) and (k >= 0):
                  vertices = triangle_coordinates(i, j, k)
                  yield map(project, vertices), value
              # Upside-down triangles
              if (i < scale) and (j < scale) and (k >= 1):
                  vertices = alt_triangle_coordinates(i, j, k)
                  value = blend_value(data, i, j, k)
                  yield map(project, vertices), value
          elif style == "t":
              # Upright triangles
              if (i < scale) and (j < scale) and (k > 0):
                  vertices = triangle_coordinates(i, j, k)
                  value = blend_value(data, i, j, k)
                  yield map(project, vertices), value
              # If not on the boundary add the upside-down triangle
              if (i < scale) and (j < scale) and (k > 1):
                  vertices = alt_triangle_coordinates(i, j, k)
                  value = alt_blend_value(data, i, j, k)
                  yield map(project, vertices), value
  
file_path: python-ternary/ternary/heatmapping.py
imports: import functools
  import numpy
  from matplotlib import pyplot
  from .helpers import unzip, normalize, simplex_iterator, permute_point, project_point
  from .colormapping import get_cmap, colormapper, colorbar_hack
label_desc: Use image node_id 7 for calling a global function with example usage: polygon_generator(data, scale, style, permutation) without return types