matplotlib has no attribute ‘pyplot’

I can import matplotlib but when I try to run the following: matplotlib.pyplot(x) I get: Traceback (most recent call last): File “<pyshell#31>”, line 1, in <module> matplotlib.pyplot(x) AttributeError: ‘module’ object has no attribute ‘pyplot’ Answer pyplot is a sub-module of matplotlib which doesn’t get imported with a simple import matplotlib. >>> import matplotlib >>> print … Read more

Defining a discrete colormap for imshow in matplotlib

I have a simple image that I’m showing with imshow in matplotlib. I’d like to apply a custom colormap so that values between 0-5 are white, 5-10 are red (very simple colors), etc. I’ve tried following this tutorial: with the following code: cdict = { ‘red’ : ((0., 0., 0.), (0.5, 0.25, 0.25), (1., … Read more

How to prevent overlapping x-axis labels in sns.countplot

For the plot sns.countplot(x=”HostRamSize”,data=df) I got the following graph with x-axis label mixing together, how do I avoid this? Should I change the size of the graph to solve this problem? Answer Having a Series ds like this import pandas as pd import seaborn as sns import matplotlib.pyplot as plt import numpy as np; np.random.seed(136) … Read more

ImportError: DLL load failed: The specified module could not be found

I have installed Python 2.5.4, Numpy 1.5.0 win32, Matplotlib 1.0.0 win32, pywin32 218. Still not able to plot graphs in Python. Here is the error I am getting : import pylab File “C:\Python25\lib\site-packages\”, line 1, in <module> from matplotlib.pylab import * File “C:\Python25\lib\site-packages\matplotlib\”, line 216, in <module> from matplotlib import mpl # pulls in most … Read more

Matplotlib: avoiding overlapping datapoints in a “scatter/dot/beeswarm” plot

When drawing a dot plot using matplotlib, I would like to offset overlapping datapoints to keep them all visible. For example, if I have: CategoryA: 0,0,3,0,5 CategoryB: 5,10,5,5,10 I want each of the CategoryA “0” datapoints to be set side by side, rather than right on top of each other, while still remaining distinct from … Read more

Cleanest way to hide every nth tick label in matplotlib colorbar?

The labels on my horizontal colorbar are too close together and I don’t want to reduce text size further: cbar = plt.colorbar(shrink=0.8, orientation=’horizontal’, extend=’both’, pad=0.02) I’d like to preserve all ticks, but remove every other label. Most examples I’ve found pass a user-specified list of strings to cbar.set_ticklabels(). I’m looking for a general solution. … Read more