Matplotlib scatter plot

I enjoy using matplotlib for crafting impressive scatter plots in my notebooks. Despite its complex syntax, MLJAR Studio simplifies with code recipes, auto-imports packages, and clickable notes for easy navigation to detailed documentation.

This notebook was created with MLJAR Studio

MLJAR Studio is Python code editior with interactive code recipes and local AI assistant.
You have code recipes UI displayed at the top of code cells.


Please note that all required packages are automatically imported by MLJAR Studio for you. What is more, I left side notes in left, with cookbook names so you can easily navigate to recipes. They are clickable, try it to open documentation.

# import packages
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D
import matplotlib.colors as mcolors
# load example dataset
df = pd.read_csv("", skipinitialspace=True)
# display first rows
# create mapping between values and colors
labels = df["class"].unique().tolist()
colors = list(mcolors.TABLEAU_COLORS.keys())
color_map = {l: colors[i%len(colors)] for i,l in enumerate(labels)}
# create scatter
plt.scatter(df["sepal length (cm)"], df["sepal width (cm)"], color=df["class"].map(color_map))
# add legend box
handles = [Line2D([0], [0], marker='o', color='w', markerfacecolor=v, label=k, markersize=8) for k, v in color_map.items()]
plt.legend(handles=handles, loc="best")
# display plot


Using Python and matplotlib can be a great fun. Scatter plots are beautiful, but there are plenty of other plots in the matplotlib package, I hope they will be available soon in MLJAR Studio as recipes.

Good luck! ๐Ÿ˜Š

Recipes used in the matplotlib-scatter-plot.ipynb

All code recipes used in this notebook are listed below. You can click them to check their documentation.

Packages used in the matplotlib-scatter-plot.ipynb

List of packages that need to be installed in your Python environment to run this notebook. Please note that MLJAR Studio automatically installs and imports required modules for you.