Adding y=x to a matplotlib scatter plot if I haven’t kept track of all the data points that went in

You don’t need to know anything about your data per se. You can get away with what your matplotlib Axes object will tell you about the data. See below: import numpy as np import matplotlib.pyplot as plt # random data N = 37 x = np.random.normal(loc=3.5, scale=1.25, size=N) y = np.random.normal(loc=3.4, scale=1.5, size=N) c = … Read more

How to improve the label placement in scatter plot

Another option using my library adjustText, written specially for this purpose (https://github.com/Phlya/adjustText). from adjustText import adjust_text np.random.seed(2016) N = 50 scatter_data = np.random.rand(N, 3) fig, ax = plt.subplots() ax.scatter(scatter_data[:, 0], scatter_data[:, 1], c=scatter_data[:, 2], s=scatter_data[:, 2] * 150) labels = [‘ano_{}’.format(i) for i in range(N)] texts = [] for x, y, text in zip(scatter_data[:, 0], … Read more

Changing the background color of the axes planes of a 3D plot

Using the same example. You can set the pane color using the set_pane_color method as described here http://matplotlib.org/mpl_toolkits/mplot3d/api.html#axis3d. You can set the color using the RGBA tuple: # scatter3d_demo.py # … # Set the background color of the pane YZ ax.w_xaxis.set_pane_color((1.0, 1.0, 1.0, 1.0)) plt.show()