Is it possible to do additive blending with matplotlib?

If you only need an image as the result, you can get the canvas buffer as a numpy array, and then do the blending, here is an example: from matplotlib import pyplot as plt import numpy as np fig, ax = plt.subplots() ax.scatter(x1,y1,c=”b”,edgecolors=”none”) ax.set_xlim(-4, 4) ax.set_ylim(-4, 4) ax.patch.set_facecolor(“none”) ax.patch.set_edgecolor(“none”) fig.canvas.draw() w, h = fig.canvas.get_width_height() img … Read more

Overlay imshow plots in matplotlib

You can set the alpha argument in your imshow command. In your example, img3 = plt.imshow(zvals2, interpolation=’nearest’, cmap=cmap2, origin=’lower’, alpha=0.6) EDIT: Thanks for the clarification. Here is a description of what you can do: First, choose a matplotlib colormap object (in your case, for white and black, you can take the ‘binary’ colormap). Or create … Read more

Logscale plots with zero values in matplotlib

It’s easiest to use a “symlog” plot for this purpose. The interval near 0 will be on a linear scale, so 0 can be displayed. import matplotlib.pyplot as plt fig, ax = plt.subplots() ax.plot([0,1,2],[10,10,100],marker=”o”,linestyle=”-“) ax.set_yscale(‘symlog’) ax.set_xscale(‘symlog’) plt.show() Symlog sets a small interval near zero (both above and below) to use a linear scale. This allows … Read more

How to connect scatterplot points with line using matplotlib

I think @Evert has the right answer: plt.scatter(dates,values) plt.plot(dates, values) plt.show() Which is pretty much the same as plt.plot(dates, values, ‘-o’) plt.show() You can replace -o with another suitable format string as described in the documentation. You can also split the choices of line and marker styles using the linestyle= and marker= keyword arguments.

Plotting labeled intervals in matplotlib/gnuplot

Updated: Now includes handling the data sample and uses mpl dates functionality. import matplotlib.pyplot as plt from matplotlib.dates import DateFormatter, MinuteLocator, SecondLocator import numpy as np from StringIO import StringIO import datetime as dt ### The example data a=StringIO(“””a 10:15:22 10:15:30 OK b 10:15:23 10:15:28 OK c 10:16:00 10:17:10 FAILED b 10:16:30 10:16:50 OK “””) … Read more

matplotlib scatter plot colour as function of third variable [duplicate]

This works for me, using matplotlib 1.1: import numpy as np import matplotlib.pyplot as plt x = np.arange(10) y = np.sin(x) plt.scatter(x, y, marker=”+”, s=150, linewidths=4, c=y, cmap=plt.cm.coolwarm) plt.show() Result: Alternatively, for n points, make an array of RGB color values with shape (n, 3), and assign it to the edgecolors keyword argument of scatter(): … Read more