Skip to content

Instantly share code, notes, and snippets.

View afvincent's full-sized avatar

Adrien F. Vincent afvincent

  • Bordeaux INP
  • Bordeaux, France
View GitHub Profile
@afvincent
afvincent / imshow_slices.py
Last active February 18, 2018 17:07
Display slices of a picture
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.gridspec import GridSpec # only for Method 2
# A lot of information about GridSpec can be found here:
# https://matplotlib.org/tutorials/intermediate/gridspec.html
# Dummy data
uu = np.linspace(0, np.pi, 128)
data = np.cos(uu - 0.5) * np.cos(uu.reshape((-1, 1)) - 1.0)
@afvincent
afvincent / benchmark_new_auto_legend_locator.py
Last active October 30, 2017 04:58
Benchmark for matplotlib #9598
# -*- coding: utf-8 -*-
"""
Memo for pprofile:
pprofile --out cachegrind.out benchmark_cleverer_legend.py >> profiling.log
"""
from __future__ import division, print_function, unicode_literals
import numpy as np
import matplotlib.pyplot as plt
@afvincent
afvincent / modified_pcolor_log_example.py
Created March 18, 2017 09:50
Pcolor demo with LogNorm in a case with outliers, for different colormaps
"""
Based on the pcolor_log example:
http://matplotlib.org/examples/pylab_examples/pcolor_log.html
More about colormaps here:
http://matplotlib.org/users/colormaps.html
"""
import numpy as np
import matplotlib.pyplot as plt
@afvincent
afvincent / Hatches_and_Matplotlib_versions.diff
Created March 16, 2017 19:46
Exploring issue #8289 with Matplotlib 2.0 and the EPS rendering when hatching is used.
2,4c2,4
< %%Title: test_bis_1.5.1.eps
< %%Creator: matplotlib version 1.5.1, http://matplotlib.org/
< %%CreationDate: Thu Mar 16 10:19:55 2017
---
> %%Title: test_bis_2.0.eps
> %%Creator: matplotlib version 2.0.0, http://matplotlib.org/
> %%CreationDate: Thu Mar 16 10:19:13 2017
6c6
< %%BoundingBox: 18 180 594 612
@afvincent
afvincent / mwe_bissect_issue_7751.py
Last active January 6, 2017 17:34
Some kind of MWE to bissect Matplotlib issue #7751
"""
MWE to bissect issue #7751
======================================
Radar chart (aka spider or star chart)
======================================
This example creates a radar chart, also known as a spider or star chart [1]_.
Although this example allows a frame of either 'circle' or 'polygon', polygon
@afvincent
afvincent / modified_resample.py
Created August 5, 2016 10:20
Possible new version of the event handling resample.py
import numpy as np
import matplotlib.pyplot as plt
# A class that will downsample the data if there are too many points to display
class DataDisplayResampler(object):
def __init__(self, xdata, ydata, max_disp_samples=80):
self.origYData = ydata
self.origXData = xdata
self.max_disp_samples = max_disp_samples