2825 explained code solutions for 75 technologies


python-matplotlibHow to set colormap


import numpy as np
import matplotlib.pyplot as plt

data = np.random.randn(30, 30)

plt.pcolormesh(data, cmap='magma', rasterized=True, vmin=-4, vmax=4)
plt.show()ctrl + c
import matplotlib.pyplot as plt

loads Matplotlib module to use plotting capabilities

import numpy as np

load Numpy module for Python

np.random.randn(30, 30)

generate random matrix 30x30 in size

pcolormesh

create pseudo color plot

cmap

set colormap to use

.show()

render chart in a separate window


How to set colormap, python matplotlib

Usage example

import numpy as np
import matplotlib.pyplot as plt

data = np.random.randn(30, 30)

plt.pcolormesh(data, cmap='magma', rasterized=True, vmin=-4, vmax=4)
plt.show()