diff --git a/pygmt/base_plotting.py b/pygmt/base_plotting.py index 64dfbbbbf5d..90648e02d6a 100644 --- a/pygmt/base_plotting.py +++ b/pygmt/base_plotting.py @@ -361,8 +361,8 @@ def plot(self, x=None, y=None, data=None, sizes=None, direction=None, **kwargs): Parameters ---------- - x, y : 1d arrays - Arrays of x and y coordinates of the data points. + x, y : float or 1d arrays + The x and y coordinates, or arrays of x and y coordinates of the data points data : str or 2d array Either a data file name or a 2d numpy array with the tabular data. Use option *columns* (i) to choose which columns are x, y, color, @@ -426,7 +426,9 @@ def plot(self, x=None, y=None, data=None, sizes=None, direction=None, **kwargs): elif kind == "matrix": file_context = lib.virtualfile_from_matrix(data) elif kind == "vectors": - file_context = lib.virtualfile_from_vectors(x, y, *extra_arrays) + file_context = lib.virtualfile_from_vectors( + np.atleast_1d(x), np.atleast_1d(y), *extra_arrays + ) with file_context as fname: arg_str = " ".join([fname, build_arg_string(kwargs)]) diff --git a/pygmt/tests/baseline/test_plot_scalar_xy.png b/pygmt/tests/baseline/test_plot_scalar_xy.png new file mode 100644 index 00000000000..44d36d4dea2 Binary files /dev/null and b/pygmt/tests/baseline/test_plot_scalar_xy.png differ diff --git a/pygmt/tests/test_plot.py b/pygmt/tests/test_plot.py index 9233aa97786..e1f842b4642 100644 --- a/pygmt/tests/test_plot.py +++ b/pygmt/tests/test_plot.py @@ -256,3 +256,14 @@ def test_plot_vectors(): frame="af", ) return fig + + +@pytest.mark.mpl_image_compare +def test_plot_scalar_xy(): + "Plot symbols given scalar x, y coordinates" + fig = Figure() + fig.basemap(region=[-2, 2, -2, 2], frame=True) + fig.plot(x=-1.5, y=1.5, style="c1c") + fig.plot(x=0, y=0, style="t1c") + fig.plot(x=1.5, y=-1.5, style="s1c") + return fig