Class Heatmap


public class Heatmap extends Plot
A heat map is a graphical representation of data where the values taken by a variable in a two-dimensional map are represented as colors.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Heatmap(double[] x, double[] y, double[][] z, Color[] palette)
    Constructor.
    Heatmap(String[] rowLabels, String[] columnLabels, double[][] z, Color[] palette)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a figure containing the plot.
    double[]
    Returns the lower bound of data.
    double[]
    Returns the upper bound of data.
    static Heatmap
    of(double[][] z)
    Creates a heatmap with 16-color jet color palette.
    static Heatmap
    of(double[][] z, int k)
    Creates a heatmap with jet color palette.
    static Heatmap
    of(double[][] z, Color[] palette)
    Creates a heatmap with given color palette.
    static Heatmap
    of(double[] x, double[] y, double[][] z)
    Creates a heatmap with 16-color jet color palette.
    static Heatmap
    of(double[] x, double[] y, double[][] z, int k)
    Creates a heatmap with jet color palette.
    static Heatmap
    of(String[] rowLabels, String[] columnLabels, double[][] z)
    Creates a heatmap with 16-color jet color palette.
    static Heatmap
    of(String[] rowLabels, String[] columnLabels, double[][] z, int k)
    Creates a heatmap with jet color palette.
    void
    Draws the shape.
    tooltip(double[] coord)
    Returns an optional tooltip for the object at given coordinates.

    Methods inherited from class smile.plot.swing.Plot

    legends, toolbar

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Heatmap

      public Heatmap(String[] rowLabels, String[] columnLabels, double[][] z, Color[] palette)
      Constructor.
      Parameters:
      rowLabels - the labels of rows.
      columnLabels - the labels of columns.
      z - a data matrix to be shown in pseudo heat map.
      palette - the color palette.
    • Heatmap

      public Heatmap(double[] x, double[] y, double[][] z, Color[] palette)
      Constructor.
      Parameters:
      x - x coordinate of data matrix cells. Must be in ascending order.
      y - y coordinate of data matrix cells. Must be in ascending order.
      z - a data matrix to be shown in pseudo heat map.
      palette - the color palette.
  • Method Details

    • tooltip

      public Optional<String> tooltip(double[] coord)
      Description copied from class: Plot
      Returns an optional tooltip for the object at given coordinates.
      Overrides:
      tooltip in class Plot
      Parameters:
      coord - the logical coordinates of current mouse position.
      Returns:
      a string if an object with label close to the given coordinates.
    • getLowerBound

      public double[] getLowerBound()
      Description copied from class: Plot
      Returns the lower bound of data.
      Specified by:
      getLowerBound in class Plot
      Returns:
      the lower bound of data.
    • getUpperBound

      public double[] getUpperBound()
      Description copied from class: Plot
      Returns the upper bound of data.
      Specified by:
      getUpperBound in class Plot
      Returns:
      the upper bound of data.
    • paint

      public void paint(Renderer g)
      Description copied from class: Shape
      Draws the shape.
      Specified by:
      paint in class Shape
      Parameters:
      g - the renderer.
    • figure

      public Figure figure()
      Description copied from class: Plot
      Returns a figure containing the plot.
      Overrides:
      figure in class Plot
      Returns:
      a figure containing the plot.
    • of

      public static Heatmap of(double[][] z)
      Creates a heatmap with 16-color jet color palette.
      Parameters:
      z - a data matrix to be shown in pseudo heat map.
      Returns:
      the heatmap.
    • of

      public static Heatmap of(double[][] z, int k)
      Creates a heatmap with jet color palette.
      Parameters:
      z - a data matrix to be shown in pseudo heat map.
      k - the number of colors in the palette.
      Returns:
      the heatmap.
    • of

      public static Heatmap of(double[][] z, Color[] palette)
      Creates a heatmap with given color palette.
      Parameters:
      z - a data matrix to be shown in pseudo heat map.
      palette - the color palette.
      Returns:
      the heatmap.
    • of

      public static Heatmap of(String[] rowLabels, String[] columnLabels, double[][] z)
      Creates a heatmap with 16-color jet color palette.
      Parameters:
      rowLabels - the row labels.
      columnLabels - the column labels.
      z - a data matrix to be shown in pseudo heat map.
      Returns:
      the heatmap.
    • of

      public static Heatmap of(String[] rowLabels, String[] columnLabels, double[][] z, int k)
      Creates a heatmap with jet color palette.
      Parameters:
      rowLabels - the row labels.
      columnLabels - the column labels.
      z - a data matrix to be shown in pseudo heat map.
      k - the number of colors in the palette.
      Returns:
      the heatmap.
    • of

      public static Heatmap of(double[] x, double[] y, double[][] z)
      Creates a heatmap with 16-color jet color palette.
      Parameters:
      x - x coordinate of data matrix cells. Must be in ascending order.
      y - y coordinate of data matrix cells. Must be in ascending order.
      z - a data matrix to be shown in pseudo heat map.
      Returns:
      the heatmap.
    • of

      public static Heatmap of(double[] x, double[] y, double[][] z, int k)
      Creates a heatmap with jet color palette.
      Parameters:
      x - x coordinate of data matrix cells. Must be in ascending order.
      y - y coordinate of data matrix cells. Must be in ascending order.
      z - a data matrix to be shown in pseudo heat map.
      k - the number of colors in the palette.
      Returns:
      the heatmap.