Matplotlib Scatter Plot Color By Label
Matplotlib scatter has a parameter c which allows an array like or a list of colors.
Matplotlib scatter plot color by label. Scatter x y c color s scale label color alpha 0 3 edgecolors none ax. Import matplotlib pyplot as plt x 1 2 3 4 y 4 1 3 6 plt scatter x y c coral x 5 6 7 8 y 1 3 5 2 plt scatter x y c lightblue plt title nuage de points avec matplotlib plt xlabel x plt ylabel y plt savefig scatterplot 05 png plt show. How to create a scatter plot with several colors in matplotlib. Plt plot group x group y marker o linestyle markersize 12 label name plt legend you can find more python tutorials here.
Used matplotlib version 3 x. N 750 x y np. Rand 100 area np. View all code on this notebook.
Randint 100 600 100 continent north america europe asia australia 25 df pd. Add text to plot. Use plt text x y text. See all options you can pass to plt text here.
Import matplotlib pyplot as plt groups df groupby z for name group in groups. Import numpy as np np. Subplots for color in tab blue tab orange tab green. Add text to plot.
Valid keyword args for plt txt. Matplotlib scatter plot with legend 5 answers closed 3 years ago. The code below defines a colors dictionary to map your continent colors to the plotting colors. Seed 19680801 import matplotlib pyplot as plt fig ax plt.
Add labels to line plots. The following code shows how to create a scatterplot using the variable z to color the markers based on category. Import matplotlib pyplot as plt import numpy as np import pandas as pd population np. Rand 2 n scale 200 0 np.