Tags » MatPlotLib

Stacking density plots in 3D in Matplotlib

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

X,Y = np.meshgrid(np.linspace(0,1,100),np.linspace(0,1,100))

A1 = np.sin(X)*np.sin(Y)
A2 = np.sin(X)*np.cos(Y)
A3 = np.sin(10*X)*np.cos(10*Y)

fig = plt.figure(figsize=plt.figaspect(2)*1)
ax = fig.add_subplot(111, projection='3d')
ax.contourf(X, Y, A1, 100, zdir='z', offset=0)
ax.contourf(X, Y, A2, 100, zdir='z', offset=0.5)
ax.contourf(X, Y, A3, 100, zdir='z', offset=1)

ax.set_zlim((0.,1.5))

plt.show()
Computing

FITS (Part 4) : Histograms

In this part, we will learn how to get histogram of the FITS image :

Python

matplotlib.rc customizations for fonts

I’ve long struggled with modifying the fonts for matplotlib plots from the default “Bitstream Vera Sans” until I found this post recently.

The steps outlined there worked quite well for changing the general font used for the plots, but escaped math characters still would change to the default Computer Modern font. 352 more words

Creating a .mp4 and .gif

Matplotlb can certainly create animation, but sometimes it is hard to get that up and running (see other post on this). A more general way to make animations, is to create a .mp4 video or a .gif file from a series on .png files. 436 more words