Answers for "plt.scatter python"

1

scatter plot of a dataframe in python

>>> ax2 = df.plot.scatter(x='length',
...                       y='width',
...                       c='species',
...                       colormap='viridis')
Posted by: Guest on December-17-2020
1

how to do scatter plot in pyplot

import numpy as npimport matplotlib.pyplot as plt
# Create data
N = 500x = np.random.rand(N)
y = np.random.rand(N)
colors = (0,0,0)
area = np.pi*3
# Plot
plt.scatter(x, y, s=area, c=colors, alpha=0.5)
plt.title('Scatter plot pythonspot.com')
plt.xlabel('x')
plt.ylabel('y')
plt.show()
Posted by: Guest on August-29-2020
1

matplotlib scatter plot python

import numpy as np
np.random.seed(19680801)
import matplotlib.pyplot as plt


fig, ax = plt.subplots()
for color in ['tab:blue', 'tab:orange', 'tab:green']:
    n = 750
    x, y = np.random.rand(2, n)
    scale = 200.0 * np.random.rand(n)
    ax.scatter(x, y, c=color, s=scale, label=color,
               alpha=0.3, edgecolors='none')

ax.legend()
ax.grid(True)

plt.show()
Posted by: Guest on September-10-2020
0

plt scatter

import matplotlib.pyplot as plt
import numpy as np

# Fixing random state for reproducibility
np.random.seed(19680801)


N = 100
r0 = 0.6
x = 0.9 * np.random.rand(N)
y = 0.9 * np.random.rand(N)
area = (20 * np.random.rand(N))**2  # 0 to 10 point radii
c = np.sqrt(area)
r = np.sqrt(x ** 2 + y ** 2)
area1 = np.ma.masked_where(r < r0, area)
area2 = np.ma.masked_where(r >= r0, area)
plt.scatter(x, y, s=area1, marker='^', c=c)
plt.scatter(x, y, s=area2, marker='o', c=c)
# Show the boundary between the regions:
theta = np.arange(0, np.pi / 2, 0.01)
plt.plot(r0 * np.cos(theta), r0 * np.sin(theta))

plt.show()
Posted by: Guest on June-22-2021
1

plt.scatter cmap

Here are shown all the diferent cmaps available:
https://matplotlib.org/stable/tutorials/colors/colormaps.html
Posted by: Guest on August-11-2021

Python Answers by Framework

Browse Popular Code Answers by Language