Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
a638e30
Refactor pass 1. Refactoring Gcf out of specific backend (backend_gt…
OceanWolf Feb 21, 2015
9307461
Refactor Pass 2. Refactored Gcf out of all backend code.
OceanWolf Feb 22, 2015
a5e52a0
Quick fix to figure for safe unpickling.
OceanWolf Feb 25, 2015
d104283
GTK3Agg
OceanWolf Feb 26, 2015
26a872d
Refactored making `FigureManager` a *figure* manager, plus added miss…
OceanWolf Feb 27, 2015
8e18ebe
keyword
OceanWolf Feb 27, 2015
c3f34b7
Make add_element more general, and make sure the code complies with it.
OceanWolf Feb 27, 2015
d8a1bdf
Better destroy order.
OceanWolf Feb 27, 2015
f2b7f08
GTK simplifications
OceanWolf Feb 28, 2015
0bda9db
Added doc and cleaned backend_managers, don't want our new file dirty.
OceanWolf Mar 3, 2015
89fc1d5
Improve layout!
OceanWolf Apr 6, 2015
7e1c677
Move knowledge of the backend to the manager.
OceanWolf Apr 7, 2015
99c19ea
Incorporate MEP22 into MEP27
OceanWolf Apr 12, 2015
3ed068f
Improved new toolbar and updated tool_manager example accoridingly.
OceanWolf Apr 12, 2015
e0a27c2
fullscreen
OceanWolf Apr 13, 2015
b4660fc
MEP update
OceanWolf Apr 14, 2015
b4b7246
Finish MEP22 conversion
OceanWolf Apr 14, 2015
93a8891
rename window method
OceanWolf Apr 17, 2015
a334841
Add backend anme to widgets
OceanWolf Apr 17, 2015
55bc009
Updated widgets.py
JayP16 Mar 15, 2015
a6ccc20
Moved active and ignore logic to parent class.
JayP16 Mar 16, 2015
f7daaae
Removed white space.
JayP16 Mar 20, 2015
0d763fd
Added native dpi option for print_figure
Mar 27, 2015
a3fceb7
Moved new dpi option to Figure.savefig()
Mar 29, 2015
e2df30b
Create updated_widgets.rst
JayP16 Mar 30, 2015
fc2894d
Added whats new and validation for figure.savefig dpi change
Apr 4, 2015
1cc3e9f
Use qt_compat rather that qt4_compat in example
jenshnielsen Apr 5, 2015
01603a8
Add link explaning change between qt4 and qt5
jenshnielsen Apr 5, 2015
c6e31fb
Add embedding in qt5 example
jenshnielsen Apr 5, 2015
e5ed696
added resize parameter to plot 2d-arrays using figimage
mehdimu Apr 6, 2015
fe1e8c9
added an entry in whats_new, and fixed the placement of the resize pa…
mehdimu Apr 6, 2015
f95d076
Fix Angstrom issues.
mdboom Mar 25, 2015
f87e3c9
Add test images
mdboom Apr 6, 2015
9fa10f0
DOC: Note about pixel placement in imshow
caspervdw Apr 7, 2015
41ed61d
DOC: Fixed PEP8 thing
caspervdw Apr 7, 2015
cc1ff1b
modified plt.imsave to use the new resize parameter in plt.figimage()…
Apr 11, 2015
0d19703
BUG : make sure lw is a float
tacaswell Apr 12, 2015
4bade42
STY : white space cleanup in backend_wx
tacaswell Apr 12, 2015
d2d1011
FIX : cast linewidth to float in backends
tacaswell Apr 12, 2015
04afed2
Add functionality to plot bar and barh with string labels. Add what's…
Mar 23, 2015
f6ee676
BUG : fix scaling issue with mlab.psd and odd NFFT
tacaswell Apr 10, 2015
8915407
TST : add test of odd NFFT single sided psd
tacaswell Apr 12, 2015
07d30a6
figure centered FigureManager and ToolManager
fariza May 8, 2015
11cc44f
toggle tools for example
fariza May 8, 2015
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
30 changes: 17 additions & 13 deletions doc/devel/MEP/MEP27.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@

Status
======
**Discussion**
**Progress**

Branches and Pull requests
==========================
Main PR (including GTK3):

+ https://github.com/matplotlib/matplotlib/pull/4143

Backend specific branch diffs:

+ https://github.com/OceanWolf/matplotlib/compare/backend-refactor...OceanWolf:backend-refactor-tkagg
+ https://github.com/OceanWolf/matplotlib/compare/backend-refactor...OceanWolf:backend-refactor-qt
+ https://github.com/OceanWolf/matplotlib/compare/backend-refactor...backend-refactor-wx
Expand Down Expand Up @@ -79,7 +81,7 @@ The description of this MEP gives us most of the solution:
1. To remove the windowing aspect out of ``FigureManagerBase`` letting
it simply wrap this new class along with the other backend classes.
Create a new ``WindowBase`` class that can handle this
functionality, with pass-through methods (:arrow_right:) to
functionality, with pass-through methods (->) to
``WindowBase``. Classes that subclass ``WindowBase`` should also
subclass the GUI specific window class to ensure backward
compatibility (``manager.window == manager.window``).
Expand All @@ -103,30 +105,30 @@ The description of this MEP gives us most of the solution:
|FigureManagerBase(canvas, num) |FigureManager(figure, num) |``WindowBase(title)``|Notes |
| | | | |
+======================================+==============================+=====================+================================+
|show | |show | |
|show |-> |show | |
+--------------------------------------+------------------------------+---------------------+--------------------------------+
|destroy |calls destroy on all |destroy | |
| |components | | |
+--------------------------------------+------------------------------+---------------------+--------------------------------+
|full_screen_toggle |handles logic |set_fullscreen | |
+--------------------------------------+------------------------------+---------------------+--------------------------------+
|resize | |resize | |
|resize |-> |resize | |
+--------------------------------------+------------------------------+---------------------+--------------------------------+
|key_press |key_press | | |
|key_press |key_press |X | |
+--------------------------------------+------------------------------+---------------------+--------------------------------+
|show_popup |show_poup | |Not used anywhere in mpl, and |
|show_popup |show_poup |X |Not used anywhere in mpl, and |
| | | |does nothing. |
+--------------------------------------+------------------------------+---------------------+--------------------------------+
|get_window_title | |get_window_title | |
|get_window_title |-> |get_window_title | |
+--------------------------------------+------------------------------+---------------------+--------------------------------+
|set_window_title | |set_window_title | |
|set_window_title |-> |set_window_title | |
+--------------------------------------+------------------------------+---------------------+--------------------------------+
| |_get_toolbar | |A common method to all |
|X |_get_toolbar |X |A common method to all |
| | | |subclasses of FigureManagerBase |
+--------------------------------------+------------------------------+---------------------+--------------------------------+
| | |set_default_size | |
|X |X |set_default_size | |
+--------------------------------------+------------------------------+---------------------+--------------------------------+
| | |add_element_to_window| |
|X |X |add_element | |
+--------------------------------------+------------------------------+---------------------+--------------------------------+


Expand All @@ -135,14 +137,14 @@ The description of this MEP gives us most of the solution:
+==========+============+=============+
|mainloop |begin | |
+----------+------------+-------------+
| |end |Gets called |
|X |end |Gets called |
| | |automagically|
| | |when no more |
| | |instances of |
| | |the subclass |
| | |exist |
+----------+------------+-------------+
|__call__ | |Method moved |
|__call__ |X |Method moved |
| | |to |
| | |Gcf.show_all |
+----------+------------+-------------+
Expand Down Expand Up @@ -191,6 +193,8 @@ in the same manner as everything else.
| | |window, so this also |
| | |breaks BC. |
+-------------------------+-------------------------+-------------------------+
|WebAgg |canvas | |
+-------------------------+-------------------------+-------------------------+


Alternatives
Expand Down
8 changes: 8 additions & 0 deletions doc/users/whats_new/plotting.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Plot bar and barh with labels
`````````````````````````````

Added kwarg "tick_label" to bar and barh to support plotting bar graphs with a
text label for each bar.
Example:
bar([1, 2], [1, 1], tick_label=['bar1', 'bar2'])

Added center and frame kwargs to pie
````````````````````````````````````

Expand Down
8 changes: 8 additions & 0 deletions doc/users/whats_new/updated_figimage.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
updated figimage to take optional resize parameter
----------------------------------------------------
Added the ability to plot simple 2D-Array using plt.figimage(X, resize=True).
This is useful for plotting simple 2D-Array without the Axes or whitespacing
around the image.
Example:
data = np.random.random( [500, 500] )
plt.figimage(data, resize=True)
9 changes: 9 additions & 0 deletions doc/users/whats_new/updated_figure.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Updated Figure.savefig()
------------------------

Added support to save the figure with the same dpi as the figure on the screen using dpi='figure'

Example:
f = plt.figure(dpi=25) # dpi set to 25
S = plt.scatter([1,2,3],[4,5,6])
f.savefig('output.png', dpi='figure') # output savefig dpi set to 25 (same as figure)
10 changes: 10 additions & 0 deletions doc/users/whats_new/updated_widgets.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Moved ``ignore``, ``set_active``, and ``get_active`` methods to base class ``Widget``
`````````````````````````````````````````````````````````````````````````````````
Pushes up duplicate methods in child class to parent class to avoid duplication of code.


Adds enable/disable feature to MultiCursor
``````````````````````````````````````````
A MultiCursor object can be disabled (and enabled) after it has been created without destroying the object.
Example:
multi_cursor.active = False
4 changes: 2 additions & 2 deletions examples/user_interfaces/embedding_in_qt4.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
import sys
import os
import random
from matplotlib.backends import qt4_compat
use_pyside = qt4_compat.QT_API == qt4_compat.QT_API_PYSIDE
from matplotlib.backends import qt_compat
use_pyside = qt_compat.QT_API == qt_compat.QT_API_PYSIDE
if use_pyside:
from PySide import QtGui, QtCore
else:
Expand Down
141 changes: 141 additions & 0 deletions examples/user_interfaces/embedding_in_qt5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
#!/usr/bin/env python

# embedding_in_qt5.py --- Simple Qt5 application embedding matplotlib canvases
#
# Copyright (C) 2005 Florent Rougon
# 2006 Darren Dale
# 2015 Jens H Nielsen
#
# 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
import sys
import os
import random
import matplotlib
# Make sure that we are using QT5
matplotlib.use('Qt5Agg')
from PyQt5 import QtGui, QtCore, QtWidgets

from numpy import arange, sin, pi
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure

progname = os.path.basename(sys.argv[0])
progversion = "0.1"


class MyMplCanvas(FigureCanvas):
"""Ultimately, this is a QWidget (as well as a FigureCanvasAgg, etc.)."""

def __init__(self, parent=None, width=5, height=4, dpi=100):
fig = Figure(figsize=(width, height), dpi=dpi)
self.axes = fig.add_subplot(111)
# We want the axes cleared every time plot() is called
self.axes.hold(False)

self.compute_initial_figure()

#
FigureCanvas.__init__(self, fig)
self.setParent(parent)

FigureCanvas.setSizePolicy(self,
QtWidgets.QSizePolicy.Expanding,
QtWidgets.QSizePolicy.Expanding)
FigureCanvas.updateGeometry(self)

def compute_initial_figure(self):
pass


class MyStaticMplCanvas(MyMplCanvas):
"""Simple canvas with a sine plot."""

def compute_initial_figure(self):
t = arange(0.0, 3.0, 0.01)
s = sin(2*pi*t)
self.axes.plot(t, s)


class MyDynamicMplCanvas(MyMplCanvas):
"""A canvas that updates itself every second with a new plot."""

def __init__(self, *args, **kwargs):
MyMplCanvas.__init__(self, *args, **kwargs)
timer = QtCore.QTimer(self)
timer.timeout.connect(self.update_figure)
timer.start(1000)

def compute_initial_figure(self):
self.axes.plot([0, 1, 2, 3], [1, 2, 0, 4], 'r')

def update_figure(self):
# Build a list of 4 random integers between 0 and 10 (both inclusive)
l = [random.randint(0, 10) for i in range(4)]

self.axes.plot([0, 1, 2, 3], l, 'r')
self.draw()


class ApplicationWindow(QtWidgets.QMainWindow):
def __init__(self):
QtWidgets.QMainWindow.__init__(self)
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
self.setWindowTitle("application main window")

self.file_menu = QtWidgets.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 = QtWidgets.QMenu('&Help', self)
self.menuBar().addSeparator()
self.menuBar().addMenu(self.help_menu)

self.help_menu.addAction('&About', self.about)

self.main_widget = QtWidgets.QWidget(self)

l = QtWidgets.QVBoxLayout(self.main_widget)
sc = MyStaticMplCanvas(self.main_widget, width=5, height=4, dpi=100)
dc = MyDynamicMplCanvas(self.main_widget, width=5, height=4, dpi=100)
l.addWidget(sc)
l.addWidget(dc)

self.main_widget.setFocus()
self.setCentralWidget(self.main_widget)

self.statusBar().showMessage("All hail matplotlib!", 2000)

def fileQuit(self):
self.close()

def closeEvent(self, ce):
self.fileQuit()

def about(self):
QtGui.QMessageBox.about(self, "About",
"""embedding_in_qt5.py example
Copyright 2005 Florent Rougon, 2006 Darren Dale, 2015 Jens H Nielsen

This program is a simple example of a Qt5 application embedding matplotlib
canvases.

It may be used and modified with no restriction; raw copies as well as
modified versions may be distributed without limitation.

This is modified from the embedding in qt4 example to show the difference
between qt4 and qt5"""
)


qApp = QtWidgets.QApplication(sys.argv)

aw = ApplicationWindow()
aw.setWindowTitle("%s" % progname)
aw.show()
sys.exit(qApp.exec_())
#qApp.exec_()
60 changes: 60 additions & 0 deletions examples/user_interfaces/multifigure.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# from __future__ import print_function
import matplotlib
matplotlib.use('GTK3AGG')
# matplotlib.rcParams['backend.multifigure'] = False
matplotlib.rcParams['toolbar'] = 'toolmanager'
from matplotlib.backend_tools import ToolToggleBase


from matplotlib.figure import Figure
from matplotlib.backend_managers import FigureManager


class t1(ToolToggleBase):
radio_group = 'multifigure'
description = "change canvas"
def __init__(self, *args, **kwargs):
self.mfigure = kwargs.pop('figure')
ToolToggleBase.__init__(self, *args, **kwargs)

def enable(self, *args, **kwargs):
self.toolmanager.manager.figure = self.mfigure


manager = FigureManager(None, 1)
backend = manager._backend

fig1 = Figure()
canvas1 = backend.FigureCanvas(fig1)
ax1 = fig1.add_subplot(111)
ax1.plot([1, 2, 3])

manager.figure = fig1

fig2 = Figure()
canvas2 = backend.FigureCanvas(fig2)
ax2 = fig2.add_subplot(111)
ax2.plot([3, 2, 1])

fig3 = Figure()
canvas3 = backend.FigureCanvas(fig3)
ax3 = fig3.add_subplot(111)
ax3.plot([1, 1, 1])

sidebar = manager._get_toolbar()
sidebar.set_flow('vertical')


manager.toolmanager.add_tool('f1', t1, figure=fig1)
manager.toolmanager.add_tool('f2', t1, figure=fig2)
manager.toolmanager.add_tool('f3', t1, figure=fig3)
sidebar.add_tool('f1', 'foo')
sidebar.add_tool('f2', 'foo')
sidebar.add_tool('f3', 'foo')
manager.window.add_element(sidebar, False, 'west')


manager.show()
manager.mpl_connect('window_destroy_event', manager.destroy)
manager._mainloop()

Loading