diff --git a/dvc/command/plots.py b/dvc/command/plots.py index 7bb96068c5..3edbde2cdf 100644 --- a/dvc/command/plots.py +++ b/dvc/command/plots.py @@ -197,8 +197,8 @@ def _add_props_arguments(parser): help="Provided CSV ot TSV datafile does not have a header.", ) parser.add_argument("--title", default=None, help="Plot title.") - parser.add_argument("--xlab", default=None, help="X axis title.") - parser.add_argument("--ylab", default=None, help="Y axis title.") + parser.add_argument("--x-label", default=None, help="X axis label.") + parser.add_argument("--y-label", default=None, help="Y axis lebel.") def _add_output_arguments(parser): diff --git a/dvc/output/base.py b/dvc/output/base.py index c651d570a4..fe3c77c664 100644 --- a/dvc/output/base.py +++ b/dvc/output/base.py @@ -58,8 +58,8 @@ class BaseOutput: PARAM_PLOT_TEMPLATE = "template" PARAM_PLOT_X = "x" PARAM_PLOT_Y = "y" - PARAM_PLOT_XLAB = "xlab" - PARAM_PLOT_YLAB = "ylab" + PARAM_PLOT_X_LABEL = "x_label" + PARAM_PLOT_Y_LABEL = "y_label" PARAM_PLOT_TITLE = "title" PARAM_PLOT_CSV_HEADER = "csv_header" PARAM_PERSIST = "persist" diff --git a/dvc/repo/plots/template.py b/dvc/repo/plots/template.py index 0691492922..939cfac14b 100644 --- a/dvc/repo/plots/template.py +++ b/dvc/repo/plots/template.py @@ -38,8 +38,8 @@ class Template: X_ANCHOR = "" Y_ANCHOR = "" TITLE_ANCHOR = "" - X_TITLE_ANCHOR = "" - Y_TITLE_ANCHOR = "" + X_LABEL_ANCHOR = "" + Y_LABEL_ANCHOR = "" def __init__(self, templates_dir): self.plot_templates_dir = templates_dir @@ -119,15 +119,15 @@ def _check_field_exists(data, field): @staticmethod def _replace_metadata_anchors(result_content, props): props.setdefault("title", "") - props.setdefault("xlab", props.get("x")) - props.setdefault("ylab", props.get("y")) + props.setdefault("x_label", props.get("x")) + props.setdefault("y_label", props.get("y")) replace_pairs = [ (Template.TITLE_ANCHOR, "title"), (Template.X_ANCHOR, "x"), (Template.Y_ANCHOR, "y"), - (Template.X_TITLE_ANCHOR, "xlab"), - (Template.Y_TITLE_ANCHOR, "ylab"), + (Template.X_LABEL_ANCHOR, "x_label"), + (Template.Y_LABEL_ANCHOR, "y_label"), ] for anchor, key in replace_pairs: value = props.get(key) @@ -170,12 +170,12 @@ class DefaultLinearTemplate(Template): "x": { "field": Template.X_ANCHOR, "type": "quantitative", - "title": Template.X_TITLE_ANCHOR, + "title": Template.X_LABEL_ANCHOR, }, "y": { "field": Template.Y_ANCHOR, "type": "quantitative", - "title": Template.Y_TITLE_ANCHOR, + "title": Template.Y_LABEL_ANCHOR, "scale": {"zero": False}, }, "color": {"field": "rev", "type": "nominal"}, @@ -195,13 +195,13 @@ class DefaultConfusionTemplate(Template): "field": Template.X_ANCHOR, "type": "nominal", "sort": "ascending", - "title": Template.X_TITLE_ANCHOR, + "title": Template.X_LABEL_ANCHOR, }, "y": { "field": Template.Y_ANCHOR, "type": "nominal", "sort": "ascending", - "title": Template.Y_TITLE_ANCHOR, + "title": Template.Y_LABEL_ANCHOR, }, "color": {"aggregate": "count", "type": "quantitative"}, "facet": {"field": "rev", "type": "nominal"}, @@ -220,12 +220,12 @@ class DefaultScatterTemplate(Template): "x": { "field": Template.X_ANCHOR, "type": "quantitative", - "title": Template.X_TITLE_ANCHOR, + "title": Template.X_LABEL_ANCHOR, }, "y": { "field": Template.Y_ANCHOR, "type": "quantitative", - "title": Template.Y_TITLE_ANCHOR, + "title": Template.Y_LABEL_ANCHOR, "scale": {"zero": False}, }, "color": {"field": "rev", "type": "nominal"}, @@ -275,6 +275,7 @@ def get_template(self, path): def __init__(self, dvc_dir): self.dvc_dir = dvc_dir + print("PlotTemplates.__init__") if not os.path.exists(self.templates_dir): makedirs(self.templates_dir, exist_ok=True) diff --git a/dvc/schema.py b/dvc/schema.py index 0a89b72679..3fb762b022 100644 --- a/dvc/schema.py +++ b/dvc/schema.py @@ -34,8 +34,8 @@ BaseOutput.PARAM_PLOT_TEMPLATE: str, BaseOutput.PARAM_PLOT_X: str, BaseOutput.PARAM_PLOT_Y: str, - BaseOutput.PARAM_PLOT_XLAB: str, - BaseOutput.PARAM_PLOT_YLAB: str, + BaseOutput.PARAM_PLOT_X_LABEL: str, + BaseOutput.PARAM_PLOT_Y_LABEL: str, BaseOutput.PARAM_PLOT_TITLE: str, BaseOutput.PARAM_PLOT_CSV_HEADER: bool, } diff --git a/scripts/completion/dvc.bash b/scripts/completion/dvc.bash index 3ed31bcfec..a24ea85a5e 100644 --- a/scripts/completion/dvc.bash +++ b/scripts/completion/dvc.bash @@ -47,8 +47,9 @@ _dvc_move_COMPGEN=_dvc_compgen_files _dvc_params='diff' _dvc_params_diff='--all --show-json --show-md --no-path' _dvc_plots='show diff' -_dvc_plots_show='-t --template -o --out -x -y --show-json --no-csv-header --title --xlab --ylab' -_dvc_plots_diff='-t --template --targets -o --out -x -y --show-json --no-csv-header --title --xlab --ylab' +_dvc_plots_show='-t --template -o --out -x -y --show-json --no-csv-header --title --x-label --y-label' +_dvc_plots_diff='-t --template --targets -o --out -x -y --show-json --no-csv-header --title --x-label --y-label' +_dvc_plots_modify='-t --template -x -y --no-csv-header --title --x-label --y-label' _dvc_pull='-j --jobs -r --remote -a --all-branches -T --all-tags -f --force -d --with-deps -R --recursive' _dvc_pull_COMPGEN=_dvc_compgen_DVCFiles _dvc_push='-j --jobs -r --remote -a --all-branches -T --all-tags -d --with-deps -R --recursive' diff --git a/scripts/completion/dvc.zsh b/scripts/completion/dvc.zsh index d37ce5426e..5097a1f4f7 100644 --- a/scripts/completion/dvc.zsh +++ b/scripts/completion/dvc.zsh @@ -217,7 +217,7 @@ _dvc_push=( ) _dvc_plots=( - "1:Sub command:(show diff)" + "1:Sub command:(show diff modify)" ) _dvc_remote=( diff --git a/tests/func/plots/test_plots.py b/tests/func/plots/test_plots.py index 6916a18a0a..75835e6365 100644 --- a/tests/func/plots/test_plots.py +++ b/tests/func/plots/test_plots.py @@ -50,8 +50,8 @@ def test_plot_csv_one_column(tmp_dir, scm, dvc, run_copy_metrics): props = { "csv_header": False, - "xlab": "x_title", - "ylab": "y_title", + "x_label": "x_title", + "y_label": "y_title", "title": "mytitle", } plot_string = dvc.plots.show(props=props)["metric.csv"] diff --git a/tests/unit/command/test_plots.py b/tests/unit/command/test_plots.py index 69b8a1ac89..4c1776c1b1 100644 --- a/tests/unit/command/test_plots.py +++ b/tests/unit/command/test_plots.py @@ -20,9 +20,9 @@ def test_metrics_diff(dvc, mocker): "y_field", "--title", "my_title", - "--xlab", + "--x-label", "x_title", - "--ylab", + "--y-label", "y_title", "HEAD", "tag1", @@ -47,8 +47,8 @@ def test_metrics_diff(dvc, mocker): "x": "x_field", "y": "y_field", "title": "my_title", - "xlab": "x_title", - "ylab": "y_title", + "x_label": "x_title", + "y_label": "y_title", }, )