How to use the matplotlib.use function in matplotlib

To help you get started, we’ve selected a few matplotlib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github thierrydumas / autoencoder_based_image_compression / kodak_tensorflow / test_tf_utils.py View on Github external
"""A script to test the library that contains Tensorflow utilities."""

import argparse
import matplotlib
try:
    import PyQt5
    matplotlib.use('Qt5Agg')
except ImportError:
    matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy
import scipy.stats.distributions
import tensorflow as tf

import tf_utils.tf_utils as tfuls
import tools.tools as tls


class TesterTfUtils(object):
    """Class for testing the library that contains Tensorflow utilities."""
    
    def test_add_noise(self):
        """Tests the function `add_noise`.
        
        The test is successful if a tiny zero-mean uniform
github sci-wms / sci-wms / sciwms / settings / defaults.py View on Github external
if not os.path.isdir(db_path):
    os.makedirs(db_path)
db_file = os.path.join(db_path, "sci-wms.db")
huey_file = os.path.join(db_path, "huey.db")
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME':  db_file,
    }
}

# Grappelli
GRAPPELLI_ADMIN_TITLE = 'sci-wms'

# Matplotlib
matplotlib.use("Agg")

HUEY = {
    'name': 'sciwms',
    'filename': huey_file,
    'result_store': True,  # Store return values of tasks.
    'events': True,  # Consumer emits events allowing real-time monitoring.
    'store_none': True,  # If a task returns None, do not save to results.
    'immediate': True,  # If DEBUG=True, run synchronously.
    'store_errors': True,  # Store error info if task throws exception.
    'blocking': False,  # Poll the queue rather than do blocking pop.
    'backend_class': 'huey.SqliteHuey',  # Use path to redis huey by default,
}
github oval-group / PLNN-verification / tools / compare_relaxations.py View on Github external
#!/usr/bin/env python
import argparse
import matplotlib; matplotlib.use('agg')
import matplotlib.pyplot as plt
import torch

from plnn.branch_and_bound import box_split
from plnn.model import load_and_simplify
from plnn.network_linear_approximation import LinearizedNetwork
from torch.autograd import Variable
from timeit import default_timer as timer

font = {'size': 26}

matplotlib.rc('font', **font)

def make_plots(target_filename, measurements):
    (values, timings, names, dom_areas) = measurements
    target_format = "eps" if target_filename.endswith('.eps') else "png"
github pytorch / ignite / examples / gan / dcgan.py View on Github external
def create_plots(engine):
        try:
            import matplotlib as mpl
            mpl.use('agg')

            import numpy as np
            import pandas as pd
            import matplotlib.pyplot as plt

        except ImportError:
            warnings.warn('Loss plots will not be generated -- pandas or matplotlib not found')

        else:
            df = pd.read_csv(os.path.join(output_dir, LOGS_FNAME), delimiter='\t', index_col='iteration')
            _ = df.plot(subplots=True, figsize=(20, 20))
            _ = plt.xlabel('Iteration number')
            fig = plt.gcf()
            path = os.path.join(output_dir, PLOT_FNAME)

            fig.savefig(path)
github thomaskuestner / CNNArt / GUI / PyQt / Qt_main.py View on Github external
import matplotlib
matplotlib.use('Qt5Agg')
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
import os
import dicom
import dicom_numpy
from matplotlib import pyplot as plt
from matplotlib.widgets import LassoSelector, RectangleSelector, EllipseSelector
from matplotlib import path
import matplotlib.patches as patches
from matplotlib.patches import Ellipse

from framework1 import Ui_MainWindow
from Patches_window import*
from cPre_window import*
from activeview import Activeview
github olivierfriard / BORIS / src / plot_events.py View on Github external
import matplotlib.dates
import matplotlib.font_manager as font_manager
import matplotlib.pyplot as plt
import matplotlib.transforms as mtransforms
import numpy as np
from matplotlib import colors as mcolors
from matplotlib.dates import (HOURLY, MICROSECONDLY, MINUTELY, MONTHLY,
                              SECONDLY, WEEKLY, DateFormatter, RRuleLocator,
                              rrulewrapper)

import db_functions
import project_functions
import utilities
from config import *

matplotlib.use("Qt5Agg")


plt_colors = dict(mcolors.BASE_COLORS, **mcolors.CSS4_COLORS)


def default_value(ethogram, behavior, parameter):
    """
    return value for duration in case of point event
    """
    default_value_ = 0
    if (project_functions.event_type(behavior, ethogram) == "POINT EVENT"
            and parameter in ["duration"]):
        default_value_ = "NA"
    return default_value_
github amueller / kaggle_insults / train.py View on Github external
import numpy as np
import matplotlib as mpl
mpl.use('Agg')
from sklearn.cross_validation import train_test_split, ShuffleSplit
from sklearn.base import BaseEstimator, clone
from sklearn.grid_search import GridSearchCV
from sklearn.linear_model import LogisticRegression
from features import TextFeatureTransformer
from sklearn.metrics import roc_auc_score as auc_score
import matplotlib.pyplot as plt

from models import build_base_model
from models import build_elasticnet_model
from models import build_stacked_model
from models import build_nltk_model
#from sklearn.feature_selection import SelectPercentile, chi2


from util import load_data, load_extended_data, write_test, load_test
github ruoyu0088 / scpy2 / scipy / hrd_solver.py View on Github external
# -*- coding: utf-8 -*-
from collections import deque
from itertools import chain, product
import matplotlib
matplotlib.use("Qt4Agg")
import pylab as pl
import numpy as np
from .hrd import find_path

SPEED = 5

W, H = 4, 5

BLOCKS = {
    "A": (0, 1, W, W+1),
    "B": (0, W),
    "C": (0, 1),
    "D": (0,)
}

SIZES = {
github audiofhrozen / motion_dance / deepdancer / bin / annot_eval.py View on Github external
from deepdancer.motion import JOINTS
from deepdancer.motion import motionread
from madmom.features import beats

import multiprocessing as mp
import numpy as np
import pandas as pd
from scipy import signal
from scipy import stats
import six

try:
    disp = os.environ['DISPLAY']
except Exception as e:
    import matplotlib as mpl
    mpl.use('Agg')
    pass
from matplotlib import pyplot as plt


def convermp32wav(infile, outfile):
    folder = os.path.dirname(outfile)
    if not os.path.exists(folder):
        os.makedirs(folder)
    if platform == 'Windows':
        cmmd = 'ffmpeg -loglevel panic -y -i {} -acodec pcm_s16le -ar 16000 -ac 1 {}'.format(infile, outfile)
        subprocess.Popen(cmmd, shell=False).communicate()
    elif platform == 'Linux':
        os.system('sox {} -c 1 -r 16000 {}'.format(infile, outfile))
    else:
        raise TypeError('OS not supported')
    return
github juzb / DeeProtein / DeeProtein / post_processing / evaluate_masked_dump.py View on Github external
import os
import sys
from shutil import copyfile
import logging
import json
import scipy.stats as stats
import numpy as np
import Bio.PDB as pdb
from goatools.obo_parser import GODag
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
sys.path.insert(0, sys.argv[0].replace('post_processing/evaluate_masked_dump.py', 'helpers'))
from helpers_cpu import *

np.warnings.simplefilter('ignore', np.RankWarning)
plt.style.use(json.load(open(os.path.join(sys.path[0], '../style/style.json'), 'r')))

with open(os.path.join(sys.path[0], '../style/colors.json'), 'r') as pickle_file:
    colors = json.load(pickle_file)


class evaluate():
    """
    Read masked dump files that contain the sensitvity values. Calculates sphere variance, compares with information
    content.
    """