3

I have a plot using matplotlib and I want to remove some of the buttons from the toolbar.

I have achieved removing the forward, back, home, zoom and help buttons, but when I try to remove the "Configure subplots" button I get an error.

Why can't I remove this one but I can remove the others?

My code is something like this:

import matplotlib.pyplot as plt
plt.rcParams['toolbar'] = 'toolmanager'

fig = plt.figure()

fig.canvas.manager.toolmanager.remove_tool('forward')
fig.canvas.manager.toolmanager.remove_tool('back')
fig.canvas.manager.toolmanager.remove_tool('home')
fig.canvas.manager.toolmanager.remove_tool('zoom')
fig.canvas.manager.toolmanager.remove_tool('help')
fig.canvas.manager.toolmanager.remove_tool('subplots')

If I comment the last line, the code runs without problem and I get the toolbar without the specified buttons, but if I add the last line I get the following error:

AttributeError: 'NoneType' object has no attribute 'destroy'

I have tried all type of combinations from 'subplots', in case the name is not correct like

  • 'Subplot',
  • 'Subplots',
  • 'subplot',
  • 'configure',
  • 'configure_subplots',
  • 'Configure subplots'
2
  • 1
    I suggested a fix for this in #14282, which might make it into the next bug fix release. Commented May 20, 2019 at 22:50
  • 1
    In the meantime you can use the Qt5Agg backend, which does not have this problem. Commented May 21, 2019 at 10:19

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.