Best Python code snippet using yandex-tank
xnor_truthtable.py
Source:xnor_truthtable.py
1#!/usr/bin/env python2"""3 Annotation of standard bar chart with genetic constructs4"""5import dnaplotlib as dpl6from pylab import *7import matplotlib.pyplot as plt8__author__ = 'Bryan Der <bder@mit.edu>, Voigt Lab, MIT\n\9 Thomas Gorochowski <tom@chofski.co.uk>, Voigt Lab, MIT'10__license__ = 'MIT'11__version__ = '1.0'12# Function to generate a ligher colour13def lighten_color (col, fac):14 r = col[0] + (fac*(1.0-col[0]))15 g = col[1] + (fac*(1.0-col[1]))16 b = col[2] + (fac*(1.0-col[2]))17 return (r,g,b)18# Plot bar chart19fig = plt.figure(figsize=(3.7,2.32))20ax = plt.axes([0.08, 0.14, 0.21, 0.80])21ax.set_xscale('log')22ax.tick_params(axis='y', labelsize=8)23ax.tick_params(axis='x', labelsize=8)24ax.tick_params(axis='y', which='major', pad=3)25reu_to_rpu = 1.0/4.226val = [2.5, 0.008, 0.012, 2.5]27val = [x*reu_to_rpu for x in val]28pos = arange(4)+.529barlist=ax.barh(pos,val,0.3, align='center', log=True)30barlist[0].set_color('black')31barlist[0].set_facecolor('black')32barlist[1].set_color('black')33barlist[1].set_facecolor('white')34barlist[2].set_color('black')35barlist[2].set_facecolor('white')36barlist[3].set_color('black')37barlist[3].set_facecolor('black')38ax.spines['top'].set_visible(False)39ax.spines['right'].set_visible(False)40ax.yaxis.tick_left()41ax.xaxis.tick_bottom()42ax.set_xlim([0.005/4.2,10/4.2])43ax.set_ylim([-0.1,3.9])44plt.yticks(pos, ('+/+', '-/+', '+/-', '-/-'))45plt.xlabel('Output (RPU)', fontsize=8, labelpad=0)46plt.ylabel('Input', fontsize=8, labelpad=-1)47plt.grid(False)48# Colour map49col_map = {}50col_map['black'] = (0.00, 0.00, 0.00)51col_map['white'] = (1.00, 1.00, 1.00)52col_map['red'] = (0.95, 0.30, 0.25)53col_map['green'] = (0.38, 0.82, 0.32)54col_map['blue'] = (0.38, 0.65, 0.87)55col_map['orange'] = (1.00, 0.75, 0.17)56# Global line width57lw = 1.058# Define the parts59g0_OFF = {'type':'CDS', 'name':'g0_OFF', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['white'], 'edge_color':col_map['black'], 'x_extent':24}} #output60g0_ON = {'type':'CDS', 'name':'g0_ON', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['black'], 'edge_color':col_map['black'], 'x_extent':24, 'label':'Out', 'label_style':'italic', 'label_color':(1,1,1), 'label_x_offset':-3, 'label_y_offset':-1}}61g1_OFF = {'type':'CDS', 'name':'g1_OFF', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['white'], 'edge_color':col_map['red'], 'x_extent':24}}62g1_ON = {'type':'CDS', 'name':'g1_ON', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['red'], 'edge_color':col_map['red'], 'x_extent':24, 'label':'D', 'label_style':'italic', 'label_color':(1,1,1), 'label_x_offset':-3, 'label_y_offset':-1}}63g2_OFF = {'type':'CDS', 'name':'g2_OFF', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['white'], 'edge_color':col_map['blue'], 'x_extent':24}}64g2_ON = {'type':'CDS', 'name':'g2_ON', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['blue'], 'edge_color':col_map['blue'], 'x_extent':24, 'label':'C', 'label_style':'italic', 'label_color':(1,1,1), 'label_x_offset':-3, 'label_y_offset':-1}}65g3_OFF = {'type':'CDS', 'name':'g3_OFF', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['white'], 'edge_color':col_map['green'], 'x_extent':24}}66g3_ON = {'type':'CDS', 'name':'g3_ON', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['green'], 'edge_color':col_map['green'], 'x_extent':24, 'label':'B', 'label_style':'italic', 'label_color':(1,1,1), 'label_x_offset':-3, 'label_y_offset':-1}}67g4_OFF = {'type':'CDS', 'name':'g4_OFF', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['white'], 'edge_color':col_map['orange'], 'x_extent':24}}68g4_ON = {'type':'CDS', 'name':'g4_ON', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['orange'], 'edge_color':col_map['orange'], 'x_extent':24, 'label':'A', 'label_style':'italic', 'label_color':(1,1,1), 'label_x_offset':-3, 'label_y_offset':-1}}69pA = {'type':'Promoter', 'name':'pA', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['black'], 'label':'p1', 'label_y_offset':-8}}70pB = {'type':'Promoter', 'name':'pB', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['black'], 'label':'p2', 'label_y_offset':-8}}71p1 = {'type':'Promoter', 'name':'p3', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['red']}}72p2 = {'type':'Promoter', 'name':'p4', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['blue']}}73p3 = {'type':'Promoter', 'name':'p5', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['green']}}74p4_1 = {'type':'Promoter', 'name':'p6', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['orange']}}75p4_2 = {'type':'Promoter', 'name':'p6', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['orange']}}76# How much to lighten OFF components77off_fac = 0.778print('black', lighten_color(col_map['black'],off_fac))79print('red', lighten_color(col_map['red'],off_fac))80print('green', lighten_color(col_map['green'],off_fac))81print('blue', lighten_color(col_map['blue'],off_fac))82print('orange', lighten_color(col_map['orange'],off_fac))83pA_OFF = {'type':'Promoter', 'name':'pA', 'fwd':True, 'opts':{'linewidth':lw, 'color':lighten_color(col_map['black'],off_fac)}}84pB_OFF = {'type':'Promoter', 'name':'pB', 'fwd':True, 'opts':{'linewidth':lw, 'color':lighten_color(col_map['black'],off_fac)}}85p1_OFF = {'type':'Promoter', 'name':'p3', 'fwd':True, 'opts':{'linewidth':lw, 'color':lighten_color(col_map['red'],off_fac)}}86p2_OFF = {'type':'Promoter', 'name':'p4', 'fwd':True, 'opts':{'linewidth':lw, 'color':lighten_color(col_map['blue'],off_fac)}}87p3_OFF = {'type':'Promoter', 'name':'p5', 'fwd':True, 'opts':{'linewidth':lw, 'color':lighten_color(col_map['green'],off_fac)}}88p4_1_OFF = {'type':'Promoter', 'name':'p6', 'fwd':True, 'opts':{'linewidth':lw, 'color':lighten_color(col_map['orange'],off_fac)}}89p4_2_OFF = {'type':'Promoter', 'name':'p6', 'fwd':True, 'opts':{'linewidth':lw, 'color':lighten_color(col_map['orange'],off_fac)}}90t0 = {'type':'Terminator', 'name':'t0', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['black'], 'start_pad':-1}}91t1 = {'type':'Terminator', 'name':'t1', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['black'], 'start_pad':-1}}92t2 = {'type':'Terminator', 'name':'t2', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['black'], 'start_pad':-1}}93t3 = {'type':'Terminator', 'name':'t3', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['black'], 'start_pad':-1}}94t4 = {'type':'Terminator', 'name':'t4', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['black'], 'start_pad':-1}}95u0 = {'type':'RBS', 'name':'u0', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['black'], 'start_pad':-6, 'x_extent':6}}96u1 = {'type':'RBS', 'name':'u1', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['black'], 'start_pad':-6, 'x_extent':6}}97u2 = {'type':'RBS', 'name':'u2', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['black'], 'start_pad':-6, 'x_extent':6}}98u3 = {'type':'RBS', 'name':'u3', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['black'], 'start_pad':-6, 'x_extent':6}}99u4 = {'type':'RBS', 'name':'u4', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['black'], 'start_pad':-6, 'x_extent':6}}100# Define the regulation101arc1 = {'type':'Repression', 'from_part':g1_ON, 'to_part':p1_OFF, 'opts':{'color':col_map['red'], 'linewidth':lw}}102arc2 = {'type':'Repression', 'from_part':g2_ON, 'to_part':p2_OFF, 'opts':{'color':col_map['blue'], 'linewidth':lw}}103arc3 = {'type':'Repression', 'from_part':g3_ON, 'to_part':p3_OFF, 'opts':{'color':col_map['green'], 'linewidth':lw, 'arc_height':25}}104arc4 = {'type':'Repression', 'from_part':g4_ON, 'to_part':p4_1_OFF, 'opts':{'color':col_map['orange'], 'linewidth':lw, 'arc_height':20}}105arc5 = {'type':'Repression', 'from_part':g4_ON, 'to_part':p4_2_OFF, 'opts':{'color':col_map['orange'], 'linewidth':lw, 'arc_height':20}}106reg1 = [arc2, arc3]107reg2 = [arc1, arc2, arc4, arc5]108reg3 = [arc1, arc3, arc4, arc5]109reg4 = [arc2, arc3, arc4, arc5]110# A design is merely a list of parts and their properties111design1 = [pA_OFF, pB_OFF, u4, g4_OFF, t4, pB_OFF, p4_1, u3, g3_ON, t3, pA_OFF, p4_2, u2, g2_ON, t2, p3_OFF, p2_OFF, u1, g1_OFF, t1, p1, u0, g0_ON, t0]112design2 = [pA, pB_OFF, u4, g4_ON, t4, pB_OFF, p4_1_OFF, u3, g3_OFF, t3, pA, p4_2_OFF, u2, g2_ON, t2, p3, p2_OFF, u1, g1_ON, t1, p1_OFF, u0, g0_OFF, t0]113design3 = [pA_OFF, pB, u4, g4_ON, t4, pB, p4_1_OFF, u3, g3_ON, t3, pA_OFF, p4_2_OFF, u2, g2_OFF, t2, p3_OFF, p2, u1, g1_ON, t1, p1_OFF, u0, g0_OFF, t0]114design4 = [pA, pB, u4, g4_ON, t4, pB, p4_1_OFF, u3, g3_ON, t3, pA, p4_2_OFF, u2, g2_ON, t2, p3_OFF, p2_OFF, u1, g1_OFF, t1, p1, u0, g0_ON, t0]115# Set up the axes for the genetic constructs116ax_dna1 = plt.axes([0.135, 0.75, 1, 0.2])117ax_dna2 = plt.axes([0.135, 0.55, 1, 0.2])118ax_dna3 = plt.axes([0.135, 0.35, 1, 0.2])119ax_dna4 = plt.axes([0.135, 0.15, 1, 0.2])120# Create the DNAplotlib renderer121dr = dpl.DNARenderer()122# Redender the DNA to axis123start, end = dr.renderDNA(ax_dna1, design1, dr.SBOL_part_renderers(), 124 regs=reg1, reg_renderers=dr.std_reg_renderers())125ax_dna1.set_xlim([start, end])126ax_dna1.set_ylim([-27,27])127ax_dna1.set_aspect('equal')128ax_dna1.set_xticks([])129ax_dna1.set_yticks([])130ax_dna1.axis('off')131start, end = dr.renderDNA(ax_dna2, design2, dr.SBOL_part_renderers(),132 regs=reg2, reg_renderers=dr.std_reg_renderers())133ax_dna2.set_xlim([start, end])134ax_dna2.set_ylim([-27,27])135ax_dna2.set_aspect('equal')136ax_dna2.set_xticks([])137ax_dna2.set_yticks([])138ax_dna2.axis('off')139start, end = dr.renderDNA(ax_dna3, design3, dr.SBOL_part_renderers(), 140 regs=reg3, reg_renderers=dr.std_reg_renderers())141ax_dna3.set_xlim([start, end])142ax_dna3.set_ylim([-27,27])143ax_dna3.set_aspect('equal')144ax_dna3.set_xticks([])145ax_dna3.set_yticks([])146ax_dna3.axis('off')147start, end = dr.renderDNA(ax_dna4, design4, dr.SBOL_part_renderers(), 148 regs=reg4, reg_renderers=dr.std_reg_renderers())149ax_dna4.set_xlim([start, end])150ax_dna4.set_ylim([-27,27])151ax_dna4.set_aspect('equal')152ax_dna4.set_xticks([])153ax_dna4.set_yticks([])154ax_dna4.axis('off')155# Save the figure156fig.savefig('xnor_truthtable.pdf', transparent=True)157fig.savefig('xnor_truthtable.png', dpi=300)158# Clear the plotting cache...
scatter_annotate.py
Source:scatter_annotate.py
1#!/usr/bin/env python2"""3 Annotation of standard scatter plot with genetic constructs4"""5import numpy as np6import matplotlib.pyplot as plt7import dnaplotlib as dpl8import csv9__author__ = 'Thomas Gorochowski <tom@chofski.co.uk>, Voigt Lab, MIT'10__license__ = 'MIT'11__version__ = '1.0'12# Read some data points for the scatter plot13filename_in ='data_points.txt'14data_reader = csv.reader(open(filename_in, 'rU'), delimiter=' ')15x = []16y = []17for row in data_reader:18 y.append( float(row[1]) )19 x.append( float(row[2]) )20# Generate the scatter plot21fig = plt.figure(figsize=(2.8,2.32))22ax = plt.subplot(1, 1, 1)23ax.set_yscale('log')24ax.set_xlim([0.85,1.05])25ax.set_ylim([1,500])26ax.set_xticks([0.85, 0.9, 0.95, 1.0, 1.05])27ax.tick_params(axis='y', labelsize=8)28ax.tick_params(axis='x', labelsize=8)29ax.spines['right'].set_visible(False)30ax.spines['top'].set_visible(False)31ax.yaxis.set_ticks_position('left')32ax.xaxis.set_ticks_position('bottom')33plt.xlabel('Parameter 1', fontsize=8, labelpad=0)34plt.ylabel('Parameter 2', fontsize=8, labelpad=0)35ax.tick_params(axis='y', which='major', pad=1)36plt.scatter(x, y, c='none', s=6, edgecolor=(0.5,0.5,0.5), lw = 0.8) #(0.38, 0.65, 0.87)37# Add arrows to the constructs38plt.annotate(39 '', 40 xy = (0.8785, 323.5), xytext = (25, 5),41 textcoords = 'offset points', ha = 'right', va = 'bottom',42 bbox = dict(boxstyle = 'round,pad=0.5', fc = 'yellow', alpha = 0.5),43 arrowprops = dict(arrowstyle = '->', linewidth=1.0, connectionstyle = 'arc3,rad=0'))44plt.annotate(45 '', 46 xy = (0.977, 34), xytext = (20, 14),47 textcoords = 'offset points', ha = 'right', va = 'bottom',48 bbox = dict(boxstyle = 'round,pad=0.5', fc = 'yellow', alpha = 0.5),49 arrowprops = dict(arrowstyle = '->', linewidth=1.0, connectionstyle = 'arc3,rad=0'))50plt.annotate(51 '', 52 xy = (0.982, 3.3), xytext = (22, 10),53 textcoords = 'offset points', ha = 'right', va = 'bottom',54 bbox = dict(boxstyle = 'round,pad=0.5', fc = 'yellow', alpha = 0.5),55 arrowprops = dict(arrowstyle = '->', linewidth=1.0, connectionstyle = 'arc3,rad=0'))56# Color maps (let's make sure we use similar colors)57col_map = {}58col_map['black'] = (0.00, 0.00, 0.00)59col_map['white'] = (1.00, 1.00, 1.00)60col_map['red'] = (0.95, 0.30, 0.25)61col_map['green'] = (0.38, 0.82, 0.32)62col_map['blue'] = (0.38, 0.65, 0.87)63col_map['orange'] = (1.00, 0.75, 0.17)64col_map['purple'] = (0.55, 0.35, 0.64)65col_map['yellow'] = (0.98, 0.97, 0.35)66# Global line width67lw = 1.068# Define design 169p1_1 = {'type':'Promoter', 'name':'pA', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['black']}}70rbs_1_1 = {'type':'RBS', 'name':'rbs_f', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['black'], 'start_pad':-6, 'x_extent':6}}71gA_1 = {'type':'CDS', 'name':'gA', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['red'], 'edgecolor':col_map['red'], 'x_extent':24, 'label':'A', 'label_style':'italic', 'label_color':(1,1,1), 'label_x_offset':-3, 'label_y_offset':-1}}72rbs_1_2 = {'type':'RBS', 'name':'rbs_r', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['black'], 'start_pad':2, 'x_extent':6}}73gB_1 = {'type':'CDS', 'name':'gB', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['blue'], 'edgecolor':col_map['blue'], 'x_extent':24, 'label':'B', 'label_style':'italic', 'label_color':(1,1,1), 'label_x_offset':-3, 'label_y_offset':-1}}74t1_1 = {'type':'Terminator', 'name':'t0', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['black'], 'start_pad':-1}}75design1 = [p1_1, rbs_1_1, gA_1, rbs_1_2, gB_1, t1_1]76# Define design 277t1_2 = {'type':'Terminator', 'name':'t0', 'fwd':False, 'opts':{'linewidth':lw, 'color':col_map['black'], 'start_pad':-1}}78gA_2 = {'type':'CDS', 'name':'gA', 'fwd':False, 'opts':{'linewidth':lw, 'color':col_map['red'], 'edgecolor':col_map['red'], 'x_extent':24, 'label':'A', 'label_style':'italic', 'label_color':(1,1,1), 'label_x_offset':2, 'label_y_offset':-1}}79rbs_1_2 = {'type':'RBS', 'name':'rbs_f', 'fwd':False, 'opts':{'linewidth':lw, 'color':col_map['black'], 'start_pad':-6, 'x_extent':6}}80p1_2 = {'type':'Promoter', 'name':'pA', 'fwd':False, 'opts':{'linewidth':lw, 'color':col_map['black']}}81p2_2 = {'type':'Promoter', 'name':'pA', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['black']}}82rbs_2_2 = {'type':'RBS', 'name':'rbs_r', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['black'], 'start_pad':-6, 'x_extent':6}}83gB_2 = {'type':'CDS', 'name':'gB', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['blue'], 'edgecolor':col_map['blue'], 'x_extent':24, 'label':'B', 'label_style':'italic', 'label_color':(1,1,1), 'label_x_offset':-3, 'label_y_offset':-1}}84t2_2 = {'type':'Terminator', 'name':'t0', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['black'], 'start_pad':-1}}85design2 = [t1_2, gA_2, rbs_1_2, p1_2, p2_2, rbs_2_2, gB_2, t2_2]86# Define design 387p1_3 = {'type':'Promoter', 'name':'pA', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['black']}}88rbs_1_3 = {'type':'RBS', 'name':'rbs_r', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['black'], 'start_pad':-6, 'x_extent':6}}89gA_3 = {'type':'CDS', 'name':'gB', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['red'], 'edgecolor':col_map['red'], 'x_extent':24, 'label':'A', 'label_style':'italic', 'label_color':(1,1,1), 'label_x_offset':-3, 'label_y_offset':-1}}90t1_3 = {'type':'Terminator', 'name':'t0', 'fwd':True, 'opts':{'linewidth':lw, 'color':col_map['black'], 'start_pad':-1}}91t2_3 = {'type':'Terminator', 'name':'t0', 'fwd':False, 'opts':{'linewidth':lw, 'color':col_map['black'], 'start_pad':-1}}92gB_3 = {'type':'CDS', 'name':'gA', 'fwd':False, 'opts':{'linewidth':lw, 'color':col_map['blue'], 'edgecolor':col_map['blue'], 'x_extent':24, 'label':'B', 'label_style':'italic', 'label_color':(1,1,1), 'label_x_offset':0, 'label_y_offset':-1}}93rbs_2_3 = {'type':'RBS', 'name':'rbs_f', 'fwd':False, 'opts':{'linewidth':lw, 'color':col_map['black'], 'start_pad':-6, 'x_extent':6}}94p2_3 = {'type':'Promoter', 'name':'pA', 'fwd':False, 'opts':{'linewidth':lw, 'color':col_map['black']}}95design3 = [p1_3, rbs_1_3, gA_3, t1_3, t2_3, gB_3, rbs_2_3, p2_3]96# Set up the axes for the genetic constructs97ax_dna1 = plt.axes([0.35, 0.83, 0.35, 0.12])98ax_dna2 = plt.axes([0.61, 0.65, 0.4, 0.12])99ax_dna3 = plt.axes([0.58, 0.32, 0.4, 0.12])100# Create the DNAplotlib renderer101dr = dpl.DNARenderer()102# Redender the DNA to axis103start, end = dr.renderDNA(ax_dna1, design1, dr.SBOL_part_renderers())104ax_dna1.set_xlim([start, end])105ax_dna1.set_ylim([-15,15])106ax_dna1.set_aspect('equal')107ax_dna1.set_xticks([])108ax_dna1.set_yticks([])109ax_dna1.axis('off')110start, end = dr.renderDNA(ax_dna2, design2, dr.SBOL_part_renderers())111ax_dna2.set_xlim([start, end])112ax_dna2.set_ylim([-15,15])113ax_dna2.set_aspect('equal')114ax_dna2.set_xticks([])115ax_dna2.set_yticks([])116ax_dna2.axis('off')117start, end = dr.renderDNA(ax_dna3, design3, dr.SBOL_part_renderers())118ax_dna3.set_xlim([start, end])119ax_dna3.set_ylim([-15,15])120ax_dna3.set_aspect('equal')121ax_dna3.set_xticks([])122ax_dna3.set_yticks([])123ax_dna3.axis('off')124# Sort out subplot spacing125plt.subplots_adjust(hspace=0.01, left=0.13, right=0.95, top=0.93, bottom=0.13)126# Save the figure127fig.savefig('scatter_annotate.pdf', transparent=True)128fig.savefig('scatter_annotate.png', dpi=300)129# Clear the plotting cache...
ColTab.py
Source:ColTab.py
1import numpy as np2import matplotlib as mpl3def ColTabbw():4 5 cdict = {'red': ((0.0, 0.0, 0.0), 6 (1.0, 1.0, 1.0)),7 'green': ((0.0, 0.0, 0.0),8 (1.0, 1.0, 1.0)),9 'blue': ((0.0, 0.0, 0.0),10 (1.0, 1.0, 1.0)) 11 } 12 13 col_map=mpl.colors.LinearSegmentedColormap('bw',cdict)14 15 return col_map16def ColTabBinary(col0,col1):17 18 cdict = {'red': ((0.0, col0[0], col0[0]), 19 (0.5, col0[0], col1[0]),20 (1.0, col1[0], col1[0])),21 'green': ((0.0, col0[1], col0[1]), 22 (0.5, col0[1], col1[1]),23 (1.0, col1[1], col1[1])),24 'blue': ((0.0, col0[2], col0[2]), 25 (0.5, col0[2], col1[2]),26 (1.0, col1[2], col1[2])), 27 28 'alpha': ((0.0, col0[3], col0[3]), 29 (0.5, col0[3], col1[3]),30 (1.0, col1[3], col1[3]))31 } 32 33 col_map=mpl.colors.LinearSegmentedColormap('binary',cdict)34 35 return col_map36def ColTabwb():37 38 cdict = {'red': ((0.0, 1.0, 1.0), 39 (1.0, 0.0, 0.0)),40 'green': ((0.0, 1.0, 1.0),41 (1.0, 0.0, 0.0)),42 'blue': ((0.0, 1.0, 1.0),43 (1.0, 0.0, 0.0)) 44 } 45 46 col_map=mpl.colors.LinearSegmentedColormap('wb',cdict)47 48 return col_map49def ColTabbcyr():50 51 cdict = {'red': ((0.0, 0.0, 0.0), 52 (0.5, 0.0, 1.0), 53 (1.0, 1.0, 1.0)),54 'green': ((0.0, 0.0, 0.0),55 (0.5, 1.0, 1.0),56 (1.0, 0.0, 0.0)),57 'blue': ((0.0, 0.0, 1.0),58 (0.5, 1.0, 0.0), 59 (1.0, 0.0, 0.0)) 60 } 61 62 col_map=mpl.colors.LinearSegmentedColormap('bcyr',cdict)63 64 return col_map65def ColTabbr():66 67 cdict = {'red': ((0.0, 0.0, 0.0), 68 (1.0, 1.0, 1.0)),69 'green': ((0.0, 0.0, 0.0),70 (1.0, 0.0, 0.0)),71 'blue': ((0.0, 1.0, 1.0),72 (1.0, 0.0, 0.0)) 73 } 74 75 col_map=mpl.colors.LinearSegmentedColormap('br',cdict)76 77 return col_map78def ColTabyr():79 80 cdict = {'red': ((0.0, 1.0, 1.0), 81 (1.0, 1.0, 1.0)),82 'green': ((0.0, 1.0, 1.0),83 (1.0, 0.0, 0.0)),84 'blue': ((0.0, 0.0, 0.0),85 (1.0, 0.0, 0.0)) 86 } 87 88 col_map=mpl.colors.LinearSegmentedColormap('yr',cdict)89 90 return col_map91def ColTabor():92 93 cdict = {'red': ((0.0, 1.0, 1.0), 94 (1.0, 1.0, 1.0)),95 'green': ((0.0, 0.5, 0.5),96 (1.0, 0.0, 0.0)),97 'blue': ((0.0, 0.0, 0.0),98 (1.0, 0.0, 0.0)) 99 } 100 101 col_map=mpl.colors.LinearSegmentedColormap('or',cdict)102 103 return col_map104def ColTabwyr():105 106 cdict = {'red': ((0.0, 1.0, 1.0), 107 (0.5, 1.0, 1.0), 108 (1.0, 1.0, 1.0)),109 'green': ((0.0, 1.0, 1.0),110 (0.5, 1.0, 1.0),111 (1.0, 0.0, 0.0)),112 'blue': ((0.0, 1.0, 1.0),113 (0.5, 0.0, 0.0), 114 (1.0, 0.0, 0.0)) 115 } 116 117 col_map=mpl.colors.LinearSegmentedColormap('wyr',cdict)118 119 return col_map120def ColTab6Step():121 122 cdict = {'red': ((0.0, 0.5, 0.5), 123 (0.167, 0.5, 0.0), 124 (0.333, 0.0, 0.0), 125 (0.5, 0.0, 0.0), 126 (0.667, 0.0, 1.0),127 (0.833, 1.0, 1.0), 128 (1.0, 1.0, 1.0)),129 'green': ((0.0, 0.0, 0.0),130 (0.167, 0.0, 0.0), 131 (0.333, 0.0, 0.5), 132 (0.5, 0.5, 1.0), 133 (0.667, 1.0, 1.0),134 (0.833, 1.0, 0.0), 135 (1.0, 0.0, 0.0)),136 'blue': ((0.0, 1.0, 1.0),137 (0.167, 1.0, 1.0), 138 (0.333, 1.0, 1.0), 139 (0.5, 1.0, 0.0), 140 (0.667, 0.0, 0.0),141 (0.833, 0.0, 0.0), 142 (1.0, 0.0, 0.0)) 143 } 144 145 col_map=mpl.colors.LinearSegmentedColormap('6step',cdict)146 147 return col_map148 149def ColTabCircular():150 cdict = {'red': ((0.0, 1.0, 1.0), 151 (0.25,1.0, 1.0),152 (0.5, 1.0, 1.0),153 (0.75,1.0, 1.0), 154 (1.0, 1.0, 1.0)),155 'green': ((0.0, 0.0, 0.0),156 (0.25,0.0, 0.0),157 (0.5, 1.0, 1.0),158 (0.75,1.0, 1.0), 159 (1.0, 0.0, 0.0)),160 'blue': ((0.0, 0.0, 0.0),161 (0.25,1.0, 1.0),162 (0.5, 1.0, 1.0),163 (0.75,0.0, 0.0), 164 (1.0, 0.0, 0.0)),165 } 166 167 col_map=mpl.colors.LinearSegmentedColormap('Circular',cdict)168 169 return col_map170def ColTabNonLin():171 cdict = {'red': (( 0.0, 1.0, 1.0), #white 1.0 1.0 1.0172 ( 0.01, 0.0, 0.0), #blue 0.0 0.0 1.0173 (0.025, 0.7, 0.7), #purple 0.7 0.0 0.7174 (0.063, 0.0, 0.0), #green 0.0 1.0 0.0175 (0.158, 1.0, 1.0), #yellow 1.0 1.0 0.0176 (0.398, 1.0, 1.0), #red 1.0 0.0 0.0177 ( 1.0, 0.0, 0.0)), #black 0.0 0.0 0.0178 'green': (( 0.0, 1.0, 1.0),179 ( 0.01, 0.0, 0.0),180 (0.025, 0.0, 0.0),181 (0.063, 1.0, 1.0), 182 (0.158, 1.0, 1.0),183 (0.398, 0.0, 0.0),184 ( 1.0, 0.0, 0.0)),185 'blue': (( 0.0, 1.0, 1.0),186 ( 0.01, 1.0, 1.0),187 (0.025, 0.7, 0.7),188 (0.063, 0.0, 0.0), 189 (0.158, 0.0, 0.0),190 (0.398, 0.0, 0.0),191 ( 1.0, 0.0, 0.0)),192 } 193 194 col_map=mpl.colors.LinearSegmentedColormap('NonLin',cdict)195 196 return col_map197def ColTabNonLin2():198 cdict = {'red': (( 0.0, 1.0, 1.0), #white 1.0 1.0 1.0199 (0.025, 0.5, 0.5), #purple 0.7 0.0 0.7200 (0.063, 1.0, 1.0), #pink 1.0 0.5 0.5201 (0.158, 1.0, 1.0), #yellow 1.0 1.0 0.0202 (0.398, 1.0, 1.0), #red 1.0 0.0 0.0203 ( 1.0, 0.0, 0.0)),#black 0.0 0.0 0.0204 'green': (( 0.0, 1.0, 1.0),205 (0.025, 0.0, 0.0),206 (0.063, 0.5, 0.5), 207 (0.158, 1.0, 1.0),208 (0.398, 0.0, 0.0),209 ( 1.0, 0.0, 0.0)),210 'blue': (( 0.0, 1.0, 1.0),211 (0.025, 0.5, 0.5),212 (0.063, 0.5, 0.5), 213 (0.158, 0.0, 0.0),214 (0.398, 0.0, 0.0),215 ( 1.0, 0.0, 0.0)),216 } 217 218 col_map=mpl.colors.LinearSegmentedColormap('NonLin2',cdict)219 ...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!