8000 Add test to colorbar.py to see if ax is an object as returned by plt.subplots by jklymak · Pull Request #8733 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Add test to colorbar.py to see if ax is an object as returned by plt.subplots #8733

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
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
67d2324
Make histogram example figures fit on web page
dstansby May 12, 2017
719d556
Clarify how a FancyArrowPatch behaves
dstansby Jun 2, 2017
5d88cca
Fix typos
taehoonlee Jun 3, 2017
22488ff
Various cleanups to backends code.
anntzer Jun 3, 2017
df9e1d7
removing sgskip
choldgraf Jun 7, 2017
bb29bb6
Clarify in display units
dstansby Jun 7, 2017
f76a010
Parameterize test_fill_between and test_fill_betweenx
patniharshit Jun 7, 2017
a0ccb78
Add ids to test_fill_between tests
patniharshit Jun 7, 2017
2e6b968
colorbar.py: added test to see if parents are an object and to flatte…
jklymak Jun 8, 2017
7146ae6
Fixed PEP 8 error
jklymak Jun 8, 2017
1774e56
Merge pull request #8709 from taehoonlee/fix_typos
QuLogic Jun 8, 2017
34fda3e
Merge pull request #8729 from patniharshit/test_fill_between
QuLogic Jun 8, 2017
7fd3e25
Fixed so that we check to see if the object is an ndarray
jklymak Jun 8, 2017
80e9ec1
simplified logic to take into account all possible input cases
jklymak Jun 9, 2017
622307f
Merge pull request #8614 from dstansby/hist-example
tacaswell Jun 9, 2017
95cfdeb
Merge pull request #8725 from choldgraf/rem_sgskip
tacaswell Jun 9, 2017
1383228
Merge pull request #8703 from dstansby/fancyarrowpatch-clarify
anntzer Jun 9, 2017
4d26d74
Allow divmod to be overridden by numpy
dstansby Jun 9, 2017
60f547a
Merge pull request #8735 from dstansby/fix-tests
dstansby Jun 9, 2017
90ded74
Merge pull request #8711 from anntzer/backends-cleanup
QuLogic Jun 9, 2017
a5053c3
colorbar.py: added test to see if parents are an object and to flatte…
jklymak Jun 8, 2017
e178d2b
Fixed PEP 8 error
jklymak Jun 8, 2017
c4ea69a
Fixed so that we check to see if the object is an ndarray
jklymak Jun 8, 2017
0e31a22
simplified logic to take into account all possible input cases
jklymak Jun 9, 2017
3b2e06f
Rebased, hopefully get rid of CI error
jklymak Jun 9, 2017
b82411a
Rebased, hopefully get rid of CI error
jklymak Jun 9, 2017
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
34 changes: 0 additions & 34 deletions lib/matplotlib/backends/backend_agg.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,25 +84,18 @@ class RendererAgg(RendererBase):

lock = threading.RLock()
def __init__(self, width, height, dpi):
if __debug__: verbose.report('RendererAgg.__init__', 'debug-annoying')
RendererBase.__init__(self)

self.dpi = dpi
self.width = width
self.height = height
if __debug__: verbose.report('RendererAgg.__init__ width=%s, height=%s'%(width, height), 'debug-annoying')
self._renderer = _RendererAgg(int(width), int(height), dpi, debug=False)
self._filter_renderers = []

if __debug__: verbose.report('RendererAgg.__init__ _RendererAgg done',
'debug-annoying')

self._update_methods()
self.mathtext_parser = MathTextParser('Agg')

self.bbox = Bbox.from_bounds(0, 0, self.width, self.height)
if __debug__: verbose.report('RendererAgg.__init__ done',
'debug-annoying')

def __getstate__(self):
# We only want to preserve the init keywords of the Renderer.
Expand Down Expand Up @@ -178,8 +171,6 @@ def draw_mathtext(self, gc, x, y, s, prop, angle):
"""
Draw the math text using matplotlib.mathtext
"""
if __debug__: verbose.report('RendererAgg.draw_mathtext',
'debug-annoying')
ox, oy, width, height, descent, font_image, used_characters = \
self.mathtext_parser.parse(s, self.dpi, prop)

Expand All @@ -193,8 +184,6 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
"""
Render the text
"""
if __debug__: verbose.report('RendererAgg.draw_text', 'debug-annoying')

if ismath:
return self.draw_mathtext(gc, x, y, s, prop, angle)

Expand Down Expand Up @@ -279,9 +268,6 @@ def _get_agg_font(self, prop):
"""
Get the font for text instance t, cacheing for efficiency
"""
if __debug__: verbose.report('RendererAgg._get_agg_font',
'debug-annoying')

fname = findfont(prop)
font = get_font(
fname,
Expand All @@ -298,23 +284,15 @@ def points_to_pixels(self, points):
convert point measures to pixes using dpi and the pixels per
inch of the display
"""
if __debug__: verbose.report('RendererAgg.points_to_pixels',
'debug-annoying')
return points*self.dpi/72.0

def tostring_rgb(self):
if __debug__: verbose.report('RendererAgg.tostring_rgb',
'debug-annoying')
return self._renderer.tostring_rgb()

def tostring_argb(self):
if __debug__: verbose.report('RendererAgg.tostring_argb',
'debug-annoying')
return self._renderer.tostring_argb()

def buffer_rgba(self):
if __debug__: verbose.report('RendererAgg.buffer_rgba',
'debug-annoying')
return self._renderer.buffer_rgba()

def clear(self):
Expand Down Expand Up @@ -423,10 +401,6 @@ def new_figure_manager(num, *args, **kwargs):
"""
Create a new figure manager instance
"""
if __debug__: verbose.report('backend_agg.new_figure_manager',
'debug-annoying')


FigureClass = kwargs.pop('FigureClass', Figure)
thisFig = FigureClass(*args, **kwargs)
return new_figure_manager_given_figure(num, thisFig)
Expand Down Expand Up @@ -465,8 +439,6 @@ def draw(self):
"""
Draw the figure using the renderer
"""
if __debug__: verbose.report('FigureCanvasAgg.draw', 'debug-annoying')

self.renderer = self.get_renderer(cleared=True)
# acquire a lock on the shared font cache
RendererAgg.lock.acquire()
Expand Down Expand Up @@ -500,8 +472,6 @@ def tostring_rgb(self):
-------
bytes
'''
if __debug__: verbose.report('FigureCanvasAgg.tostring_rgb',
'debug-annoying')
return self.renderer.tostring_rgb()

def tostring_argb(self):
Expand All @@ -515,8 +485,6 @@ def tostring_argb(self):
bytes

'''
if __debug__: verbose.report('FigureCanvasAgg.tostring_argb',
'debug-annoying')
return self.renderer.tostring_argb()

def buffer_rgba(self):
Expand All @@ -529,8 +497,6 @@ def buffer_rgba(self):
-------
bytes
'''
if __debug__: verbose.report('FigureCanvasAgg.buffer_rgba',
'debug-annoying')
return self.renderer.buffer_rgba()

def print_raw(self, filename_or_obj, *args, **kwargs):
Expand Down
18 changes: 0 additions & 18 deletions lib/matplotlib/backends/backend_cairo.py
B41A
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@

import numpy as np

def _fn_name(): return sys._getframe(1).f_code.co_name

try:
import cairocffi as cairo
except ImportError:
Expand Down Expand Up @@ -58,9 +56,6 @@ def _fn_name(): return sys._getframe(1).f_code.co_name
from matplotlib.transforms import Bbox, Affine2D
from matplotlib.font_manager import ttfFontProperty

_debug = False
#_debug = True

# Image::color_conv(format) for draw_image()
if sys.byteorder == 'little':
BYTE_FORMAT = 0 # BGRA
Expand Down Expand Up @@ -114,7 +109,6 @@ class RendererCairo(RendererBase):
def __init__(self, dpi):
"""
"""
if _debug: print('%s.%s()' % (self.__class__.__name__, _fn_name()))
self.dpi = dpi
self.gc = GraphicsContextCairo (renderer=self)
self.text_ctx = cairo.Context (
Expand Down Expand Up @@ -227,8 +221,6 @@ def draw_markers(self, gc, marker_path, marker_trans, path, transform, rgbFace=N

def draw_image(self, gc, x, y, im):
# bbox - not currently used
if _debug: print('%s.%s()' % (self.__class__.__name__, _fn_name()))

if sys.byteorder == 'little':
im = im[:, :, (2, 1, 0, 3)]
else:
Expand Down Expand Up @@ -266,8 +258,6 @@ def draw_image(self, gc, x, y, im):
def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
# Note: x,y are device/display coords, not user-coords, unlike other
# draw_* methods
if _debug: print('%s.%s()' % (self.__class__.__name__, _fn_name()))

if ismath:
self._draw_mathtext(gc, x, y, s, prop, angle)

Expand Down Expand Up @@ -297,8 +287,6 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
ctx.restore()

def _draw_mathtext(self, gc, x, y, s, prop, angle):
if _debug: print('%s.%s()' % (self.__class__.__name__, _fn_name()))

ctx = gc.ctx
width, height, descent, glyphs, rects = self.mathtext_parser.parse(
s, self.dpi, prop)
Expand Down Expand Up @@ -335,19 +323,16 @@ def _draw_mathtext(self, gc, x, y, s, prop, angle):


def flipy(self):
if _debug: print('%s.%s()' % (self.__class__.__name__, _fn_name()))
return True
#return False # tried - all draw objects ok except text (and images?)
# which comes out mirrored!


def get_canvas_width_height(self):
if _debug: print('%s.%s()' % (self.__class__.__name__, _fn_name()))
return self.width, self.height


def get_text_width_height_descent(self, s, prop, ismath):
if _debug: print('%s.%s()' % (self.__class__.__name__, _fn_name()))
if ismath:
width, height, descent, fonts, used_characters = self.mathtext_parser.parse(
s, self.dpi, prop)
Expand Down Expand Up @@ -376,15 +361,13 @@ def get_text_width_height_descent(self, s, prop, ismath):


def new_gc(self):
if _debug: print('%s.%s()' % (self.__class__.__name__, _fn_name()))
self.gc.ctx.save()
self.gc._alpha = 1.0
self.gc._forced_alpha = False # if True, _alpha overrides A from RGBA
return self.gc


def points_to_pixels(self, points):
if _debug: print('%s.%s()' % (self.__class__.__name__, _fn_name()))
return points/72.0 * self.dpi


Expand Down Expand Up @@ -488,7 +471,6 @@ def new_figure_manager(num, *args, **kwargs): # called by backends/__init__.py
"""
Create a new figure manager instance
"""
if _debug: print('%s()' % (_fn_name()))
FigureClass = kwargs.pop('FigureClass', Figure)
thisFig = FigureClass(*args, **kwargs)
return new_figure_manager_given_figure(num, thisFig)
Expand Down
6 changes: 2 additions & 4 deletions lib/matplotlib/backends/backend_gdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import os
import sys
import warnings
def fn_name(): return sys._getframe(1).f_code.co_name

import gobject
import gtk; gdk = gtk.gdk
Expand All @@ -24,16 +23,15 @@ def fn_name(): return sys._getframe(1).f_code.co_name
import matplotlib
from matplotlib import rcParams
from matplotlib._pylab_helpers import Gcf
from matplotlib.backend_bases import RendererBase, GraphicsContextBase, \
FigureManagerBase, FigureCanvasBase
from matplotlib.backend_bases import (
RendererBase, GraphicsContextBase, FigureManagerBase, FigureCanvasBase)
from matplotlib.cbook import restrict_dict, warn_deprecated
from matplotlib.figure import Figure
from matplotlib.mathtext import MathTextParser
from matplotlib.transforms import Affine2D
from matplotlib.backends._backend_gdk import pixbuf_get_pixels_array

backend_version = "%d.%d.%d" % gtk.pygtk_version
_debug = False

# Image formats that this backend supports - for FileChooser and print_figure()
IMAGE_FORMAT = sorted(['bmp', 'eps', 'jpg', 'png', 'ps', 'svg']) # 'raw', 'rgb'
Expand Down
20 changes: 0 additions & 20 deletions lib/matplotlib/backends/backend_gtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import six

import os, sys, warnings
def fn_name(): return sys._getframe(1).f_code.co_name

if six.PY3:
warnings.warn(
Expand Down Expand Up @@ -44,9 +43,6 @@ def fn_name(): return sys._getframe(1).f_code.co_name

backend_version = "%d.%d.%d" % gtk.pygtk_version

_debug = False
#_debug = True

# the true dots per inch on the screen; should be display dependent
# see http://groups.google.com/groups?q=screen+dpi+x11&hl=en&lr=&ie=UTF-8&oe=UTF-8&safe=off&selm=7077.26e81ad5%40swift.cs.tcd.ie&rnum=5 for some info about screen dpi
PIXELS_PER_INCH = 96
Expand Down Expand Up @@ -225,7 +221,6 @@ def __init__(self, figure):
"See Matplotlib usage FAQ for"
" more info on backends.",
alternative="GTKAgg")
if _debug: print('FigureCanvasGTK.%s' % fn_name())
FigureCanvasBase.__init__(self, figure)
gtk.DrawingArea.__init__(self)

Expand Down Expand Up @@ -261,7 +256,6 @@ def destroy(self):
gobject.source_remove(self._idle_draw_id)

def scroll_event(self, widget, event):
if _debug: print('FigureCanvasGTK.%s' % fn_name())
x = event.x
# flipy so y=0 is bottom of canvas
y = self.allocation.height - event.y
Expand All @@ -273,7 +267,6 @@ def scroll_event(self, widget, event):
return False # finish event propagation?

def button_press_event(self, widget, event):
if _debug: print('FigureCanvasGTK.%s' % fn_name())
x = event.x
# flipy so y=0 is bottom of canvas
y = self.allocation.height - event.y
Expand All @@ -297,29 +290,23 @@ def button_press_event(self, widget, event):
return False # finish event propagation?

def button_release_event(self, widget, event):
if _debug: print('FigureCanvasGTK.%s' % fn_name())
x = event.x
# flipy so y=0 is bottom of canvas
y = self.allocation.height - event.y
FigureCanvasBase.button_release_event(self, x, y, event.button, guiEvent=event)
return False # finish event propagation?

def key_press_event(self, widget, event):
if _debug: print('FigureCanvasGTK.%s' % fn_name())
key = self._get_key(event)
if _debug: print("hit", key)
FigureCanvasBase.key_press_event(self, key, guiEvent=event)
return True # stop event propagation

def key_release_event(self, widget, event):
if _debug: print('FigureCanvasGTK.%s' % fn_name())
key = self._get_key(event)
if _debug: print("release", key)
FigureCanvasBase.key_release_event(self, key, guiEvent=event)
return True # stop event propagation

def motion_notify_event(self, widget, event):
if _debug: print('FigureCanvasGTK.%s' % fn_name())
if event.is_hint:
x, y, state = event.window.get_pointer()
else:
Expand Down Expand Up @@ -355,7 +342,6 @@ def _get_key(self, event):
return key

def configure_event(self, widget, event):
if _debug: print('FigureCanvasGTK.%s' % fn_name())
if widget.window is None:
return
w, h = event.width, event.height
Expand Down Expand Up @@ -408,8 +394,6 @@ def _pixmap_prepare(self, width, height):
Make sure _._pixmap is at least width, height,
create new pixmap if necessary
"""
if _debug: print('FigureCanvasGTK.%s' % fn_name())

create_pixmap = False
if width > self._pixmap_width:
# increase the pixmap in 10%+ (rather than 1 pixel) steps
Expand Down Expand Up @@ -438,8 +422,6 @@ def _render_figure(self, pixmap, width, height):
def expose_event(self, widget, event):
"""Expose_event for all GTK backends. Should not be overridden.
"""
if _debug: print('FigureCanvasGTK.%s' % fn_name())

if GTK_WIDGET_DRAWABLE(self):
if self._need_redraw:
x, y, w, h = self.allocation
Expand Down Expand Up @@ -556,7 +538,6 @@ class FigureManagerGTK(FigureManagerBase):

"""
def __init__(self, canvas, num):
if _debug: print('FigureManagerGTK.%s' % fn_name())
FigureManagerBase.__init__(self, canvas, num)

self.window = gtk.Window()
Expand Down Expand Up @@ -610,7 +591,6 @@ def notify_axes_change(fig):
self.canvas.grab_focus()

def destroy(self, *args):
if _debug: print('FigureManagerGTK.%s' % fn_name())
if hasattr(self, 'toolbar') and self.toolbar is not None:
self.toolbar.destroy()
if hasattr(self, 'vbox'):
Expand Down
Loading
0