plot: Reproducible plots from a table.
Code author: Ueli Sauter, Peter Kraus
The function dgpost.utils.plot.plot()
processes the below specification
in order to generate a plot:
- pydantic model dgbowl_schemas.dgpost.recipe_1_1.plot.Plot
Show JSON schema
{ "title": "Plot", "type": "object", "properties": { "table": { "title": "Table", "type": "string" }, "ax_args": { "title": "Ax Args", "type": "array", "items": { "$ref": "#/definitions/AxArgs" } }, "fig_args": { "title": "Fig Args", "type": "object" }, "style": { "title": "Style", "type": "object" }, "nrows": { "title": "Nrows", "default": 1, "type": "integer" }, "ncols": { "title": "Ncols", "default": 1, "type": "integer" }, "save": { "$ref": "#/definitions/PlotSave" } }, "required": [ "table", "ax_args" ], "additionalProperties": false, "definitions": { "SeriesIndex": { "title": "SeriesIndex", "type": "object", "properties": { "from_zero": { "title": "From Zero", "default": true, "type": "boolean" }, "to_units": { "title": "To Units", "type": "string" } }, "additionalProperties": false }, "Series": { "title": "Series", "type": "object", "properties": { "y": { "title": "Y", "type": "string" }, "x": { "title": "X", "type": "string" }, "kind": { "title": "Kind", "default": "scatter", "enum": [ "scatter", "line", "errorbar" ], "type": "string" }, "index": { "title": "Index", "default": { "from_zero": true, "to_units": null }, "allOf": [ { "$ref": "#/definitions/SeriesIndex" } ] } }, "required": [ "y" ] }, "AxArgs": { "title": "AxArgs", "type": "object", "properties": { "cols": { "title": "Cols", "type": "array", "minItems": 2, "maxItems": 2, "items": [ { "type": "integer" }, { "type": "integer" } ] }, "rows": { "title": "Rows", "type": "array", "minItems": 2, "maxItems": 2, "items": [ { "type": "integer" }, { "type": "integer" } ] }, "series": { "title": "Series", "type": "array", "items": { "$ref": "#/definitions/Series" } }, "methods": { "title": "Methods", "type": "object" }, "legend": { "title": "Legend", "default": false, "type": "boolean" } }, "required": [ "series" ] }, "PlotSave": { "title": "PlotSave", "type": "object", "properties": { "as": { "title": "As", "type": "string" }, "tight_layout": { "title": "Tight Layout", "type": "object" } }, "required": [ "as" ] } } }
- field table: str [Required]
- field ax_args: Sequence[dgbowl_schemas.dgpost.recipe_1_1.plot.AxArgs] [Required]
- field fig_args: Optional[Dict[str, Any]] = None
- field style: Optional[Dict[str, Any]] = None
- field nrows: int = 1
- field ncols: int = 1
- field save: Optional[dgbowl_schemas.dgpost.recipe_1_1.plot.PlotSave] = None
- dgpost.utils.plot.apply_plot_style(style)
Updates the plot style with the given dictionary. For available kwargs see
matplotlib.rcParams
. If style is None, applies/resets to the default matplotlib style.- Parameters
style (
dict
) – A dictionary object containing valid key/value pairs.- Return type
None
- dgpost.utils.plot.plt_axes(ax, table, ax_args)
Processes ax_args and plots the data
- Parameters
ax (
Axes
) – axes object to be plotted totable (
DataFrame
) – dataframe containing the dataax_args (
dict
) – arguments for the axes
- Returns
ret – True if axes contain only timeseries as x-axis, False otherwise.
- Return type
bool
- dgpost.utils.plot.plot(table, ax_args, save, style=None, fig_args=None, **grid_args)