Reputation: 1443
I am curious about changing the colormap and the interpolation method for plotting a matrix
import matplotlib.pyplot as plt
matrix= [[1,2,3],
[4,5,6],
[7,8,9]]
plt.imshow(matrix,cmap="gray")
plt.show()
In the definition of plt.imshow
(in the file pyplot.py
) if found this code:
def imshow(
X, cmap=None, norm=None, aspect=None, interpolation=None,
alpha=None, vmin=None, vmax=None, origin=None, extent=None,
shape=None, filternorm=1, filterrad=4.0, imlim=None,
resample=None, url=None, *, data=None, **kwargs):
__ret = gca().imshow(
X, cmap=cmap, norm=norm, aspect=aspect,
interpolation=interpolation, alpha=alpha, vmin=vmin,
vmax=vmax, origin=origin, extent=extent, shape=shape,
filternorm=filternorm, filterrad=filterrad, imlim=imlim,
resample=resample, url=url, **({"data": data} if data is not
None else {}), **kwargs)
sci(__ret)
return __ret
However it only says cmap=None
and interpolation=None
.
I know that I can look up the options for these arguments in the internet ( e.g. https://matplotlib.org/gallery/images_contours_and_fields/interpolation_methods.html), but I would like to find the option possibilities of cmap and interpolation in the python code of matplotib itself, also to get more familiar with the data structure in python.
How can I "unearth" the options for these parameters in my code?
As an IDE I am using pycharm.
Upvotes: 0
Views: 2577
Reputation: 339660
I would recommend to use the online documentation of matplotlib, available at matplotlib.org.
On the homepage you may navigate to API
Then either look at the matplotlib.pyplot function reference or the list of matplotlib modules.
You would then arrive at the documentation page you're intested in, either
From there you obtain a complete overview over possible arguments and accepted values. You can directly check the source code
and often find examples of the usage linked.
Upvotes: 0
Reputation: 653
in your python session
help(plt.imshow)
in jupyter notebook
?plt.imshow
dont know about pycharm
Upvotes: 1