xyzpy.plot.infiniplot ===================== .. py:module:: xyzpy.plot.infiniplot Attributes ---------- .. autoapisummary:: xyzpy.plot.infiniplot._COLORS_DEFAULT xyzpy.plot.infiniplot._COLORS_SORTED xyzpy.plot.infiniplot._LINESTYLES_DEFAULT xyzpy.plot.infiniplot._MARKERS_DEFAULT xyzpy.plot.infiniplot._HEATMAP_INVALID_KWARGS xyzpy.plot.infiniplot._STYLE_SORT_ORDER xyzpy.plot.infiniplot.INFINIPLOTTER_DEFAULTS xyzpy.plot.infiniplot._PLOTTER_OPTS Classes ------- .. autoapisummary:: xyzpy.plot.infiniplot.Infiniplotter Functions --------- .. autoapisummary:: xyzpy.plot.infiniplot.get_neutral_style xyzpy.plot.infiniplot.use_neutral_style xyzpy.plot.infiniplot.neutral_style xyzpy.plot.infiniplot.get_default_colormaps xyzpy.plot.infiniplot.mod_sat xyzpy.plot.infiniplot.auto_colors xyzpy.plot.infiniplot.color_to_colormap xyzpy.plot.infiniplot.get_default_cmap xyzpy.plot.infiniplot.to_colormap xyzpy.plot.infiniplot._make_bold xyzpy.plot.infiniplot.infiniplot Module Contents --------------- .. py:function:: get_neutral_style(draw_color=(0.5, 0.5, 0.5)) .. py:function:: use_neutral_style(fn) Decorator to use xyzpy neutral style for a function. .. py:function:: neutral_style(draw_color=(0.5, 0.5, 0.5), **kwargs) .. py:data:: _COLORS_DEFAULT :value: ('#56B4E9', '#E69F00', '#009E73', '#D55E00', '#F0E442', '#CC79A7', '#0072B2') .. py:data:: _COLORS_SORTED :value: ('#0072B2', '#56B4E9', '#009E73', '#F0E442', '#E69F00', '#D55E00', '#CC79A7') .. py:function:: get_default_colormaps(N) .. py:function:: mod_sat(c, mod) Modify the luminosity of rgb color ``c``. .. py:function:: auto_colors(N) .. py:function:: color_to_colormap(c, **autohue_opts) .. py:function:: get_default_cmap(i, vdiff=0.5, sdiff=0.25) .. py:function:: to_colormap(c, **autohue_opts) .. py:function:: _make_bold(s) .. py:data:: _LINESTYLES_DEFAULT :value: ('solid', (0.0, (3, 1)), (0.5, (1, 1)), (1.0, (3, 1, 1, 1)), (1.5, (3, 1, 3, 1, 1, 1)), (2.0,... .. py:data:: _MARKERS_DEFAULT :value: ('o', 'X', 'v', 's', 'P', 'D', '^', 'h', '*', 'p', '<', 'd', '8', '>', 'H') .. py:data:: _HEATMAP_INVALID_KWARGS .. py:data:: _STYLE_SORT_ORDER :value: ('hue', 'color', 'markeredgecolor', 'marker', 'linestyle', 'markersize', 'linewidth') .. py:data:: INFINIPLOTTER_DEFAULTS .. py:data:: _PLOTTER_OPTS :value: ('bins', 'bins_density', 'aggregate', 'aggregate_method', 'aggregate_err_range', 'err',... .. py:class:: Infiniplotter(ds, x, y=None, z=None, **kwargs) .. py:attribute:: x .. py:attribute:: y :value: None .. py:attribute:: z :value: None .. py:attribute:: is_histogram .. py:attribute:: is_heatmap .. py:attribute:: is_scatter .. py:attribute:: kwargs .. py:attribute:: autohue_opts .. py:attribute:: err_kws .. py:attribute:: base_style .. py:attribute:: sizes .. py:attribute:: input_values .. py:attribute:: output_values .. py:attribute:: labels .. py:attribute:: ticklabels .. py:attribute:: ds .. py:attribute:: mapped .. py:attribute:: unmapped .. py:attribute:: remaining_dims .. py:attribute:: remaining_ranges .. py:method:: init_mapped_dim(name, custom_values=None, default_values=None) .. py:method:: plot_lines() Plot lines of the data. .. py:method:: create_legend() Create a legend for lines plot. .. py:method:: _create_legend_merged(legend_handles, legend_opts) Entry for every unique style combination. .. py:method:: _create_legend_split(legend_handles, legend_opts) Separate legend for each style separately. .. py:method:: plot_heatmap() Plot a heatmap of the data. .. py:method:: do_axes_formatting() .. py:function:: infiniplot(ds, x, y=None, z=None, **kwargs) Helper class for the infiniplot functionality. :param ds: Dataset to plot. :type ds: xarray.Dataset :param x: Name of the x coordinate. :type x: str :param y: Name of the y coordinate. If not specified, histogram mode is activated and the values of ``x`` are binned to produce a density or frequency to use as the y-variable. :type y: str, optional :param z: Name of the z coordinate. If specified this turns on the heatmap mode. :type z: str, optional :param bins: If in histogram mode, specify either the number of bins to use or the bin edges. If not specified, a default number of bins is automatically chosen based on the number of data points. :type bins: int or array_like, optional :param bins_density: If in histogram mode, whether to plot the density (True) or frequency (False) of the data. Default is True. :type bins_density: bool, optional :param aggregate: If specified, aggregate over the given dimension(s) using ``aggregate_method`` (by default 'median'). If `True` aggregate over all unmapped dimensions. If in heatmap mode, this is automatically set to `True`, since only one plot can be shown per axis. :type aggregate: str or Sequence[str], optional :param aggregate_method: If ``aggregate`` is specified, the method to use for aggregation. Any option available as a method on a DataArray can be used, e.g. 'mean', 'median', 'max'. Default is 'median'. :type aggregate_method: str, optional :param aggregate_err_range: If ``aggregate`` is specified, the range of the error bars or bands to show. The options are: - ``'std'``: show the standard deviation of the data - ``'stderr'``: show the standard error of the mean - float: show the given quantile range, e.g. 0.5 for the interquartile range :type aggregate_err_range: float or str, optional :param err: If specified, a data variable to use for error bars or bands. This overrides any derived from ``aggregate``. :type err: str, optional :param err_style: If specified, the style of error to show. The options are: - ``'bars'``: show error bars - ``'band'``: show error bands :type err_style: str, optional :param err_kws: Additional keyword arguments to pass to the error plotting function. :type err_kws: dict, optional :param xlink: If specified, the name of a dimension to use for linking the x-axis. Used when you are plotting a variable rather than coordinate as ``x``, but want to link each sweep of values as a line. :type xlink: str, optional :param color: If specified, the name of a dimension to use for mapping the color or intensity of each line. If ``hue`` is also specified, this controls the intensity of the color. If not a dimension, this is used as a constant color for all lines. :type color: str, optional :param colors: An explicit sequence of colors to use for the color-mapped dimension. :type colors: sequence, optional :param color_order: An explicit order of values to use for the color-mapped dimension. :type color_order: sequence, optional :param color_label: An alternate label to use for the color-mapped dimension. :type color_label: str, optional :param color_ticklabels: A mapping from values to tick labels to use for the color-mapped dimension. :type color_ticklabels: dict or sequence, optional :param colormap_start: If using a palette, the starting value of the colormap to use, e.g. 0.2 would skip the first 20% of the colormap. :type colormap_start: float, optional :param colormap_stop: If using a palette, the stopping value of the colormap to use, e.g. 0.9 would skip the last 10% of the colormap. :type colormap_stop: float, optional :param hue: If specified, the name of a dimension to use for mapping the color or hue of each line. If ``color`` is also specified, this controls the hue of the color. If not a dimension, this is used as a constant hue for all lines. :type hue: str, optional :param hues: An explicit sequence of hues to use for the hue-mapped dimension. :type hues: sequence, optional :param hue_order: An explicit order of values to use for the hue-mapped dimension. :type hue_order: sequence, optional :param hue_label: An alternate label to use for the hue-mapped dimension. :type hue_label: str, optional :param hue_ticklabels: A mapping from values to tick labels to use for the hue-mapped dimension. :type hue_ticklabels: dict or sequence, optional :param palette: If specified, the name of a colormap, or an actual colormap, to use for mapping the color or hue of each line. If both ``color`` and ``hue`` are specified, you can supply a sequence of palettes here, with ``hue`` controlling which palette, and ``color`` controlling the intensity within the palette. :type palette: str, sequence, or colormap, optional :param autohue_start: If not using a palette, the starting hue to use for automatically generating a sequence of hues. :type autohue_start: float, optional :param autohue_sweep: If not using a palette, the sweep of hues to use for automatically generating a sequence of hues. :type autohue_sweep: float, optional :param autohue_opts: Additional keyword arguments to pass to the automatic hue generator - see {func}`xyzpy.color.cmoke`. :type autohue_opts: dict, optional :param marker: If specified, the name of a dimension to use for mapping the marker style of each line. If not a dimension, this is used as a constant marker style for all lines. :type marker: str, optional :param markers: An explicit sequence of markers to use for the marker-mapped dimension. :type markers: sequence, optional :param marker_order: An explicit order of values to use for the marker-mapped dimension. :type marker_order: sequence, optional :param marker_label: An alternate label to use for the marker-mapped dimension. :type marker_label: str, optional :param marker_ticklabels: A mapping from values to tick labels to use for the marker-mapped dimension. :type marker_ticklabels: dict or sequence, optional :param markersize: If specified, the name of a dimension to use for mapping the marker size of each line. If not a dimension, this is used as a constant marker size for all lines. :type markersize: str, optional :param markersizes: An explicit sequence of marker sizes to use for the markersize-mapped dimension. :type markersizes: sequence, optional :param markersize_order: An explicit order of values to use for the markersize-mapped dimension. :type markersize_order: sequence, optional :param markersize_label: An alternate label to use for the markersize-mapped dimension. :type markersize_label: str, optional :param markersize_ticklabels: A mapping from values to tick labels to use for the markersize-mapped dimension. :type markersize_ticklabels: dict or sequence, optional :param markeredgecolor: If specified, the name of a dimension to use for mapping the marker edge color of each line. If not a dimension, this is used as a constant marker edge color for all lines. :type markeredgecolor: str, optional :param markeredgecolors: An explicit sequence of marker edge colors to use for the markeredgecolor-mapped dimension. :type markeredgecolors: sequence, optional :param markeredgecolor_order: An explicit order of values to use for the markeredgecolor-mapped dimension. :type markeredgecolor_order: sequence, optional :param markeredgecolor_label: An alternate label to use for the markeredgecolor-mapped dimension. :type markeredgecolor_label: str, optional :param markeredgecolor_ticklabels: A mapping from values to tick labels to use for the markeredgecolor-mapped dimension. :type markeredgecolor_ticklabels: dict or sequence, optional :param linewidth: If specified, the name of a dimension to use for mapping the line width of each line. If not a dimension, this is used as a constant line width for all lines. :type linewidth: str, optional :param linewidths: An explicit sequence of line widths to use for the linewidth-mapped dimension. :type linewidths: sequence, optional :param linewidth_order: An explicit order of values to use for the linewidth-mapped dimension. :type linewidth_order: sequence, optional :param linewidth_label: An alternate label to use for the linewidth-mapped dimension. :type linewidth_label: str, optional :param linewidth_ticklabels: A mapping from values to tick labels to use for the linewidth-mapped dimension. :param linestyle: If specified, the name of a dimension to use for mapping the line style of each line. If not a dimension, this is used as a constant line style for all lines. :type linestyle: str, optional :param linestyles: An explicit sequence of line styles to use for the linestyle-mapped dimension. :type linestyles: sequence, optional :param linestyle_order: An explicit order of values to use for the linestyle-mapped dimension. :type linestyle_order: sequence, optional :param linestyle_label: An alternate label to use for the linestyle-mapped dimension. :type linestyle_label: str, optional :param linestyle_ticklabels: A mapping from values to tick labels to use for the linestyle-mapped dimension. :type linestyle_ticklabels: dict or sequence, optional :param text: If specified, the name of a dimension to use for mapping text annotations to each line. :type text: str, optional :param text_formatter: A function to use to format data entries to text annotations. Default is ``str``. :type text_formatter: callable, optional :param text_opts: Additional keyword arguments to pass to the text plotting function. :type text_opts: dict, optional :param col: If specified, the name of a dimension to use for mapping the subplot column of each line. :type col: str, optional :param col_order: An explicit order of values to use for the col-mapped dimension. :type col_order: sequence, optional :param col_label: An alternate label to use for the col-mapped dimension. :type col_label: str, optional :param col_ticklabels: A mapping from values to tick labels to use for the col-mapped dimension. :type col_ticklabels: dict or sequence, optional :param row: If specified, the name of a dimension to use for mapping the subplot row of each line. :type row: str, optional :param row_order: An explicit order of values to use for the row-mapped dimension. :type row_order: sequence, optional :param row_label: An alternate label to use for the row-mapped dimension. :type row_label: str, optional :param row_ticklabels: A mapping from values to tick labels to use for the row-mapped dimension. :type row_ticklabels: dict or sequence, optional :param alpha: Global alpha value to use for all lines. :type alpha: float, optional :param join_across_missing: If True, join lines across missing (NaN) data. Default is False. :type join_across_missing: bool, optional :param err_band_alpha: Alpha value to use for error bands. :type err_band_alpha: float, optional :param err_bar_capsize: Size of the caps on error bars. :type err_bar_capsize: float, optional :param xlabel: Alternate label to use for the x-axis. :type xlabel: str, optional :param ylabel: Alternate label to use for the y-axis. :type ylabel: str, optional :param xlim: Limits to use for the x-axis. :type xlim: tuple, optional :param ylim: Limits to use for the y-axis. :type ylim: tuple, optional :param xscale: Scale to use for the x-axis, e.g. 'log'. :type xscale: str, optional :param yscale: Scale to use for the y-axis, e.g. 'log'. :type yscale: str, optional :param zscale: Scale to use for a heatmap color dimension, e.g. 'log'. :type zscale: str, optional :param xbase: If ``xscale=='log'``, the log base to use for the x-axis. :type xbase: float, optional :param ybase: If ``yscale=='log'``, the log base to use for the y-axis. :type ybase: float, optional :param xticks: Manual sequence of x-values to use for ticks. :type xticks: sequence[float], optional :param yticks: Manual sequence of y-values to use for ticks. :type yticks: sequence[float], optional :param xticklabels: Manual sequence of x-tick labels to use, requires and should be the same length as ``xticks``. :type xticklabels: sequence[str], optional :param yticklabels: Manual sequence of y-tick labels to use, requires and should be the same length as ``yticks``. :type yticklabels: sequence[str], optional :param vspans: Sequence of x-values to use for vertical spans. :type vspans: sequence[float], optional :param hspans: Sequence of y-values to use for horizontal spans. :type hspans: sequence[float], optional :param span_color: Color to use for spans. :type span_color: str or tuple, optional :param span_alpha: Alpha value to use for spans. :type span_alpha: float, optional :param span_linewidth: Line width to use for spans. :type span_linewidth: float, optional :param span_linestyle: Line style to use for spans. :type span_linestyle: str, optional :param grid: Whether to show grid lines. :type grid: bool, optional :param grid_which: Which grid lines to show, either 'major' or 'minor'. :type grid_which: str, optional :param grid_alpha: Alpha value to use for grid lines. :type grid_alpha: float, optional :param legend: Whether to show a legend. :type legend: bool, optional :param legend_ncol: Number of columns to use for the legend. :type legend_ncol: int, optional :param legend_merge: If ``True``, combinations of different mapped properties are merged into list of every combination. :type legend_merge: bool, optional :param legend_reverse: If ``True``, reverse the order of the legend entries. :type legend_reverse: bool, optional :param legend_entries: An explicit sequence of legend entries to use. :type legend_entries: sequence, optional :param legend_labels: An explicit sequence of legend labels to use. :type legend_labels: sequence, optional :param legend_extras: An explicit sequence of extra legend items to add. :type legend_extras: sequence, optional :param legend_opts: Additional keyword arguments to pass to the legend plotting function. :type legend_opts: dict, optional :param title: A title to use for the plot. :type title: str, optional :param axs: An explicit array of axes to use for the plot, it should have at least as many rows and columns as there are mapped dimensions. :type axs: sequence[sequence[matplotlib.Axes]], optional :param ax: Shortcut for supplying a single axes to use for the plot, can only supply if there is a single row and column. :type ax: matplotlib.Axes, optional :param format_axs: Whether to format the axes to use the neutral xyzpy style. :type format_axs: bool, optional :param figsize: Size of the figure to use if creating one (ax is axs is None). If not specified it is automatically computed based on the number of rows and columns. :type figsize: tuple, optional :param height: Height of each subplot. Default is 3. :type height: float, optional :param width: Width of each subplot. If not specified, it is automatically set to match ``height``. Default is None. :type width: float, optional :param hspace: Spacing between subplots vertically. Default is 0.12. :type hspace: float, optional :param wspace: Spacing between subplots horizontally. Default is 0.12. :type wspace: float, optional :param sharex: Whether to share the x-axis between subplots. Default is True. :type sharex: bool, optional :param sharey: Whether to share the y-axis between subplots. Default is True. :type sharey: bool, optional :param kwargs: Additional keyword arguments to pass to the main plotting function. :type kwargs: dict, optional :returns: * **fig** (*matplotlib.Figure*) -- Figure containing the plot (None if ``ax`` or ``axs`` is specified). * **axs** (*sequence[sequence[matplotlib.Axes]]*) -- Array of axes containing the plot.