Answers for "when we use scatter plot"

8

how to plot a scatter plot in matplotlib

# Import matplotlib
import matplotlib.pyplot as plt

# Set plot space as inline for inline plots and qt for external plots
%matplotlib inline


# Set the figure size in inches
plt.figure(figsize=(10,6))

plt.scatter(x, y, label = "label_name" )

# Set x and y axes labels
plt.xlabel('X Values')
plt.ylabel('Y Values')

plt.title('Scatter Title')
plt.legend()
plt.show()
Posted by: Guest on May-28-2020
0

Scatter graph

# the iris dataset is provided by R natively

# Create a color palette
library(paletteer)
colors <- paletteer_c(package = "ggthemes", palette = "Green-Blue-White", n = 3)

# Scatterplot with categoric color scale
plot(
  x = iris$Petal.Length, 
  y = iris$Petal.Width,
  bg = colors[ unclass(iris$Species) ],
  cex = 3,
  pch=21
)
Posted by: Guest on July-24-2021

Browse Popular Code Answers by Language