예제 #1
0
def stems(x, y, ax=None, label=None, mkr_fmt=None, **kwargs):
    """
    Provide a faster replacement for stem plots under matplotlib < 3.1.0 using 
    vlines (= LineCollection). LineCollection keywords are supported.
    """
    # create a copy of the kwargs dict without 'bottom' key-value pair, provide
    # default value = 0:
    bottom = kwargs.get('bottom', 0)
    kwargs_cp = {k: v for k, v in kwargs.items() if k not in ['bottom']}
    if cmp_version("matplotlib", "3.1.0") >= 0:
        kwargs_cp = {k: v for k, v in kwargs.items() if k not in ['bottom']}
        ax.axhline(bottom, **kwargs_cp)
        ml, sl, bl = ax.stem(x, y, use_line_collection=True, bottom=bottom)
        setp(ml, **mkr_fmt)
        setp(bl, **kwargs_cp)
        setp(sl, **kwargs_cp)
    else:
        ax.axhline(bottom, **kwargs_cp)
        ax.vlines(x, y, bottom, label=label, **kwargs_cp)
        # ax.set_ylim([1.05*y.min(), 1.05*y.max()])
        scatter(x, y, ax=ax, label=label, mkr_fmt=mkr_fmt, **kwargs)

    handle = (lines.Line2D([], [], **kwargs_cp), lines.Line2D([], [],
                                                              **mkr_fmt))
    return handle
예제 #2
0
    def __init__(self, parent):
        super(MplWidget, self).__init__(parent)
        # Create the mpl figure and subplot (white bg, 100 dots-per-inch).
        # Construct the canvas with the figure:
        self.plt_lim = [] # define variable for x,y plot limits

        if cmp_version("matplotlib", "2.2.0") >= 0:
            self.fig = Figure(constrained_layout=True)
        else:
            self.fig = Figure()

        self.canvas = FigureCanvas(self.fig)
        self.canvas.setSizePolicy(QSizePolicy.Expanding,
                                   QSizePolicy.Expanding)

        # Needed for mouse modifiers (x,y, <CTRL>, ...):
        #    Key press events in general are not processed unless you
        #    "activate the focus of Qt onto your mpl canvas"
        # http://stackoverflow.com/questions/22043549/matplotlib-and-qt-mouse-press-event-key-is-always-none
        self.canvas.setFocusPolicy( QtCore.Qt.ClickFocus )
        self.canvas.setFocus()

        self.canvas.updateGeometry()

        # Create a custom navigation toolbar, tied to the canvas and
        # initialize toolbar settings
        #
        self.mplToolbar = MplToolbar(self.canvas, self)
        self.mplToolbar.zoom_locked = False
        self.mplToolbar.cursor_enabled = False
        #self.mplToolbar.enable_plot(state = True)
        self.mplToolbar.sig_tx.connect(self.process_signals)
        layHToolbar = QHBoxLayout()
        layHToolbar.addWidget(self.mplToolbar, 1, QtCore.Qt.AlignLeft)
        layHToolbar.addStretch(1)

        #=============================================
        # Main plot widget layout
        #=============================================
        self.layVMainMpl = QVBoxLayout()
        self.layVMainMpl.addLayout(layHToolbar)
        self.layVMainMpl.addWidget(self.canvas)

        self.setLayout(self.layVMainMpl)
예제 #3
0
def stems(x, y, ax=None, label=None, mkr_fmt=None, **kwargs):
    """
    Provide a faster replacement for stem plots under matplotlib < 3.1.0 using
    vlines (= LineCollection). LineCollection keywords are supported.
    """
    # create a copy of the kwargs dict without 'bottom' key-value pair, provide
    # pop bottom from dict (defuault = 0), not compatible with vlines
    bottom = kwargs.pop('bottom', 0)
    ax.axhline(bottom, **kwargs)
    if cmp_version("matplotlib", "3.1.0") >= 0:
        ml, sl, bl = ax.stem(x, y, use_line_collection=True, bottom=bottom)
        setp(ml, **mkr_fmt)
        setp(bl, **kwargs)
        setp(sl, **kwargs)
    else:
        ax.vlines(x, y, bottom, label=label, **kwargs)
        scatter(x, y, ax=ax, label=label, mkr_fmt=mkr_fmt, **kwargs)

    if mkr_fmt['marker']:
        handle = (lines.Line2D([], [],
                               **kwargs), lines.Line2D([], [], **mkr_fmt))
    else:
        handle = lines.Line2D([], [], **kwargs)
    return handle
예제 #4
0
toolbar.
"""
import logging
logger = logging.getLogger(__name__)
import sys
from pyfda.libs.pyfda_lib import cmp_version

# do not import matplotlib.pyplot - pyplot brings its own GUI, event loop etc!!!
from matplotlib.figure import Figure
from matplotlib.transforms import Bbox
from matplotlib import rcParams

try:
    MPL_CURS = True
    import mplcursors
    if cmp_version('matplotlib', '3.1') < 0:
       MPL_CURS = False
except ImportError:
    MPL_CURS = False
    print(MPL_CURS)
try:
    import matplotlib.backends.qt_editor.figureoptions as figureoptions
except ImportError:
    figureoptions = None

from pyfda.libs.compat import (QtCore, QtGui, QWidget, QLabel, pyqtSignal, pyqtSlot,
                      QSizePolicy, QIcon, QImage, QVBoxLayout, QHBoxLayout,
                      QInputDialog, FigureCanvas, NavigationToolbar)

from pyfda import pyfda_rc
import pyfda.filterbroker as fb
예제 #5
0
from pyfda.fixpoint_widgets.fixpoint_helpers import UI_W, UI_Q
from pyfda.pyfda_rc import params

# when deltasigma module is present, add a corresponding entry to the combobox
try:
    import deltasigma
    HAS_DS = True
except ImportError:
    HAS_DS = False

import logging
logger = logging.getLogger(__name__)

# TODO:
# when nmigen is present, instantiate the fixpoint widget
if cmp_version("nmigen", "0.2") >= 0:
    HAS_NMIGEN = True
else:
    HAS_NMIGEN = False

# ------------------------------------------------------------------------------

classes = {'Input_Fixpoint_Specs': 'Fixpoint'}  #: Dict with class name : display name


class Input_Fixpoint_Specs(QWidget):
    """
    Create the widget that holds the dynamically loaded fixpoint filter ui
    """

    # sig_resize = pyqtSignal()  # emit a signal when the image has been resized
예제 #6
0
파일: pyfda_rc.py 프로젝트: xfunture/pyfda
    'axes.titlesize': 14,
    'axes.linewidth': 1,  # linewidth for coordinate system
    'axes.formatter.use_mathtext':
    True,  # use mathtext for scientific notation.
    'grid.linestyle': ':',
    'grid.linewidth': 0.5,
    'xtick.direction': 'out',
    'ytick.direction': 'out',
    #'xtick.top'                 : False, 2.0 only
    'figure.figsize': (5, 4),
    'figure.dpi': 100
}

mpl_2 = {'hatch.color': '#808080', 'hatch.linewidth': 0.5}

if cmp_version('matplotlib', '2.0') >= 0:
    mpl_rc.update(mpl_2)

# dark theme for matplotlib widgets
mpl_rc_dark = {
    'axes.facecolor': 'black',
    'axes.labelcolor': 'white',
    'axes.edgecolor': 'white',
    'figure.facecolor': '#202020',
    'figure.edgecolor':
    '#808080',  # also color for hatched specs for mpl < 2.0
    'savefig.facecolor': 'black',
    'savefig.edgecolor': 'black',
    'xtick.color': 'white',
    'ytick.color': 'white',
    'text.color': 'white',
예제 #7
0
                               QHBoxLayout, pyqtSignal, QFrame, QEvent,
                               QSizePolicy)

import numpy as np

import pyfda.filterbroker as fb  # importing filterbroker initializes all its globals
import pyfda.libs.pyfda_dirs as dirs
from pyfda.libs.pyfda_lib import qstr, cmp_version, pprint_log
import pyfda.libs.pyfda_fix_lib as fx
from pyfda.libs.pyfda_io_lib import extract_file_ext
from pyfda.libs.pyfda_qt_lib import qget_cmb_box, qset_cmb_box, qstyle_widget
from pyfda.fixpoint_widgets.fixpoint_helpers import UI_W, UI_Q
from pyfda.pyfda_rc import params

# when migen is present, instantiate the fixpoint widget
if cmp_version("migen",
               "0.1") >= -1:  # currently, version cannot be determined
    import migen
    HAS_MIGEN = True
else:
    HAS_MIGEN = False

# when deltasigma module is present, add a corresponding entry to the combobox
try:
    import deltasigma
    HAS_DS = True
except ImportError:
    HAS_DS = False
#------------------------------------------------------------------------------

classes = {
    'Input_Fixpoint_Specs': 'Fixpoint'