## Is there any way to use bivariate colormaps in matplotlib?

imshow can take an array of [r, g, b] entries. So you can convert the absolute values to intensities and phases – to hues. I will use as an example complex numbers, because for it it makes the most sense. If needed, you can always add numpy arrays Z = X + 1j * Y. … Read more

## Matplotlib ion() function fails to be interactive

I bumped into this link found here, which answers my problem. It seems that after turning on interactive mode through plt.ion(), pyplot needs to be paused temporarily for it to update/redraw itself through plt.pause(0.0001). Here is what I did and it works! >>> import matplotlib.pyplot as plt >>> import numpy as np >>> plt.ion() >>> … Read more

## Rotating axis text for each subplot

Just iterate through the axes tied to the figure, set the active axes to the iterated object, and modify: for ax in fig.axes: matplotlib.pyplot.sca(ax) plt.xticks(rotation=90)

## Remove the legend on a matplotlib figure

As of matplotlib v1.4.0rc4, a remove method has been added to the legend object. Usage: ax.get_legend().remove() or legend = ax.legend(…) … legend.remove() See here for the commit where this was introduced.

## matplotlib values under cursor [duplicate]

You simply need to re-assign ax.format_coord. See this example from the documentation. (code lifted directly from example) “”” Show how to modify the coordinate formatter to report the image “z” value of the nearest pixel given x and y “”” import numpy as np import matplotlib.pyplot as plt import matplotlib.cm as cm X = 10*np.random.rand(5,3) … Read more

## Adding a second y-axis related to the first y-axis

twin axis Adding a second y axis can be done by creating a twin axes, ax2 = ax.twinx(). The scale of this axes can be set using its limits, ax2.set_ylim(y2min, y2max). The values of y2min, y2max can be calculated using some known relationship (e.g. implemented as a function) from the limits of the left axis. … Read more

## How do I include a matplotlib Figure object as subplot? [duplicate]

You can’t put a figure in a figure. You should modify your plotting functions to take axes objects as an argument. I am also unclear why the kwarg figure is there, I think it is an artifact of the way that inheritance works, the way that the documentation is auto-generated, and the way some of … Read more

## Matplotlib Colormap with two parameter

In general colormaps in matplotlib are 1D, i.e. they map a scalar to a color. In order to obtain a 2D colormap one would need to somehow invent a mapping of two scalars to a color. While this is in principle possible, it’s not as convenient as the usual colormaps. An example is below, where … Read more

## vertical & horizontal lines in matplotlib

The pyplot functions you are calling, axhline() and axvline() draw lines that span a portion of the axis range, regardless of coordinates. The parameters xmin or ymin use value 0.0 as the minimum of the axis and 1.0 as the maximum of the axis. Instead, use plt.plot((x1, x2), (y1, y2), ‘k-‘) to draw a line … Read more

## Matplotlib multiple animate multiple lines

The Matplotlib documentation for the line2d artist explains how set_data works. It “ACCEPTS: 2D array (rows are x, y) or two 1D arrays.” It also works with lists. You’ve given it a four element list instead. You need to set the x and y data of each line separately. I’ve included an example with fake … Read more