From f4782dad1902e9d6398607e85c714607fe9aaa47 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Fri, 22 Aug 2014 12:52:49 -0400 Subject: [PATCH 1/2] DOC : add note about np.matrix and pandas objects There is no intentional support for np.matrix or pandas data objects as input to plotting functions. --- doc/faq/usage_faq.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/faq/usage_faq.rst b/doc/faq/usage_faq.rst index 26c00198dfcc..832eb5482647 100644 --- a/doc/faq/usage_faq.rst +++ b/doc/faq/usage_faq.rst @@ -114,6 +114,15 @@ idea). When the figure is rendered, all of the artists are drawn to the **canvas**. Most Artists are tied to an Axes; such an Artist cannot be shared by multiple Axes, or moved from one to another. +.. _input_types: + +Types of inputs to plotting functions +===================================== + +All of plotting functions expect `np.array` or `np.ma.masked_array` as +input. Classes that are 'array-like' such as `pandas` data objects +and `np.matrix` may or may not work as intended. It is best to +convert these to `np.array` objects prior to plotting. .. _pylab: From 676f04b4c5293a037da70d3ce348032e29c00b4f Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Fri, 22 Aug 2014 13:32:10 -0400 Subject: [PATCH 2/2] DOC : add examples of casting DataFrame and matrix --- doc/faq/usage_faq.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/doc/faq/usage_faq.rst b/doc/faq/usage_faq.rst index 832eb5482647..1dcd7f7b7cc9 100644 --- a/doc/faq/usage_faq.rst +++ b/doc/faq/usage_faq.rst @@ -124,6 +124,18 @@ input. Classes that are 'array-like' such as `pandas` data objects and `np.matrix` may or may not work as intended. It is best to convert these to `np.array` objects prior to plotting. +For example, to covert a `pandas.DataFrame` :: + + a = pandas.DataFrame(np.random.rand(4,5), columns = list('abcde')) + a_asndarray = a.values + +and to covert a `np.matrix` :: + + b = np.matrix([[1,2],[3,4]]) + b_asarray = np.asarray(b) + + + .. _pylab: Matplotlib, pyplot and pylab: how are they related?