-
-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Backend plt/gcf refactor #2624
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
Closed
Closed
Backend plt/gcf refactor #2624
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
5501f4e
first steps to extract FigureManager* and friends from pyplot
tacaswell 373909d
split backend_qt4 into two parts, with and without Gcf
tacaswell 3014931
split backend_qt4agg into two parts.
tacaswell 37e600e
Added a demo-file to show how to use the FigureManager classes to
tacaswell 82f3dea
removed un-needed import of Gcf
tacaswell 1ad0ebf
pep8 on backend_gtk.py
tacaswell 58ea364
pep8 clean up in backend_gdk
tacaswell f355c0c
removed un-needed Gcf import
tacaswell d5e47fb
split backend_gcf into two parts,
tacaswell 87781c5
pep8 on backend_gtkagg.py
tacaswell ce7c2ac
split backend_gktagg.py in to two parts
tacaswell ec24d0c
updated exclude list
tacaswell d3ecb67
pep8 clean up on backend_gtk3.py
tacaswell 26fc122
split backend_gtk3 into two parts
tacaswell fe7cdc0
updated coding standards
tacaswell b099ddd
pep8 on backend_gtkcairo.py
tacaswell 70939fe
split backend_gtkcairo.py into Gcf dependent and independent
tacaswell 4ec7908
import from _backend_bases in backend_agg to avoid implicit Gcf import
tacaswell 4f9f5b5
pep8 on backend_agg.py
tacaswell 03e86ee
split backend_gtk3agg.py into two parts, the gcf dependent and
tacaswell d97d98f
updated coding standards exclude list
tacaswell 83caa44
pep8 on backend_gtk3cairo.py
tacaswell 9e74042
pep8 on backend_cairo.py
tacaswell 51ccd5e
changed backend_cairo.py to import from _backend_bases to avoid
tacaswell efb1881
updated coding standards
tacaswell f4bdd22
Split backend_gtk3cairo.py into two parts, one dependent on Gcf
tacaswell a4bda49
Updated embedding_with_qt4_manager.py
tacaswell 407b1ee
Improved class-aliases in _backend_qt*.py
tacaswell 03c43aa
adjusting imports
fariza 35afa92
renamed _backend_bases.py -> base_backend_bases.py
tacaswell 2b213c0
massive rename operation
tacaswell 93fc457
removed rouge merge notation
tacaswell 6401be2
fixed broken import
tacaswell 3ea9f08
pep8 on backend_tkagg.py
tacaswell b528125
pep8 conformance
tacaswell 1dde78d
removed files that no longer exist
tacaswell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,121 @@ | ||
#!/usr/bin/env python | ||
|
||
# embedding_in_qt4.py --- Simple Qt4 application embedding matplotlib canvases | ||
# | ||
# Copyright (C) 2005 Florent Rougon | ||
# 2006 Darren Dale | ||
# | ||
# This file is an example program for matplotlib. It may be used and | ||
# modified with no restriction; raw copies as well as modified versions | ||
# may be distributed without limitation. | ||
|
||
from __future__ import unicode_literals, division | ||
import sys | ||
import os | ||
|
||
from matplotlib.backends.qt4_compat import QtCore, QtGui | ||
import numpy as np | ||
from matplotlib.backends._backend_qt4agg import (FigureCanvas, | ||
FigureManager, | ||
new_figure_manager) | ||
|
||
from matplotlib.figure import Figure | ||
|
||
progname = os.path.basename(sys.argv[0]) | ||
progversion = "0.1" | ||
|
||
|
||
def demo_plot(ax): | ||
""" | ||
Plots sin waves with random period | ||
""" | ||
k = np.random.random_integers(1, 10) | ||
th = np.linspace(0, 2*np.pi, 1024) | ||
ax.plot(th, np.sin(th * k)) | ||
|
||
|
||
class ApplicationWindow(QtGui.QMainWindow): | ||
def __init__(self): | ||
# QT boiler plate to set up main window | ||
QtGui.QMainWindow.__init__(self) | ||
self.setAttribute(QtCore.Qt.WA_DeleteOnClose) | ||
self.setWindowTitle("application main window") | ||
|
||
self.file_menu = QtGui.QMenu('&File', self) | ||
self.file_menu.addAction('&Quit', self.fileQuit, | ||
QtCore.Qt.CTRL + QtCore.Qt.Key_Q) | ||
self.menuBar().addMenu(self.file_menu) | ||
|
||
self.help_menu = QtGui.QMenu('&Help', self) | ||
self.menuBar().addSeparator() | ||
self.menuBar().addMenu(self.help_menu) | ||
|
||
self.help_menu.addAction('&About', self.about) | ||
|
||
self.main_widget = QtGui.QWidget(self) | ||
|
||
l = QtGui.QVBoxLayout(self.main_widget) | ||
button = QtGui.QPushButton("make window A") | ||
button.clicked.connect(self.new_window_hard_way) | ||
l.addWidget(button) | ||
|
||
buttonB = QtGui.QPushButton("make window B") | ||
buttonB.clicked.connect(self.new_window_easy_way) | ||
l.addWidget(buttonB) | ||
self.main_widget.setFocus() | ||
self.setCentralWidget(self.main_widget) | ||
self._figs = [] | ||
self.statusBar().showMessage("All hail matplotlib!", 2000) | ||
|
||
def new_window_hard_way(self): | ||
# make a figure | ||
fig = Figure() | ||
# make a canvas | ||
canvas = FigureCanvas(fig) | ||
# make a manager from the canvas | ||
manager = FigureManager(canvas, 1) | ||
# grab an axes in the figure | ||
ax = fig.gca() | ||
# plot some demo code | ||
demo_plot(ax) | ||
# show the window | ||
manager.show() | ||
|
||
def new_window_easy_way(self): | ||
# make a new manager | ||
manager = new_figure_manager(2) | ||
# grab a reference to the figure | ||
fig = manager.canvas.figure | ||
# get an axes object in the figure | ||
ax = fig.gca() | ||
# plot some demo-data | ||
demo_plot(ax) | ||
# show the window | ||
manager.show() | ||
|
||
def fileQuit(self): | ||
self.close() | ||
|
||
def closeEvent(self, ce): | ||
self.fileQuit() | ||
|
||
def about(self): | ||
QtGui.QMessageBox.about(self, "About", | ||
"""embedding_in_qt4.py example | ||
Copyright 2005 Florent Rougon, 2006 Darren Dale, 2013 Thomas Caswell | ||
|
||
This program is a simple example of a Qt4 application making use of | ||
the FigureManager class. | ||
|
||
It may be used and modified with no restriction; raw copies as well as | ||
modified versions may be distributed without limitation.""" | ||
) | ||
|
||
|
||
qApp = QtGui.QApplication(sys.argv) | ||
|
||
aw = ApplicationWindow() | ||
aw.setWindowTitle("%s" % progname) | ||
aw.show() | ||
sys.exit(qApp.exec_()) | ||
#qApp.exec_() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here the import should be base_backend_qt4agg?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, also missed that when I did the re-naming.