User Tools

Site Tools


matplotlib

Matplotlib Home

Backend

  • Show current backend
import matplotlib
matplotlib.pyplot.get_backend()
# or
matplotlib.rcParams['backend']
  • Setup backend
import matplotlib
matplotlib.use('GTKAgg')
  • Show all possible backends
import matplotlib
matplotlib.rcsetup.interactive_bk
matplotlib.rcsetup.non_interactive_bk
matplotlib.rcsetup.all_backends

Troubleshooting

  • When close a figure window, the following information jump out:
/usr/lib/python2.7/dist-packages/matplotlib/backends/backend_gtk.py:253: Warning: Source ID 70 was not found when attempting to remove it
  gobject.source_remove(self._idle_event_id)

The solution is to modify /usr/lib/python2.7/dist-packages/matplotlib/backend_bases.py by adding “return True” to the end of function “def idle_event(self, guiEvent=None):”. Ref

  • When want to modify the font types of labels,titles…Ref
csfont = {'fontname':'Comic Sans MS'}
hfont = {'fontname':'Helvetica'}

plt.title('title',**csfont)
plt.xlabel('xlabel', **hfont)
plt.show()
matplotlib.txt · Last modified: 2024/03/14 05:33 by 127.0.0.1