I get inconsistent behavior when plotting multiple sets of data with plt.hist. 
Here's a quick example:

>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> x = np.random.randn(10)
>>> y = np.random.randn(9)
>>> plt.hist([x, y])

The above code plots two sets of histograms, as expected. My data sets have 
different lengths, but by coincidence, I had two data sets with the same 
length. When you call hist on data sets with the same length

>>> plt.hist([x[:-1], y])

then hist actually transposes the data; for the above, you get 9 sets of data 
instead of two.

Below is a patch that fixes the issue, but unfortunately, it'll probably break 
other peoples' code; in fact, it breaks the example code 
(histogram_demo_extended.py). I'm not sure what's worse: dealing with the 
inconsistency or breaking a lot of code. But if there's a time to break code, 
MPL 1.0 might be it :)

Best,
-Tony


Index: lib/matplotlib/axes.py
===================================================================
--- lib/matplotlib/axes.py      (revision 8187)
+++ lib/matplotlib/axes.py      (working copy)
@@ -7122,7 +7122,7 @@
 
         try:
             # make sure a copy is created: don't use asarray
-            x = np.transpose(np.array(x))
+            x = np.array(x)
             if len(x.shape)==1:
                 x.shape = (1,x.shape[0])
             elif len(x.shape)==2 and x.shape[1]<x.shape[0]:


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to