How to connect subplots with a dotted line instead of a solid line in python? I used this site https://matplotlib.org/devdocs/gallery/subplots_axes_and_figures/subplots_demo.html to combine 3 scatter plots horizontally but they have a solid line between them. Is there a way to join them with a dotted line so it looks like a timeline,something like shown in this image
This can be done by customizing the example in the official reference and hiding the left and right sides of the graph frame.
This example only hides the frame, so the tick marks are still there and it looks like a dotted line. If you are happy with this, you can use it as is. If you want to customize it, you need to hide the ticks and add dotted lines with ax.vlines
or similar.
import matplotlib.pyplot as plt
import numpy as np
# Some example data to display
x = np.linspace(0, 2 * np.pi, 400)
y = np.sin(x ** 2)
fig = plt.figure()
gs = fig.add_gridspec(1,3, wspace=0)
axs = gs.subplots(sharex=True, sharey=True)
fig.suptitle('Sharing both axes')
axs[0].plot(x, y ** 2)
axs[1].plot(x, 0.3 * y, 'o')
axs[2].plot(x, y, '+')
axs[0].spines['right'].set_visible(False)
axs[1].spines['left'].set_visible(False)
axs[1].spines['right'].set_visible(False)
axs[1].spines['left'].set_visible(False)
axs[2].spines['left'].set_visible(False)
# Hide x labels and tick labels for all but bottom plot.
for ax in axs:
ax.label_outer()