close

[Solved] MatPlotLib: Multiple datasets on the same scatter plot

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error MatPlotLib: Multiple datasets on the same scatter plot in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How MatPlotLib: Multiple datasets on the same scatter plot Error Occurs?

Today I get the following error MatPlotLib: Multiple datasets on the same scatter plot in python.

How To Solve MatPlotLib: Multiple datasets on the same scatter plot Error ?

  1. How To Solve MatPlotLib: Multiple datasets on the same scatter plot Error ?

    To Solve MatPlotLib: Multiple datasets on the same scatter plot Error Although accepted answer works good but with matplotlib version 2.1.0, it is pretty straight forward to have two scatter plots in one plot without using a reference to Axes

  2. MatPlotLib: Multiple datasets on the same scatter plot

    To Solve MatPlotLib: Multiple datasets on the same scatter plot Error Although accepted answer works good but with matplotlib version 2.1.0, it is pretty straight forward to have two scatter plots in one plot without using a reference to Axes

Solution 1

I came across this question as I had exact same problem. Although accepted answer works good but with matplotlib version 2.1.0, it is pretty straight forward to have two scatter plots in one plot without using a reference to Axes

import matplotlib.pyplot as plt

plt.scatter(x,y, c='b', marker='x', label='1')
plt.scatter(x, y, c='r', marker='s', label='-1')
plt.legend(loc='upper left')
plt.show()

Solution 2

I don’t know, it works fine for me. Exact commands:

import scipy, pylab
ax = pylab.subplot(111)
ax.scatter(scipy.randn(100), scipy.randn(100), c='b')
ax.scatter(scipy.randn(100), scipy.randn(100), c='r')
ax.figure.show()

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read