Fix Python – Specify format of floats for tick labels

I am trying to set the format to two decimal numbers in a matplotlib subplot environment. Unfortunately, I do not have any idea how to solve this task.
To prevent using scientific notation on the y-axis I used ScalarFormatter(useOffset=False) as you can see in my snippet below. I think my task should be solved by passing further options/arguments ….

Fix Python – How can I set the ‘backend’ in matplotlib in Python?

I am new user of matplotlib, my platform is Ubuntu 10.04 Python 2.6.5
This is my code
import matplotlib
import matplotlib.pyplot as plt

The error is:
/usr/local/lib/python2.6/dist-packages/matplotlib/backends/ UserWarning:
Your currently selected backend, ‘agg’ does not support show().

Fix Python – Change values on matplotlib imshow() graph axis

Say I have some input data:
data = np.random.normal(loc=100,scale=10,size=(500,1,32))
hist = np.ones((32,20)) # initialise hist
for z in range(32):
hist[z],edges = np.histogram(data[:,0,z],bins=np.arange(80,122,2))

I can plot it using imshow():


However, the x-axis values do not match the input data (i…..

Fix Python – Scatter plot and Color mapping in Python

I have a range of points x and y stored in numpy arrays.
Those represent x(t) and y(t) where t=0…T-1
I am plotting a scatter plot using
import matplotlib.pyplot as plt


I would like to have a colormap representing the time (therefore coloring the points depending on the index in the numpy arrays)
What is the easiest….

Fix Python – How to plot two columns of a pandas data frame using points

I have a pandas dataframe and would like to plot values from one column versus the values from another column. Fortunately, there is plot method associated with the data-frames that seems to do what I need:
df.plot(x=’col_name_1′, y=’col_name_2′)

Unfortunately, it looks like among the plot styles (listed here after the kind parameter) there are n….

Fix Python – sklearn plot confusion matrix with labels

I want to plot a confusion matrix to visualize the classifer’s performance, but it shows only the numbers of the labels, not the labels themselves:
from sklearn.metrics import confusion_matrix
import pylab as pl
y_test=[‘business’, ‘business’, ‘business’, ‘business’, ‘business’, ‘business’, ‘business’, ‘business’, ‘business’, ‘business’, ‘business….

Fix Python – How can I make a blank subplot in matplotlib?

I am making a group of subplot (say, 3 x 2) in matplotlib, but I have fewer than 6 datasets. How can I make the remaining subplot blank?
The arrangement looks like this:
| 0,0| 0,1|
| 1,0| 1,1|
| 2,0| 2,1|

This may go on for several pages, but on the final page, there are, for example, 5 datasets to….

Fix Python – How can I make a scatter plot colored by density in matplotlib?

I’d like to make a scatter plot where each point is colored by the spatial density of nearby points.
I’ve come across a very similar question, which shows an example of this using R:
R Scatter Plot: symbol color represents number of overlapping points
What’s the best way to accomplish something similar in python using matplotlib?