Are you struggling to create a scatter plot with Matplotlib? Look no further! In this article, we'll show you how to easily create a scatter plot using
matplotlib, the popular data visualization library in Python.
import matplotlib.pyplot as plt import numpy as np # Generate random X and Y values x = np.random.randn(1000) y = np.random.randn(1000) # Create customized scatter plot plt.scatter(x = x, y = y, c = 'r', marker = 'x') plt.xlabel('x') plt.ylabel('y') plt.title('Scatter Plot') plt.show()
- Import the necessary libraries, including
matplotlib, using the alias
- Create your data to be plotted. In this case we’re using NumPy to generate random numbers. You could also import a CSV file, or load data from a database, data warehouse, or data lake.
- Use the
plt.scatter()function from Matplotlib to create a scatter plot of your data.
- Customize the appearance of your scatter plot using various parameters, such as
cfor color and
- Add labels to the x and y-axis and a title to the graph.
- Show your plot using the
plt.show()function from Matplotlib.
Einblick is an agile data science platform that provides data scientists with a collaborative workflow to swiftly explore data, build predictive models, and deploy data apps. Founded in 2020, Einblick was developed based on six years of research at MIT and Brown University. Einblick customers include Cisco, DARPA, Fuji, NetApp and USDA. Einblick is funded by Amplify Partners, Flybridge, Samsung Next, Dell Technologies Capital, and Intel Capital. For more information, please visit www.einblick.ai and follow us on LinkedIn and Twitter.