Пример #1
0
def set_mpl_backend():

    from matplotlib import rcParams, rcdefaults

    # Standardize mpl setup
    rcdefaults()

    # Set default backend to Agg. The Qt and Jupyter glue applications don't
    # use the default backend, so this is just to make sure that importing
    # matplotlib doesn't cause errors related to the MacOSX or Qt backend.
    rcParams['backend'] = 'Agg'

    # Disable key bindings in matplotlib
    for setting in list(rcParams.keys()):
        if setting.startswith('keymap'):
            rcParams[setting] = ''

    # Set the MPLBACKEND variable explicitly, because ipykernel uses the lack of
    # MPLBACKEND variable to indicate that it should use its own backend, and
    # this in turn causes some rcParams to be changed, causing test failures
    # etc.
    os.environ['MPLBACKEND'] = 'Agg'

    # Explicitly switch backend
    from matplotlib.pyplot import switch_backend
    switch_backend('agg')
Пример #2
0
def set_mpl_backend():

    from matplotlib import rcParams, rcdefaults

    # Standardize mpl setup
    rcdefaults()

    # Set default backend to Agg. The Qt and Jupyter glue applications don't
    # use the default backend, so this is just to make sure that importing
    # matplotlib doesn't cause errors related to the MacOSX or Qt backend.
    rcParams['backend'] = 'Agg'

    # Disable key bindings in matplotlib
    for setting in list(rcParams.keys()):
        if setting.startswith('keymap'):
            rcParams[setting] = ''

    # The following is a workaround for the fact that Matplotlib checks the
    # rcParams at import time, not at run-time. This is fixed in Matplotlib>=2.1
    from matplotlib import get_backend
    from matplotlib import backends
    backends.backend = get_backend()

    # Set the MPLBACKEND variable explicitly, because ipykernel uses the lack of
    # MPLBACKEND variable to indicate that it should use its own backend, and
    # this in turn causes some rcParams to be changed, causing test failures
    # etc.
    os.environ['MPLBACKEND'] = 'Agg'
Пример #3
0
def set_mpl_backend():

    try:
        from qtpy import PYQT5  # noqa
    except Exception:
        # If Qt isn't available, we don't have to worry about
        # setting the backend
        return

    from matplotlib import rcParams, rcdefaults

    # standardize mpl setup
    rcdefaults()

    rcParams['backend'] = 'Qt5Agg'

    # disable key bindings in matplotlib
    for setting in list(rcParams.keys()):
        if setting.startswith('keymap'):
            rcParams[setting] = ''

    # The following is a workaround for the fact that Matplotlib checks the
    # rcParams at import time, not at run-time. I have opened an issue with
    # Matplotlib here: https://github.com/matplotlib/matplotlib/issues/5513
    from matplotlib import get_backend
    from matplotlib import backends
    backends.backend = get_backend()
Пример #4
0
def __ein_get_matplotlib_params():
    if __ein_matplotlib_available:
        import json
        print(json.dumps([k for k in __ein_rcParams.keys()]))
    else:
        raise RuntimeError(
            "Matplotlib not installed in this instance of python!")
Пример #5
0
    def __init__(self, box, title = 'Window', padding = 0.10, toolbar = False):
        """
        width & height in inches
        """

        self._box = box
        self._padding = padding

        w, h = box.size()

        padding = 0.10

        w += 2.0 * padding
        h += 2.0 * padding

        orig_toolbar_settig = mpl.rcParams['toolbar']

        if not toolbar:
            mpl.rcParams['toolbar'] = 'None'

        self._fig = plt.figure(figsize=(w,h))

        self._fig.subplots_adjust(
            left = 0.0,
            bottom = 0.0,
            right = 1.0,
            top = 1.0,
            wspace = 0.0,
            hspace = 0.0,
        )

        self._fig.canvas.set_window_title(title)

        x = padding
        y = padding

        box._render(self._fig, x, y)

        # restore default rcparams
        mpl.rcParams['toolbar'] = orig_toolbar_settig

        #----------------------------------------------------------------------
        # disable the default keymap

        self._rc_keys_to_disable = []

        for key in rcParams.keys():
            if u'keymap' in key:
                self._rc_keys_to_disable.append(key)
                rcParams[key] = ''

        self._rc_keys_disabled = {}
Пример #6
0
def new_figure_manager_given_figure(num, figure):
    """
    Create a new figure manager instance for the given figure.
    """
    from matplotlib._pylab_helpers import Gcf

    def closer(event):
        Gcf.destroy(num)

    canvas = Canvas(figure)
    if 'nbagg.transparent' in set(rcParams.keys()) and rcParams['nbagg.transparent']:
        figure.patch.set_alpha(0)
    manager = FigureManager(canvas, num)

    if is_interactive():
        manager.show()
        figure.canvas.draw_idle()

    canvas.mpl_connect('close_event', closer)

    return manager
def new_figure_manager_given_figure(num, figure):
    """
    Create a new figure manager instance for the given figure.
    """
    from matplotlib._pylab_helpers import Gcf

    def closer(event):
        Gcf.destroy(num)

    canvas = FigureCanvasNbAgg(figure)
    if 'nbagg.transparent' in set(rcParams.keys()) and rcParams['nbagg.transparent']:
        figure.patch.set_alpha(0)
    manager = FigureManagerNbAgg(canvas, num)

    if is_interactive():
        manager.show()
        figure.canvas.draw_idle()

    canvas.mpl_connect('close_event', closer)

    return manager
Пример #8
0
def set_mpl_backend():

    from matplotlib import rcParams, rcdefaults

    # Standardize mpl setup
    rcdefaults()

    # Set default backend to Agg. The Qt and Jupyter glue applications don't
    # use the default backend, so this is just to make sure that importing
    # matplotlib doesn't cause errors related to the MacOSX or Qt backend.
    rcParams['backend'] = 'Agg'

    # Disable key bindings in matplotlib
    for setting in list(rcParams.keys()):
        if setting.startswith('keymap'):
            rcParams[setting] = ''

    # The following is a workaround for the fact that Matplotlib checks the
    # rcParams at import time, not at run-time. This is fixed in Matplotlib>=2.1
    from matplotlib import get_backend
    from matplotlib import backends
    backends.backend = get_backend()
Пример #9
0
              'suptitle.size', 'title.size', 'leftlabel.size', 'toplabel.size',
              'rightlabel.size', 'bottomlabel.size'),  # the 'large' fonts
    'linewidth': ('axes.linewidth', 'geoaxes.linewidth', 'hatch.linewidth',
                  'xtick.major.width', 'ytick.major.width'),
    'margin': ('axes.xmargin', 'axes.ymargin'),
    'grid': ('axes.grid', ),
    'gridminor': ('axes.gridminor', ),
    'geogrid': ('axes.geogrid', ),
    'ticklen': ('xtick.major.size', 'ytick.major.size'),
    'tickdir': ('xtick.direction', 'ytick.direction'),
    'tickpad': ('xtick.major.pad', 'xtick.minor.pad', 'ytick.major.pad',
                'ytick.minor.pad'),
}

# Names of the new settings
RC_PARAMNAMES = {*rcParams.keys()}
RC_SHORTNAMES = {
    'abc', 'span', 'share', 'align', 'tight', 'fontname', 'cmap', 'lut',
    'cycle', 'rgbcycle', 'alpha', 'facecolor', 'color', 'small', 'large',
    'linewidth', 'margin', 'grid', 'gridminor', 'geogrid', 'ticklen',
    'tickdir', 'tickpad', 'tickratio', 'ticklenratio', 'gridratio', 'reso',
    'land', 'ocean', 'lakes', 'coast', 'borders', 'innerborders', 'rivers',
    'nbsetup', 'format', 'autosave', 'autoreload'
}
RC_CUSTOMNAMES = {
    'axes.formatter.zerotrim',
    'axes.formatter.timerotation',
    'axes.gridminor',
    'axes.geogrid',
    'axes.alpha',
    'image.levels',
Пример #10
0
 def marker():
     return "lines.marker" in rcParams.keys()
Пример #11
0
 def present():
     return "lines.markerfacecolor" in rcParams.keys()
Пример #12
0
from copy import deepcopy
from matplotlib import pyplot as plt
from eosDriver import kentaDataTofLogRhoFit1, kentaDataTofLogRhoFit2, getTRollFunc
from matplotlib import rcParams, rc
import numpy
import eosDriver
import plot_defaults
#plt.rcParams['legend.fontsize'] = 18
print rcParams.keys()
#rcParams['ytick.major.pad'] = 5
#rcParams['xtick.major.pad'] = 10
#rcParams['figure.subplot.left'] = 0.13
##### change a few standard settings
rcParams['xtick.major.size'] = 13
rcParams['xtick.major.pad']  = 8
rcParams['xtick.minor.size'] = 7
rc('legend', fontsize=26) #16
rcParams['ytick.major.size'] = 13
rcParams['ytick.major.pad']  = 8
rcParams['ytick.minor.size'] = 7
fig = plt.figure(figsize=(10, 8))
fig.subplots_adjust(left=0.14)
fig.subplots_adjust(bottom=0.14)
fig.subplots_adjust(top=0.967)
fig.subplots_adjust(right=0.97)

##############################################################################
# Load Shen EOS for ye comparisons
##############################################################################
shen = eosDriver.eosDriver('/home/jeff/work/HShenEOS_rho220_temp180_ye65_version_1.1_20120817.h5')
ls220 = eosDriver.eosDriver('/home/jeff/work/LS220_234r_136t_50y_analmu_20091212_SVNr26.h5')
Пример #13
0
import numpy as np,pylab as pl,pandas as pd
import sys,h5py,urllib,zipfile,imageio,PIL
import tensorflow as tf
import tensorflow.keras.layers as tkl
from tensorflow_docs.vis import embed
from matplotlib import rcParams
rcParams['font.family']='serif'
#'light', 'normal','regular', 'book', 'medium', 'roman', 
#'semibold', 'demibold', 'demi', 'bold', 'heavy', 'extra bold', 'black'
rcParams['font.weight']='heavy'
#'ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed', 'normal',
#'semi-expanded', 'expanded', 'extra-expanded', 'ultra-expanded'
rcParams['font.stretch']='extra-expanded'

pd.DataFrame([list(rcParams.keys()),list(rcParams.values())])\
.T.iloc[100:130]

seed_size=16; noise_dim=196; epochs=120
buffer_size=60000; batch_size=256
norm_img=tf.random.normal([1,noise_dim])
seed_imgs=tf.random.normal([seed_size,noise_dim])

clickhtml('Data')

(x,y),(_, _)=tf.keras.datasets.mnist.load_data()
x=x.reshape(x.shape[0],28,28,1).astype('float32')
print(x[0].shape,x.mean())

x[0][:28,15:20,:1].reshape(28*5)