FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix deprecations in examples by QuLogic · Pull Request #10385 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (9) All 1 file type selected
Deleted files Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
25 changes: 0 additions & 25 deletions examples/axes_grid1/demo_new_colorbar.py

This file was deleted.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def ex3():
divider = make_axes_locatable(ax1)

ax2 = divider.new_horizontal("100%", pad=0.3, sharey=ax1)
ax2.tick_params(labelleft="off")
ax2.tick_params(labelleft=False)
fig.add_axes(ax2)

divider.add_auto_adjustable_area(use_axes=[ax1], pad=0.1,
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def normal_pdf(x, mean, var):
weights = weights_high + weights_low

# We'll also create a grey background into which the pixels will fade
greys = np.ones(weights.shape + (3,)) * 70
greys = np.empty(weights.shape + (3,), dtype=np.uint8)
greys.fill(70)

# First we'll plot these blobs using only ``imshow``.
vmax = np.abs(weights).max()
Expand Down
16 changes: 9 additions & 7 deletions examples/showcase/bachelors_degrees_by_gender.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
as an alternative to a conventional legend.
"""

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.mlab import csv2rec
from matplotlib.cbook import get_sample_data

with get_sample_data('percent_bachelors_degrees_women_usa.csv') as fname:
gender_degree_data = csv2rec(fname)

fname = get_sample_data('percent_bachelors_degrees_women_usa.csv',
asfileobj=False)
gender_degree_data = np.genfromtxt(fname, delimiter=',', names=True)

# These are the colors that will be used in the plot
color_sequence = ['#1f77b4', '#aec7e8', '#ff7f0e', '#ffbb78', '#2ca02c',
Expand Down Expand Up @@ -59,8 +61,8 @@

# Remove the tick marks; they are unnecessary with the tick lines we just
# plotted.
plt.tick_params(axis='both', which='both', bottom='off', top='off',
labelbottom='on', left='off', right='off', labelleft='on')
plt.tick_params(axis='both', which='both', bottom=False, top=False,
labelbottom=True, left=False, right=False, labelleft=True)

# Now that the plot is prepared, it's time to actually plot the data!
# Note that I plotted the majors in order of the highest % in the final year.
Expand All @@ -80,9 +82,9 @@

for rank, column in enumerate(majors):
# Plot each line separately with its own color.
column_rec_name = column.replace('\n', '_').replace(' ', '_').lower()
column_rec_name = column.replace('\n', '_').replace(' ', '_')

line = plt.plot(gender_degree_data.year,
line = plt.plot(gender_degree_data['Year'],
gender_degree_data[column_rec_name],
lw=2.5,
color=color_sequence[rank])
Expand Down
2 changes: 1 addition & 1 deletion examples/statistics/hist.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
thispatch.set_facecolor(color)

# We can also normalize our inputs by the total number of counts
axs[1].hist(x, bins=n_bins, normed=True)
axs[1].hist(x, bins=n_bins, density=True)

# Now we format the y-axis to display percentage
axs[1].yaxis.set_major_formatter(PercentFormatter(xmax=1))
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
ax.spines['bottom'].set_visible(False)
ax2.spines['top'].set_visible(False)
ax.xaxis.tick_top()
ax.tick_params(labeltop='off') # don't put tick labels at the top
ax.tick_params(labeltop=False) # don't put tick labels at the top
ax2.xaxis.tick_bottom()

# This looks pretty good, and was fairly painless, but you can get that
Expand Down
14 changes: 9 additions & 5 deletions examples/ticks_and_spines/date_index_formatter.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,19 @@
"""

from __future__ import print_function

import numpy as np
from matplotlib.mlab import csv2rec

import matplotlib.pyplot as plt
import matplotlib.cbook as cbook
from matplotlib.dates import bytespdate2num, num2date
from matplotlib.ticker import Formatter


datafile = cbook.get_sample_data('msft.csv', asfileobj=False)
print('loading %s' % datafile)
r = csv2rec(datafile)[-40:]
msft_data = np.genfromtxt(datafile, delimiter=',', names=True,
converters={0: bytespdate2num('%d-%b-%y')})[-40:]


class MyFormatter(Formatter):
Expand All @@ -34,12 +38,12 @@ def __call__(self, x, pos=0):
if ind >= len(self.dates) or ind < 0:
return ''

return self.dates[ind].strftime(self.fmt)
return num2date(self.dates[ind]).strftime(self.fmt)

formatter = MyFormatter(r.date)
formatter = MyFormatter(msft_data['Date'])

fig, ax = plt.subplots()
ax.xaxis.set_major_formatter(formatter)
ax.plot(np.arange(len(r)), r.close, 'o-')
ax.plot(np.arange(len(msft_data)), msft_data['Close'], 'o-')
fig.autofmt_xdate()
plt.show()
7 changes: 5 additions & 2 deletions lib/matplotlib/pyplot.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -2411,8 +2411,11 @@ def plotfile(fname, cols=(0,), plotfuncs=None,

if plotfuncs is None:
plotfuncs = dict()
r = mlab.csv2rec(fname, comments=comments, skiprows=skiprows,
checkrows=checkrows, delimiter=delimiter, names=names)
from matplotlib.cbook import mplDeprecation

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Should this whole method be deprecated since it depends on csv2rec?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Yes, and point people at pandas.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

You want to deprecate plt.plotfile for Pandas? Probably should be an independent PR.

with warnings.catch_warnings():
warnings.simplefilter('ignore', mplDeprecation)
r = mlab.csv2rec(fname, comments=comments, skiprows=skiprows,
checkrows=checkrows, delimiter=delimiter, names=names)

def getname_val(identifier):
'return the name and column data for identifier'
Expand Down
2 changes: 1 addition & 1 deletion tutorials/introductory/pyplot.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def f(t):
x = mu + sigma * np.random.randn(10000)

# the histogram of the data
n, bins, patches = plt.hist(x, 50, normed=1, facecolor='g', alpha=0.75)
n, bins, patches = plt.hist(x, 50, density=1, facecolor='g', alpha=0.75)


plt.xlabel('Smarts')
Expand Down

Back | FazBrowse Home | New Git URL