Python matplotlib.transforms.BlendedGenericTransform() Examples
The following are 7
code examples of matplotlib.transforms.BlendedGenericTransform().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
matplotlib.transforms
, or try the search function
.
Example #1
Source File: test_transforms.py From neural-network-animation with MIT License | 6 votes |
def test_clipping_of_log(): # issue 804 M,L,C = Path.MOVETO, Path.LINETO, Path.CLOSEPOLY points = [ (0.2, -99), (0.4, -99), (0.4, 20), (0.2, 20), (0.2, -99) ] codes = [ M, L, L, L, C ] path = Path(points, codes) # something like this happens in plotting logarithmic histograms trans = BlendedGenericTransform(Affine2D(), LogScale.Log10Transform('clip')) tpath = trans.transform_path_non_affine(path) result = tpath.iter_segments(trans.get_affine(), clip=(0, 0, 100, 100), simplify=False) tpoints, tcodes = list(zip(*result)) # Because y coordinate -99 is outside the clip zone, the first # line segment is effectively removed. That means that the closepoly # operation must be replaced by a move to the first point. assert np.allclose(tcodes, [ M, M, L, L, L ])
Example #2
Source File: test_transforms.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_clipping_of_log(): # issue 804 M, L, C = Path.MOVETO, Path.LINETO, Path.CLOSEPOLY points = [(0.2, -99), (0.4, -99), (0.4, 20), (0.2, 20), (0.2, -99)] codes = [M, L, L, L, C] path = Path(points, codes) # something like this happens in plotting logarithmic histograms trans = mtransforms.BlendedGenericTransform(mtransforms.Affine2D(), LogScale.Log10Transform('clip')) tpath = trans.transform_path_non_affine(path) result = tpath.iter_segments(trans.get_affine(), clip=(0, 0, 100, 100), simplify=False) tpoints, tcodes = zip(*result) assert_allclose(tcodes, [M, L, L, L, C])
Example #3
Source File: test_transforms.py From ImageFusion with MIT License | 6 votes |
def test_clipping_of_log(): # issue 804 M,L,C = Path.MOVETO, Path.LINETO, Path.CLOSEPOLY points = [ (0.2, -99), (0.4, -99), (0.4, 20), (0.2, 20), (0.2, -99) ] codes = [ M, L, L, L, C ] path = Path(points, codes) # something like this happens in plotting logarithmic histograms trans = BlendedGenericTransform(Affine2D(), LogScale.Log10Transform('clip')) tpath = trans.transform_path_non_affine(path) result = tpath.iter_segments(trans.get_affine(), clip=(0, 0, 100, 100), simplify=False) tpoints, tcodes = list(zip(*result)) # Because y coordinate -99 is outside the clip zone, the first # line segment is effectively removed. That means that the closepoly # operation must be replaced by a move to the first point. assert np.allclose(tcodes, [ M, M, L, L, L ])
Example #4
Source File: test_transforms.py From coffeegrindsize with MIT License | 6 votes |
def test_clipping_of_log(): # issue 804 M, L, C = Path.MOVETO, Path.LINETO, Path.CLOSEPOLY points = [(0.2, -99), (0.4, -99), (0.4, 20), (0.2, 20), (0.2, -99)] codes = [M, L, L, L, C] path = Path(points, codes) # something like this happens in plotting logarithmic histograms trans = mtransforms.BlendedGenericTransform(mtransforms.Affine2D(), LogScale.Log10Transform('clip')) tpath = trans.transform_path_non_affine(path) result = tpath.iter_segments(trans.get_affine(), clip=(0, 0, 100, 100), simplify=False) tpoints, tcodes = zip(*result) assert_allclose(tcodes, [M, L, L, L, C])
Example #5
Source File: test_transforms.py From twitter-stock-recommendation with MIT License | 6 votes |
def test_clipping_of_log(): # issue 804 M, L, C = Path.MOVETO, Path.LINETO, Path.CLOSEPOLY points = [(0.2, -99), (0.4, -99), (0.4, 20), (0.2, 20), (0.2, -99)] codes = [M, L, L, L, C] path = Path(points, codes) # something like this happens in plotting logarithmic histograms trans = mtransforms.BlendedGenericTransform(mtransforms.Affine2D(), LogScale.Log10Transform('clip')) tpath = trans.transform_path_non_affine(path) result = tpath.iter_segments(trans.get_affine(), clip=(0, 0, 100, 100), simplify=False) tpoints, tcodes = zip(*result) assert_allclose(tcodes, [M, L, L, L, C])
Example #6
Source File: exporter.py From mplexporter with BSD 3-Clause "New" or "Revised" License | 4 votes |
def process_transform(transform, ax=None, data=None, return_trans=False, force_trans=None): """Process the transform and convert data to figure or data coordinates Parameters ---------- transform : matplotlib Transform object The transform applied to the data ax : matplotlib Axes object (optional) The axes the data is associated with data : ndarray (optional) The array of data to be transformed. return_trans : bool (optional) If true, return the final transform of the data force_trans : matplotlib.transform instance (optional) If supplied, first force the data to this transform Returns ------- code : string Code is either "data", "axes", "figure", or "display", indicating the type of coordinates output. transform : matplotlib transform the transform used to map input data to output data. Returned only if return_trans is True new_data : ndarray Data transformed to match the given coordinate code. Returned only if data is specified """ if isinstance(transform, transforms.BlendedGenericTransform): warnings.warn("Blended transforms not yet supported. " "Zoom behavior may not work as expected.") if force_trans is not None: if data is not None: data = (transform - force_trans).transform(data) transform = force_trans code = "display" if ax is not None: for (c, trans) in [("data", ax.transData), ("axes", ax.transAxes), ("figure", ax.figure.transFigure), ("display", transforms.IdentityTransform())]: if transform.contains_branch(trans): code, transform = (c, transform - trans) break if data is not None: if return_trans: return code, transform.transform(data), transform else: return code, transform.transform(data) else: if return_trans: return code, transform else: return code
Example #7
Source File: exporter.py From lddmm-ot with MIT License | 4 votes |
def process_transform(transform, ax=None, data=None, return_trans=False, force_trans=None): """Process the transform and convert data to figure or data coordinates Parameters ---------- transform : matplotlib Transform object The transform applied to the data ax : matplotlib Axes object (optional) The axes the data is associated with data : ndarray (optional) The array of data to be transformed. return_trans : bool (optional) If true, return the final transform of the data force_trans : matplotlib.transform instance (optional) If supplied, first force the data to this transform Returns ------- code : string Code is either "data", "axes", "figure", or "display", indicating the type of coordinates output. transform : matplotlib transform the transform used to map input data to output data. Returned only if return_trans is True new_data : ndarray Data transformed to match the given coordinate code. Returned only if data is specified """ if isinstance(transform, transforms.BlendedGenericTransform): warnings.warn("Blended transforms not yet supported. " "Zoom behavior may not work as expected.") if force_trans is not None: if data is not None: data = (transform - force_trans).transform(data) transform = force_trans code = "display" if ax is not None: for (c, trans) in [("data", ax.transData), ("axes", ax.transAxes), ("figure", ax.figure.transFigure), ("display", transforms.IdentityTransform())]: if transform.contains_branch(trans): code, transform = (c, transform - trans) break if data is not None: if return_trans: return code, transform.transform(data), transform else: return code, transform.transform(data) else: if return_trans: return code, transform else: return code