With this code:
using Plots
pyplot()
p=plot(rand(2), rand(2), rand(2), seriestype=:path)
plot!(p, [1.0], [0.5], [1.0], seriestype=:scatter)
I get this warning:
'c' argument looks like a single numeric RGB or RGBA sequence, which should be avoided as value-mapping will have precedence in case its length matches with 'x' & 'y'. Please use a 2-D array with a single row if you really want to specify the same RGB or RGBA value for all points.
It doesn't seem to happen with gr(). Any insights on what the issue is or how to avoid it without switching to another backend?
Thanks!
I have the same problem. Even a more minimal code generates this warning
using Plots
pyplot()
scatter(rand(5)*5,rand(5)*5)
That's probably related to changes in matplotlib 3.0.0. Thanks for reporting!
I got the same problem, and if you want a temporary solution add c = [1] (i.e. scatter(rand(5)*5,rand(5)*5),c= [1]) -- the default is that c is a numeric value and the change is that c essentially needs to be a vector now. So when you're not specifying it, it's taking the default numerical value.
Changing this line https://github.com/JuliaPlots/Plots.jl/blob/c26689fcb1d3f1054c739dbf8878ce717521667a/src/backends/pyplot.jl#L500
toextrakw[:c] = [py_color_fix(markercolor, x)] seems to work, based on my very limited testing. Also not sure how it would interact with older matplotlib installations.
Great! We don't need backwards compatibility for matplotlib. Feel like making a PR we can test? :grinning:
Voila. Nothing like web-editing a bit of code...
PS: the fix in #1854 can be applied to the Julia-0.6 Plots.jl as well.
Is this fix released yet? It is still affecting my installation.
I just tagged a release with the fix.
I just started getting this error. I'm running on Linux.
Name: matplotlib
Version: 3.0.2
Summary: Python plotting package
Home-page: http://matplotlib.org
Author: John D. Hunter, Michael Droettboom
Author-email: [email protected]
License: BSD
Location: /usr/local/lib/python3.5/dist-packages
Requires: python-dateutil, cycler, numpy, pyparsing, kiwisolver
Required-by: seaborn, filterpy, cvutils
The code that generated it:
from matplotlib.colors import ListedColormap
X_set, y_set = X_train, y_train
X1, X2 = np.meshgrid(np.arange(start = X_set[:, 0].min() - 1, stop = X_set[:, 0].max() + 1, step = 0.01),
np.arange(start = X_set[:, 1].min() - 1, stop = X_set[:, 1].max() + 1, step = 0.01))
plt.contourf(X1, X2, classifier.predict(np.array([X1.ravel(), X2.ravel()]).T).reshape(X1.shape),
alpha = 0.75, cmap = ListedColormap(('red', 'green')))
plt.xlim(X1.min(), X1.max())
plt.ylim(X2.min(), X2.max())
for i, j in enumerate(np.unique(y_set)):
plt.scatter(X_set[y_set == j, 0], X_set[y_set == j, 1],
c = ListedColormap(('red', 'green'))(i), label = j)
plt.title('SVM (Training set)')
plt.xlabel('Age')
plt.ylabel('Estimated Salary')
plt.legend()
plt.show()
@darrahts I think you are in the wrong repo. This is the repo of the Julia package Plots.jl, whereas your code appears to be Python and using the matplotlib package. Also, this issue is closed.
Most helpful comment
I got the same problem, and if you want a temporary solution add
c = [1](i.e.scatter(rand(5)*5,rand(5)*5),c= [1])-- the default is thatcis a numeric value and the change is that c essentially needs to be a vector now. So when you're not specifying it, it's taking the default numerical value.