From dd0a5e09b8551f36cf7201e77f2e034334acde83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Sok=C3=B3=C5=82?= Date: Thu, 31 Aug 2023 11:38:56 +0200 Subject: [PATCH] MAINT: Refactor recarray access --- .../examples/lines_bars_and_markers/fill_between_alpha.py | 2 +- galleries/examples/lines_bars_and_markers/scatter_demo2.py | 4 +++- galleries/examples/misc/keyword_plotting.py | 2 +- galleries/examples/ticks/centered_ticklabels.py | 2 +- galleries/examples/ticks/date_index_formatter.py | 2 +- galleries/tutorials/pyplot.py | 2 +- galleries/users_explain/quick_start.py | 2 +- 7 files changed, 9 insertions(+), 7 deletions(-) diff --git a/galleries/examples/lines_bars_and_markers/fill_between_alpha.py b/galleries/examples/lines_bars_and_markers/fill_between_alpha.py index 66822aaff0c5..31c2affe5703 100644 --- a/galleries/examples/lines_bars_and_markers/fill_between_alpha.py +++ b/galleries/examples/lines_bars_and_markers/fill_between_alpha.py @@ -18,7 +18,7 @@ import matplotlib.cbook as cbook # load up some sample financial data -r = cbook.get_sample_data('goog.npz')['price_data'].view(np.recarray) +r = cbook.get_sample_data('goog.npz')['price_data'].view(np.rec.recarray) # create two subplots with the shared x and y axes fig, (ax1, ax2) = plt.subplots(1, 2, sharex=True, sharey=True) diff --git a/galleries/examples/lines_bars_and_markers/scatter_demo2.py b/galleries/examples/lines_bars_and_markers/scatter_demo2.py index 0a9eee4f2b53..258a9e518841 100644 --- a/galleries/examples/lines_bars_and_markers/scatter_demo2.py +++ b/galleries/examples/lines_bars_and_markers/scatter_demo2.py @@ -14,7 +14,9 @@ # low, close, volume, adj_close from the mpl-data/sample_data directory. The # record array stores the date as an np.datetime64 with a day unit ('D') in # the date column. -price_data = cbook.get_sample_data('goog.npz')['price_data'].view(np.recarray) +price_data = cbook.get_sample_data('goog.npz')['price_data'].view( + np.rec.recarray +) price_data = price_data[-250:] # get the most recent 250 trading days delta1 = np.diff(price_data.adj_close) / price_data.adj_close[:-1] diff --git a/galleries/examples/misc/keyword_plotting.py b/galleries/examples/misc/keyword_plotting.py index 4e0f3e61037d..f086dd850f2a 100644 --- a/galleries/examples/misc/keyword_plotting.py +++ b/galleries/examples/misc/keyword_plotting.py @@ -5,7 +5,7 @@ There are some instances where you have data in a format that lets you access particular variables with strings: for example, with -`numpy.recarray` or `pandas.DataFrame`. +`numpy.rec.recarray` or `pandas.DataFrame`. Matplotlib allows you to provide such an object with the ``data`` keyword argument. If provided, you may generate plots with the strings diff --git a/galleries/examples/ticks/centered_ticklabels.py b/galleries/examples/ticks/centered_ticklabels.py index 21c81e43d1f2..4894c3559c3e 100644 --- a/galleries/examples/ticks/centered_ticklabels.py +++ b/galleries/examples/ticks/centered_ticklabels.py @@ -25,7 +25,7 @@ import matplotlib.ticker as ticker # Load some financial data; Google's stock price -r = cbook.get_sample_data('goog.npz')['price_data'].view(np.recarray) +r = cbook.get_sample_data('goog.npz')['price_data'].view(np.rec.recarray) r = r[-250:] # get the last 250 days fig, ax = plt.subplots() diff --git a/galleries/examples/ticks/date_index_formatter.py b/galleries/examples/ticks/date_index_formatter.py index 4c48ac5ace7a..3c0fbff39740 100644 --- a/galleries/examples/ticks/date_index_formatter.py +++ b/galleries/examples/ticks/date_index_formatter.py @@ -25,7 +25,7 @@ # low, close, volume, adj_close from the mpl-data/sample_data directory. The # record array stores the date as an np.datetime64 with a day unit ('D') in # the date column (``r.date``). -r = cbook.get_sample_data('goog.npz')['price_data'].view(np.recarray) +r = cbook.get_sample_data('goog.npz')['price_data'].view(np.rec.recarray) r = r[:9] # get the first 9 days fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(6, 6), layout='constrained') diff --git a/galleries/tutorials/pyplot.py b/galleries/tutorials/pyplot.py index b6e02041afa0..067e79f7d75a 100644 --- a/galleries/tutorials/pyplot.py +++ b/galleries/tutorials/pyplot.py @@ -107,7 +107,7 @@ # # There are some instances where you have data in a format that lets you # access particular variables with strings. For example, with -# `numpy.recarray` or `pandas.DataFrame`. +# `numpy.rec.recarray` or `pandas.DataFrame`. # # Matplotlib allows you to provide such an object with # the ``data`` keyword argument. If provided, then you may generate plots with diff --git a/galleries/users_explain/quick_start.py b/galleries/users_explain/quick_start.py index cf2d5850e6e5..37d685a649d2 100644 --- a/galleries/users_explain/quick_start.py +++ b/galleries/users_explain/quick_start.py @@ -127,7 +127,7 @@ # b_asarray = np.asarray(b) # # Most methods will also parse an addressable object like a *dict*, a -# `numpy.recarray`, or a `pandas.DataFrame`. Matplotlib allows you to +# `numpy.rec.recarray`, or a `pandas.DataFrame`. Matplotlib allows you to # provide the ``data`` keyword argument and generate plots passing the # strings corresponding to the *x* and *y* variables. np.random.seed(19680801) # seed the random number generator. pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy