/data-visualization

Visualization of sci-data

Primary LanguagePythonMIT LicenseMIT

Data Visualization

This repo is created for the sake of drawing sci-style figures with free softwares (e.g. matplotlib and seaborn).

Currently there are plenty of choices to draw sci-style figures, such as Gnuplot, Origin-Lab. However, based on python, matplotlib are powerful tools to work with powerful abilities and programmable behaviors. With carefully designed style and layout settings, we can plot figures similar to those generated by Origin-Lab, which is a commercial software.

Basic Functions and APIs

  1. Draw Bars

    def draw_bar(
        axes: Axes,
        bar_cfg: Dict[str, Any],
        draw_cfg: Dict[str, Any]
    ) -> Tuple[Figure, Axes]:
        ...

    This function draw a vertical bar plot with the given axes.

    Configurations:

    1. bar_cfg

      • data is a DataFrame contains a set of bar data, including position and error (optional).

      Example:

      method AP err_n err_p
      0 Redundancy 47.8321 0.4 0.3
      1 Isometric 47.2445 0.2 0.4
      2 Random 45.53119 0.2 0.3
      3 SAG 44.64032 0.2 0.2
      • error is an optional dict contains error type and corresponding to the keys in bar_cfg. Default None.
      error: # dict
          err_pos: err_p  # positive error
          err_neg: err_n  # negative error, optional if errors are symmetric
      • x_axis is the column name of the x axis in data, e.g. method.
      • y_axis is the column name of the y axis in data, e.g. AP.
    2. draw_cfg

      bar: # dict
          width: 0.45         # width of each rectangular
          align: center       # alignment to x-ticks
          edgecolor: black
          linewidth: 0.8
      bar_label: # dict
          fmt: "%.1f"
          label_type: edge
          fontsize: small
      error_bar: # dict
          ecolor: black
          elinewidth: 0.8
          markeredgewidth: 0.8
      • colormap reference to Sec. ColorMap
      • color is a list of colors, this will override the colormap setting, type: List[str]
  2. Draw Heatmap

  3. Draw Lines

Style Settings

Layout Settings

ColorMap

Examples

  1. Basic Bins

    Path: examples/base_bins/vis_base_bins.py

    basic-bins

  2. Heatmap

    Path: examples/lr_curves/vis_xxx.py

  3. Line with Markers

  4. Loss Learning Curve

  5. LR Learning Curve

References

  1. Seaborn
  2. Matplotlib
  3. https://matplotlib.org/cheatsheets/cheatsheets.pdf