Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Deprecate FigureCanvas.{get,set}_window_title. #17723

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/api/api_changes_3.4/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ The following globals in :mod:`matplotlib.colorbar` are deprecated:
In order to use a custom boxstyle, directly pass it as the *boxstyle* argument
to `.FancyBboxPatch`. This was previously already possible, and is consistent
with custom arrow styles and connection styles.

``FigureCanvasBase.get_window_title`` and ``FigureCanvasBase.set_window_title``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
... are deprecated. Use the corresponding methods on the FigureManager if
using pyplot, or GUI-specific methods if embedding.
5 changes: 2 additions & 3 deletions examples/specialty_plots/leftventricle_bulleye.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ def bullseye_plot(ax, data, seg_bold=None, cmap=None, norm=None):
norm : Normalize or None, optional
Optional argument to normalize data into the [0.0, 1.0] range


Notes
-----
This function create the 17 segment model for the left ventricle according
This function creates the 17 segment model for the left ventricle according
to the American Heart Association (AHA) [1]_

References
Expand Down Expand Up @@ -135,7 +134,7 @@ def bullseye_plot(ax, data, seg_bold=None, cmap=None, norm=None):
# Make a figure and axes with dimensions as desired.
fig, ax = plt.subplots(figsize=(12, 8), nrows=1, ncols=3,
subplot_kw=dict(projection='polar'))
fig.canvas.set_window_title('Left Ventricle Bulls Eyes (AHA)')
fig.canvas.manager.set_window_title('Left Ventricle Bulls Eyes (AHA)')

# Create the axis for the colorbars
axl = fig.add_axes([0.14, 0.15, 0.2, 0.05])
Expand Down
2 changes: 1 addition & 1 deletion examples/statistics/barchart_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def format_ycursor(y):
def plot_student_results(student, scores, cohort_size):
fig, ax1 = plt.subplots(figsize=(9, 7)) # Create the figure
fig.subplots_adjust(left=0.115, right=0.88)
fig.canvas.set_window_title('Eldorado K-8 Fitness Chart')
fig.canvas.manager.set_window_title('Eldorado K-8 Fitness Chart')

pos = np.arange(len(test_names))

Expand Down
2 changes: 1 addition & 1 deletion examples/statistics/boxplot_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
]

fig, ax1 = plt.subplots(figsize=(10, 6))
fig.canvas.set_window_title('A Boxplot Example')
fig.canvas.manager.set_window_title('A Boxplot Example')
fig.subplots_adjust(left=0.075, right=0.95, top=0.9, bottom=0.25)

bp = ax1.boxplot(data, notch=0, sym='+', vert=1, whis=1.5)
Expand Down
15 changes: 10 additions & 5 deletions lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -2235,6 +2235,8 @@ def get_default_filetype(cls):
"""
return rcParams['savefig.format']

@cbook.deprecated(
"3.4", alternative="manager.get_window_title or GUI-specific methods")
def get_window_title(self):
"""
Return the title text of the window containing the figure, or None
Expand All @@ -2243,6 +2245,8 @@ def get_window_title(self):
if self.manager is not None:
return self.manager.get_window_title()

@cbook.deprecated(
"3.4", alternative="manager.set_window_title or GUI-specific methods")
def set_window_title(self, title):
"""
Set the title text of the window containing the figure. Note that
Expand All @@ -2256,11 +2260,12 @@ def get_default_filename(self):
Return a string, which includes extension, suitable for use as
a default filename.
"""
default_basename = self.get_window_title() or 'image'
default_basename = default_basename.replace(' ', '_')
default_filetype = self.get_default_filetype()
default_filename = default_basename + '.' + default_filetype
return default_filename
basename = (self.manager.get_window_title() if self.manager is not None
else '')
basename = (basename or 'image').replace(' ', '_')
filetype = self.get_default_filetype()
filename = basename + '.' + filetype
return filename

def switch_backends(self, FigureCanvasClass):
"""
Expand Down