本文整理汇总了Python中matplotlib.style.use函数的典型用法代码示例。如果您正苦于以下问题:Python use函数的具体用法?Python use怎么用?Python use使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了use函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plot_dists
def plot_dists(outpath, dists, controlsamples):
from matplotlib import style
style.use('ggplot')
samplecolors = colormap_lch(len(controlsamples))
samplessorted = sorted(controlsamples, key=lambda x: (x[1], x[0]))
xticks = np.arange(0, dists.index[-1] + 0.1)
xticks_disp = [format(v, 'g') for v in xtransform_rev(xticks)]
fig, ax = plt.subplots(1, 1, figsize=(4, 3.2))
ax.patch.set_facecolor('#f7f7f7')
for (samplename, explength), color in zip(samplessorted, samplecolors):
ax.plot(dists[samplename], color=color, label=samplename, zorder=3)
ax.axvline(xtransform(explength), color=color, linewidth=2, alpha=0.3)
leg = ax.legend(loc='center left', fontsize=10)
plt.setp([leg.get_frame()], facecolor='white', edgecolor='#e8e8e8')
ax.set_xlabel('Poly(A) length (nt)')
ax.set_ylabel('Cumulative fraction')
ax.set_title('Poly(A) length distribution', fontsize=12)
ax.set_xticks(xticks)
ax.set_xticklabels(xticks_disp)
plt.setp(ax.get_xgridlines() + ax.get_ygridlines(), color='#e0e0e0')
plt.tight_layout()
plt.savefig(outpath)
plt.close(fig)
示例2: __init__
def __init__(self, csv_file, image_path=None):
# TODO Re-enable plotfile
plt.subplots_adjust(left=0.13, bottom=0.33, right=0.95, top=0.89)
style.use('seaborn-darkgrid')
for label in self.ax1.xaxis.get_ticklabels():
label.set_rotation(45)
self.image_path = image_path
self.creader = self.generate_reader(csv_file)
self.points_generator = self.yield_points()
self.x = []
self.y = []
for a, b in self.points_generator:
self.x.append(a)
self.y.append(b)
self.ax1.plot_date(self.x, self.y, 'r-')
plt.xlabel('Timestamps')
plt.ylabel('Return Time (in milliseconds)')
plt.title('Ping Over Time')
示例3: __init__
def __init__(self, parent=None):
super(OptionViewerPlotDlg, self).__init__(parent)
self.setWindowTitle('Plot')
self.resize(600,450)
# a figure instance to plot on
self.figure = plt.figure()
# this is the Canvas Widget that displays the 'figure'
# it takes the 'figure' instance as a parameter to __init__
self.canvas = FigureCanvas(self.figure)
# this is the Navigation widget
# it takes the Canvas widget and a parent
self.toolbar = NavigationToolbar(self.canvas, self)
# Just some button connected to 'plot' method
self.button = QtGui.QPushButton('Plot')
self.button.clicked.connect(self.plot)
# set the layout
layout = QtGui.QVBoxLayout()
layout.addWidget(self.toolbar)
layout.addWidget(self.canvas)
layout.addWidget(self.button)
self.setLayout(layout)
style.use('ggplot')
rcParams['font.size'] = 12
# create an axis
self.ax = self.figure.add_subplot(111)
self.xdata = []
self.ydata = []
示例4: plot_wue_ppt
def plot_wue_ppt(df):
plt.rcParams['lines.linewidth'] = 1.25
plt.rcParams.update({'mathtext.default': 'regular'})
style.use('ggplot')
ncols = plt.rcParams['axes.color_cycle']
fig, ax1 = plt.subplots()
ax2 = ax1.twinx()
ax1.plot(df['Rainfall'], df["WUE"], 'o', c=ncols[0], alpha=0.7)
ax2.plot(df['Rainfall'], df["dWUE_dt"], 'o', c=ncols[1], lw=3)
ax1.set_xlabel(r'Rainfall (mm)')
ax1.set_ylabel(r'WUE (mol H$_{2}$O mol$^{-1}$ CO$_{2}$)')
ax2.set_ylabel(r'$\partial$WUE/$\partial$t (mol H$_{2}$O mol$^{-1}$ CO$_{2}$)')
ax1.set_ylim([0, 3.2])
ax2.set_ylim([-1, 1])
ax2.grid(False)
plt.show()
return 1
示例5: plot_wue_time
def plot_wue_time(df):
plt.rcParams['lines.linewidth'] = 1.25
plt.rcParams.update({'mathtext.default': 'regular'})
style.use('ggplot')
ncols = plt.rcParams['axes.color_cycle']
fig, ax1 = plt.subplots()
ax2 = ax1.twinx()
ax1.bar(df.index, df["WUE"], color=ncols[0], width=300, \
edgecolor=ncols[0], alpha=0.7)
ax1.xaxis_date()
ax2.plot_date(df.index, df["dWUE_dt"], '-', c=ncols[1], lw=3)
ax1.set_ylabel(r'WUE (mol H$_{2}$O mol$^{-1}$ CO$_{2}$)')
ax2.set_ylabel(r'$\partial$WUE/$\partial$t (mol H$_{2}$O mol$^{-1}$ CO$_{2}$)')
ax1.set_ylim([0, 3.2])
ax2.set_ylim([-1, 1])
ax2.grid(False)
plt.show()
return 1
示例6: __init__
def __init__(self,PLOTSEC=600,outfname='stripchartTemp',PDio=4):
self.PLOTSEC = PLOTSEC #PLOTSEC #720 # 12 minute sessions for x axis
self.QUITS = ("q","Q")
self.STARTIN = ('I','i')
self.ENDIN = ('E','e')
self.PDio = PDio
# Uncomment one of the blocks of code below to configure your Pi or BBB to use
# software or hardware SPI.
# Raspberry Pi software SPI configuration.
#CLK = 25
#CS = 24
#DO = 18
#sensor = MAX31855.MAX31855(CLK, CS, DO)
# Raspberry Pi hardware SPI configuration.
self.SPI_PORT = 0
self.SPI_DEVICE = 0
self.sensor = MAX31855.MAX31855(spi=SPI.SpiDev(self.SPI_PORT, self.SPI_DEVICE))
# BeagleBone Black software SPI configuration.
#CLK = 'P9_12'
#CS = 'P9_15'
#DO = 'P9_23'
#sensor = MAX31855.MAX31855(CLK, CS, DO)
# BeagleBone Black hardware SPI configuration.
#SPI_PORT = 1
#SPI_DEVICE = 0
#sensor = MAX31855.MAX31855(spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE))
self.blinkYlevel = 20 # where blink off will appear
self.blinkYactive = 25
self.blinkThresh = 2500
# this works for me and my blu-tac. Your mileage may vary. Try raising it and seeing where
# the hi and low readings tend to cluster - then choose a sensible threshold to reliably distinguish
# them
self.maxPhotoDetReads = self.blinkThresh + 1 # about 0.06 sec sampling truncating at 5k cycles
# self.maxPhotoDetReads = 100000 # about 0.23 sec sampling at 30k cycles
self.ts = self.getTempStream()
self.bs = self.photoDet()
self.outf = open('%s.xls' % outfname,'w')
self.savepng = '%s.png' % outfname
self.outf.write('Second\tTemperature\n')
# set up a generator for PLOTSEC seconds of sampling
style.use('ggplot')
# prepopulate arrays to make updates quicker
self.t = range(self.PLOTSEC+2)
self.y = [None for i in self.t]
self.blinky = [None for i in self.t]
self.blinkx = [None for i in self.t]
self.fig, self.ax = plt.subplots()
#self.ax.set_xlim(auto=True)
#self.ax.set_ylim(auto=True)
# fig.canvas.mpl_connect('key_press_event', press)
self.line, = self.ax.plot(0,0,lw=1)
self.blinkLine, = self.ax.plot(0,0,lw=1)
self.text_template = 'Last temperature = %3.2f'
self.title_template = 'Temperature strip chart at %d seconds'
self.t_temp = self.ax.text(0.15,0.15,self.text_template%(0),
transform=self.ax.transAxes, family='monospace',fontsize=10)
#self.t_title = self.ax.text(0.5,1.0,self.title_template%(0),
# transform=self.ax.transAxes, family='monospace',fontsize=20)
self.started = time.time()
示例7: plot_trajectories
def plot_trajectories(self):
# """uses matplotlib to plot the trajectory
# of each individual stock stored in earlier
# trajectory array"""
print("Creating Plot...")
#use numpy to plot
self.np_price_trajectories = np.array(self.price_trajectories, dtype=float)
self.times = np.linspace(0, self.T, self.N-1)
#style/plot/barrier line
style.use('dark_background')
self.fig = plt.figure()
self.ax1 = plt.subplot2grid((1,1),(0,0))
for sublist in self.np_price_trajectories:
if max(sublist) > self.B:
self.ax1.plot(self.times,sublist,color = 'cyan')
else:
self.ax1.plot(self.times,sublist,color = '#e2fb86')
plt.axhline(y=8,xmin=0,xmax=self.T,linewidth=2, color = 'red', label = 'Barrier')
#rotate and add grid
for label in self.ax1.xaxis.get_ticklabels():
label.set_rotation(45)
self.ax1.grid(True)
#plotting stuff
plt.xticks(np.arange(0, self.T+self.delta_t, .1))
plt.suptitle('Stock Price Trajectory', fontsize=40)
plt.legend()
self.leg = plt.legend(loc= 2)
self.leg.get_frame().set_alpha(0.4)
plt.xlabel('Time (in years)', fontsize = 30)
plt.ylabel('Price', fontsize= 30)
plt.show()
示例8: test_imshow_pil
def test_imshow_pil(fig_test, fig_ref):
style.use("default")
PIL = pytest.importorskip("PIL")
png_path = Path(__file__).parent / "baseline_images/pngsuite/basn3p04.png"
tiff_path = Path(__file__).parent / "baseline_images/test_image/uint16.tif"
axs = fig_test.subplots(2)
axs[0].imshow(PIL.Image.open(png_path))
axs[1].imshow(PIL.Image.open(tiff_path))
axs = fig_ref.subplots(2)
axs[0].imshow(plt.imread(str(png_path)))
axs[1].imshow(plt.imread(tiff_path))
示例9: __init__
def __init__(self, args):
#: input argument Namespace
self.args = args
#: verbosity
self.verbose = 0 if args.silent else args.verbose
# NB: finalizing may want to log if we're being verbose
self._finalize_arguments(args) # post-process args
if args.style: # apply custom styling
try:
from matplotlib import style
except ImportError:
from matplotlib import __version__ as mpl_version
warnings.warn('--style can only be used with matplotlib >= '
'1.4.0, you have {0}'.format(mpl_version))
else:
style.use(args.style)
#: the current figure object
self.plot = None
#: figure number
self.plot_num = 0
#: start times for data sets
self.start_list = unique(
map(int, (gps for gpsl in args.start for gps in gpsl)))
#: duration of each time segment
self.duration = args.duration
#: channels to load
self.chan_list = unique(c for clist in args.chan for c in clist)
# total number of datasets that _should_ be acquired
self.n_datasets = len(self.chan_list) * len(self.start_list)
#: list of input data series (populated by get_data())
self.timeseries = []
#: dots-per-inch for figure
self.dpi = args.dpi
#: width and height in pixels
self.width, self.height = map(float, self.args.geometry.split('x', 1))
#: figure size in inches
self.figsize = (self.width / self.dpi, self.height / self.dpi)
#: Flag for data validation (like all zeroes)
self.got_error = False
# please leave this last
self._validate_arguments()
示例10: graphWords
def graphWords(wordLst, comments):
"""
Assumes WORDLIST is a list of words to graph and
comments is a numpy array containing all the comments
in the reddit post.
"""
style.use('dark_background')
for word in wordLst:
counts = np.char.count(comments, word)
plt.plot(np.cumsum(counts), label=word)
plt.legend(loc=2)
plt.show()
示例11: use_style
def use_style(style=pb_style):
"""Shortcut for `matplotlib.style.use()`
Parameters
----------
style : dict
The default value is the preferred pybinding figure style.
"""
mpl_style.use(style)
# the style shouldn't override inline backend settings
if _is_notebook_inline_backend():
_reset_notebook_inline_backend()
示例12: main
def main():
style.use("ggplot")
data = pd.io.stata.read_stata(DTA_FILE)
plt.figure(1)
draw_1(plt, data)
draw_2(plt)
draw_3(plt, data)
draw_4(plt)
plt.tight_layout()
plt.show()
示例13: __init__
def __init__(self, frame, loss, losskeys):
self.frame = frame
self.loss = loss
self.losskeys = losskeys
self.ylim = (100, 0)
style.use('ggplot')
self.fig = plt.figure(figsize=(4, 4), dpi=75)
self.ax1 = self.fig.add_subplot(1, 1, 1)
self.losslines = list()
self.trndlines = list()
示例14: plotWell
def plotWell(time_series, edges, channels, calls, outputFig, outputFile):
'''plotting routine'''
MAX_CHANS = 6
FIG_COLS = 2
FIG_ROWS = 3
# INCHES_PER_SUBPLOT = 10
CORRECT_CAL = [0.0, 0.8, 0.4]
NO_CAL = [0.0, 0.4, 0.8]
MISS_CAL = [0.7, 0.0, 0.7]
CHANNEL_TAG = 'CH_'
COLORS = [[0, 0.4, 0.8],
[0, 0.8, 0.4],
[0.7, 1.0, 0.1],
[1.0, 0.7, 0.2],
[1.0, 0.2, 0.3],
[0.7, 0, 0.9]]
# fig1 = plt.figure(figsize=(FIG_ROWS*INCHES_PER_SUBPLOT, FIG_COLS*INCHES_PER_SUBPLOT))
style.use('ggplot')
outputFig.clf()
for i in range(len(channels)):
ax = outputFig.add_subplot(FIG_ROWS, FIG_COLS, i + 1)
marker_shape = '.'
#if it is a correct call
if calls[i] == CORRECT_CAL:
marker_shape = 'o'
#if it is a no call
elif calls[i] == NO_CAL:
marker_shape = '^'
#if it is a miss call
if calls[i] == MISS_CAL:
marker_shape = 's'
if edges[i] != -1:
ax.plot(time_series[i], color = calls[i], linewidth = 2.0)
ax.plot(edges[i], time_series[i][edges[i]], marker = marker_shape, linewidth = 3.0, color = calls[i])
ax.set_title(CHANNEL_TAG + str(channels[i] + 1), fontsize = 10.0)
ax.set_xlabel('cycles', color = [0.4, 0.4, 0.4], fontsize = 12.0)
ax.set_ylabel('intensity', color = COLORS[channels[i]], fontsize = 12.0)
for tl in ax.get_yticklabels():
tl.set_color(COLORS[channels[i]])
for tl in ax.get_xticklabels():
tl.set_color(COLORS[channels[i]])
outputFig.savefig(outputFile, format = 'png', dpi = 150)
outputFig.clf()
plt.cla()
示例15: __init__
def __init__(self,PLOTSEC=600,outfname='stripchartTemp'):
self.PLOTSEC = 10 #PLOTSEC #720 # 12 minute sessions for x axis
self.QUITS = ("q","Q")
self.STARTIN = ('I','i')
self.ENDIN = ('E','e')
# Uncomment one of the blocks of code below to configure your Pi or BBB to use
# software or hardware SPI.
# Raspberry Pi software SPI configuration.
#CLK = 25
#CS = 24
#DO = 18
#sensor = MAX31855.MAX31855(CLK, CS, DO)
# Raspberry Pi hardware SPI configuration.
self.SPI_PORT = 0
self.SPI_DEVICE = 0
self.sensor = MAX31855.MAX31855(spi=SPI.SpiDev(self.SPI_PORT, self.SPI_DEVICE))
# BeagleBone Black software SPI configuration.
#CLK = 'P9_12'
#CS = 'P9_15'
#DO = 'P9_23'
#sensor = MAX31855.MAX31855(CLK, CS, DO)
# BeagleBone Black hardware SPI configuration.
#SPI_PORT = 1
#SPI_DEVICE = 0
#sensor = MAX31855.MAX31855(spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE))
self.ts = self.getTempStream()
self.outf = open('%s.xls' % outfname,'w')
self.savepng = '%s.png' % outfname
self.outf.write('Second\tTemperature\n')
# set up a generator for PLOTSEC seconds of sampling
style.use('ggplot')
# prepopulate arrays to make updates quicker
self.t = range(self.PLOTSEC+2)
self.y = [None for i in self.t]
self.fig, self.ax = plt.subplots()
#self.ax.set_xlim(auto=True)
#self.ax.set_ylim(auto=True)
# fig.canvas.mpl_connect('key_press_event', press)
self.line, = self.ax.plot(0,0,lw=1)
self.text_template = 'Last temperature = %3.2f'
self.title_template = 'Temperature strip chart at %d seconds'
self.t_temp = self.ax.text(0.15,0.15,self.text_template%(0),
transform=self.ax.transAxes, family='monospace',fontsize=10)
#self.t_title = self.ax.text(0.5,1.0,self.title_template%(0),
# transform=self.ax.transAxes, family='monospace',fontsize=20)
self.started = time.time()