From f722ea16147d96c2ffc085e773cef5e032e254df Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Wed, 18 Mar 2020 19:00:53 -0400 Subject: [PATCH 1/3] DOC: Remove deprecated form of plt.register_cmap. --- examples/color/custom_cmap.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/examples/color/custom_cmap.py b/examples/color/custom_cmap.py index 7cccd60b88e0..cb5b11feb19c 100644 --- a/examples/color/custom_cmap.py +++ b/examples/color/custom_cmap.py @@ -155,7 +155,7 @@ ############################################################################### -# Now we will use this example to illustrate 3 ways of +# Now we will use this example to illustrate 2 ways of # handling custom colormaps. # First, the most direct and explicit: @@ -170,12 +170,8 @@ blue_red2 = LinearSegmentedColormap('BlueRed2', cdict2) plt.register_cmap(cmap=blue_red2) -############################################################################### -# Third, for LinearSegmentedColormap only, -# leave everything to register_cmap: - -plt.register_cmap(name='BlueRed3', data=cdict3) # optional lut kwarg -plt.register_cmap(name='BlueRedAlpha', data=cdict4) +plt.register_cmap(cmap=LinearSegmentedColormap('BlueRed3', cdict3)) +plt.register_cmap(cmap=LinearSegmentedColormap('BlueRedAlpha', cdict4)) ############################################################################### # Make the figure: From ad8a40e113e048456067ebe714ceda08185b8f50 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Wed, 18 Mar 2020 19:57:44 -0400 Subject: [PATCH 2/3] DOC: Don't use deprecated picker=Numeric. --- examples/event_handling/data_browser.py | 2 +- examples/event_handling/pick_event_demo.py | 37 +++++++++------------ examples/event_handling/pick_event_demo2.py | 2 +- 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/examples/event_handling/data_browser.py b/examples/event_handling/data_browser.py index 1254269744a3..6d2c68a3741d 100644 --- a/examples/event_handling/data_browser.py +++ b/examples/event_handling/data_browser.py @@ -91,7 +91,7 @@ def update(self): fig, (ax, ax2) = plt.subplots(2, 1) ax.set_title('click on point to plot time series') - line, = ax.plot(xs, ys, 'o', picker=5) # 5 points tolerance + line, = ax.plot(xs, ys, 'o', picker=True, pickradius=5) browser = PointBrowser() diff --git a/examples/event_handling/pick_event_demo.py b/examples/event_handling/pick_event_demo.py index 40531654ec19..f2cd07a01954 100644 --- a/examples/event_handling/pick_event_demo.py +++ b/examples/event_handling/pick_event_demo.py @@ -8,32 +8,27 @@ (for example, a matplotlib Line2D, Text, Patch, Polygon, AxesImage, etc...) -There are a variety of meanings of the picker property +There are a variety of meanings of the picker property: - None - picking is disabled for this artist (default) +* *None* - picking is disabled for this artist (default) - boolean - if True then picking will be enabled and the - artist will fire a pick event if the mouse event is over - the artist +* bool - if *True* then picking will be enabled and the artist will fire a pick + event if the mouse event is over the artist. - float - if picker is a number it is interpreted as an - epsilon tolerance in points and the artist will fire - off an event if it's data is within epsilon of the mouse - event. For some artists like lines and patch collections, - the artist may provide additional data to the pick event - that is generated, for example, the indices of the data within - epsilon of the pick event + Setting ``pickradius`` will add an epsilon tolerance in points and the artist + will fire off an event if its data is within epsilon of the mouse event. For + some artists like lines and patch collections, the artist may provide + additional data to the pick event that is generated, for example, the indices + of the data within epsilon of the pick event - function - if picker is callable, it is a user supplied - function which determines whether the artist is hit by the - mouse event. +* function - if picker is callable, it is a user supplied function which + determines whether the artist is hit by the mouse event. - hit, props = picker(artist, mouseevent) - - to determine the hit test. If the mouse event is over the - artist, return hit=True and props is a dictionary of properties - you want added to the PickEvent attributes + hit, props = picker(artist, mouseevent) + to determine the hit test. If the mouse event is over the artist, return + hit=True and props is a dictionary of properties you want added to the + PickEvent attributes. After you have enabled an artist for picking by setting the "picker" property, you need to connect to the figure canvas pick_event to get @@ -80,7 +75,7 @@ def pick_simple(): fig, (ax1, ax2) = plt.subplots(2, 1) ax1.set_title('click on points, rectangles or text', picker=True) ax1.set_ylabel('ylabel', picker=True, bbox=dict(facecolor='red')) - line, = ax1.plot(rand(100), 'o', picker=5) # 5 points tolerance + line, = ax1.plot(rand(100), 'o', picker=True, pickradius=5) # pick the rectangle ax2.bar(range(10), rand(10), picker=True) diff --git a/examples/event_handling/pick_event_demo2.py b/examples/event_handling/pick_event_demo2.py index 6204613690f1..5712c88588aa 100644 --- a/examples/event_handling/pick_event_demo2.py +++ b/examples/event_handling/pick_event_demo2.py @@ -17,7 +17,7 @@ fig, ax = plt.subplots() ax.set_title('click on point to plot time series') -line, = ax.plot(xs, ys, 'o', picker=5) # 5 points tolerance +line, = ax.plot(xs, ys, 'o', picker=True, pickradius=5) def onpick(event): From dd54a33de69afe87409890b3702dab362548b9cc Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Wed, 18 Mar 2020 20:02:29 -0400 Subject: [PATCH 3/3] DOC: Don't pass string lists to pgf.preamble. --- examples/userdemo/pgf_preamble_sgskip.py | 4 ++-- examples/userdemo/pgf_texsystem.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/userdemo/pgf_preamble_sgskip.py b/examples/userdemo/pgf_preamble_sgskip.py index eccdefa0d6e1..ad0ca6a4d508 100644 --- a/examples/userdemo/pgf_preamble_sgskip.py +++ b/examples/userdemo/pgf_preamble_sgskip.py @@ -12,13 +12,13 @@ "font.family": "serif", # use serif/main font for text elements "text.usetex": True, # use inline math for ticks "pgf.rcfonts": False, # don't setup fonts from rc parameters - "pgf.preamble": [ + "pgf.preamble": "\n".join([ "\\usepackage{units}", # load additional packages "\\usepackage{metalogo}", "\\usepackage{unicode-math}", # unicode math setup r"\setmathfont{xits-math.otf}", r"\setmainfont{DejaVu Serif}", # serif font via preamble - ] + ]) }) plt.figure(figsize=(4.5, 2.5)) diff --git a/examples/userdemo/pgf_texsystem.py b/examples/userdemo/pgf_texsystem.py index d3e535183539..622ba97ab740 100644 --- a/examples/userdemo/pgf_texsystem.py +++ b/examples/userdemo/pgf_texsystem.py @@ -8,11 +8,11 @@ import matplotlib.pyplot as plt plt.rcParams.update({ "pgf.texsystem": "pdflatex", - "pgf.preamble": [ + "pgf.preamble": "\n".join([ r"\usepackage[utf8x]{inputenc}", r"\usepackage[T1]{fontenc}", r"\usepackage{cmbright}", - ] + ]), }) plt.figure(figsize=(4.5, 2.5))