GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • PYTHON CHARTS
  • matplotlib
  • seaborn
  • plotly
  • pandas
  • colors
  • COLORS
  • COLOR PALETTES
  • R CODER
  • R CHARTS
  • Contact
  • Español

This view

  • Original page
  • New address

GeezerVison is showing python-charts.com — Connected scatter plot in matplotlib

Search for a graph

HOME CORRELATION CONNECTED SCATTER PLOT MATPLOTLIB

Connected scatter plot in matplotlib

Sample data

Consider the following data for illustration purposes:

import numpy as np

# Seed
rng = np.random.RandomState(3)

# Data simulation
x = np.arange(1, 13)
y = np.cumsum(rng.normal(0, 1, size = 12)) + 10

Connected scatter plot in matplotlib

A connected scatter plot is a line chart where the individual data points are also marked, which is useful to show both the trend and the exact observations, especially when there are relatively few of them. Matplotlib does not need a dedicated function for it: just pass marker to the regular plot function.

import matplotlib.pyplot as plt

fig, ax = plt.subplots()
ax.plot(x, y, marker = "o")

# plt.show()

Connected scatter plot in matplotlib

Marker shape and size

Customize the markers the same way as in a regular scatter plot, with markersize and any of matplotlib’s marker shapes.

import matplotlib.pyplot as plt

fig, ax = plt.subplots()
ax.plot(x, y, marker = "D", markersize = 8)

# plt.show()

Marker shape and size of a connected scatter plot in matplotlib

Line and marker color

Set color for the line and markerfacecolor / markeredgecolor to style the markers independently.

import matplotlib.pyplot as plt

fig, ax = plt.subplots()
ax.plot(x, y, marker = "o", color = "#4C72B0",
       markerfacecolor = "white", markeredgewidth = 2)

# plt.show()

Line and marker colors of a connected scatter plot in matplotlib

Line style

Change the line style with linestyle, for example to a dashed line.

import matplotlib.pyplot as plt

fig, ax = plt.subplots()
ax.plot(x, y, marker = "o", linestyle = "--")

# plt.show()

Line style of a connected scatter plot in matplotlib

Highlighting a point

Overlay a second scatter call on top of the specific point (for example the maximum) to highlight it with a different color and size.

import matplotlib.pyplot as plt
import numpy as np

fig, ax = plt.subplots()
ax.plot(x, y, marker = "o")

i = np.argmax(y)
ax.scatter(x[i], y[i], color = "#C44E52", s = 100, zorder = 3)

# plt.show()

Highlighting a point of a connected scatter plot in matplotlib

R CODER website
Storytelling with Data

Storytelling with Data

A Data Visualization Guide for Business Professionals

Buy on Amazon
Better Data Visualizations

Better Data Visualizations

A Guide for Scholars, Researchers, and Wonks

Buy on Amazon

See also

Hexbin chart in matplotlib

Hexbin chart in matplotlib

Heat map in seaborn with the heatmap function

Heat map in seaborn with the heatmap function

Histograms in plotly

Histograms in plotly

2D histogram in matplotlib

2D histogram in matplotlib

3D surface plot in matplotlib

3D surface plot in matplotlib

Pairs plot (pairwise plot) in seaborn with the pairplot function

Pairs plot (pairwise plot) in seaborn with the pairplot function

Heatmap clustering in seaborn with clustermap

Heatmap clustering in seaborn with clustermap

Scatter plot with regression line in seaborn

Scatter plot with regression line in seaborn

Heatmaps in plotly with imshow

Heatmaps in plotly with imshow

Scatter plot with marginal histograms in seaborn

Scatter plot with marginal histograms in seaborn

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.