本文整理汇总了Python中GeneralUtil.python.PlotUtilities.color_axis_ticks方法的典型用法代码示例。如果您正苦于以下问题:Python PlotUtilities.color_axis_ticks方法的具体用法?Python PlotUtilities.color_axis_ticks怎么用?Python PlotUtilities.color_axis_ticks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeneralUtil.python.PlotUtilities
的用法示例。
在下文中一共展示了PlotUtilities.color_axis_ticks方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plot_landscape
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import color_axis_ticks [as 别名]
def plot_landscape(data,xlim,kw_landscape=dict(),plot_derivative=True,
zero_q=True,
label_deltaG = PlotUtilities.variable_string("\Delta G")):
landscape_kcal_per_mol = data.mean_landscape_kcal_per_mol
landscape_kcal_per_mol -= min(landscape_kcal_per_mol)
std_landscape_kcal_per_mol = data.std_landscape_kcal_per_mol
extension_nm = data._extension_grid_nm
if (zero_q):
extension_nm -= min(extension_nm)
extension_aa = data.amino_acids_per_nm() * extension_nm
grad = lambda x: np.gradient(x)/(np.gradient(extension_aa))
delta_landscape_kcal_per_mol_per_amino_acid = grad(landscape_kcal_per_mol)
landscape_upper = landscape_kcal_per_mol+std_landscape_kcal_per_mol
landscape_lower =landscape_kcal_per_mol-std_landscape_kcal_per_mol
delta_landscape_kcal_per_mol_per_amino_acid = \
data.mean_delta_landscape_kcal_per_mol_per_AA
std_delta_landscape_kcal_per_mol_per_AA = \
data.std_delta_landscape_kcal_per_mol_per_AA
upper_delta_landscape = delta_landscape_kcal_per_mol_per_amino_acid+\
std_delta_landscape_kcal_per_mol_per_AA
lower_delta_landscape = delta_landscape_kcal_per_mol_per_amino_acid-\
std_delta_landscape_kcal_per_mol_per_AA
# make a second axis for the number of ammino acids
limits_delta = [min(delta_landscape_kcal_per_mol_per_amino_acid),
max(delta_landscape_kcal_per_mol_per_amino_acid)]
limits_energy = [min(landscape_kcal_per_mol),max(landscape_kcal_per_mol)]
units_energy_delta = label_deltaG + \
r" per AA (kcal/(mol $\cdot$ AA))"
units_energy = PlotUtilities.unit_string("\Delta G","kcal/mol")
difference_color = 'rebeccapurple'
landscape_color = kw_landscape['color']
if (plot_derivative):
PlotUtilities.lazyLabel("Extension (nm)",units_energy_delta,"")
PlotUtilities.ylabel(units_energy_delta,color=difference_color)
else:
PlotUtilities.lazyLabel("Extension (nm)","","")
PlotUtilities.ylabel(units_energy,color=landscape_color)
# the derivative goes on the main axis in this case...
if (plot_derivative):
ax_delta = plt.gca()
ax_2 = PlotUtilities.secondAxis(ax_delta,
label=units_energy,color=landscape_color,
limits=limits_energy,secondY =True,
tick_color=landscape_color)
ax_energy = ax_2
to_ret = ax_delta,ax_energy
else:
ax_energy = plt.gca()
ax_delta = None
to_ret = ax_energy
# filter the data if we need to
if (xlim is not None and xlim[1] is not None):
idx= np.where( (extension_nm > xlim[0]) & (extension_nm < xlim[1]))
else:
idx =np.arange(extension_nm.size)
# plot the landscape and its standard deviation
ax_energy.plot(extension_nm[idx],landscape_kcal_per_mol[idx],
label=label_deltaG,zorder=10,**kw_landscape)
ax_energy.fill_between(x=extension_nm[idx],
y1=landscape_lower[idx],
y2=landscape_upper[idx],
alpha=0.15,zorder=10,**kw_landscape)
# the energy y label should be rotated if it is on the right
rotation = -90
if plot_derivative:
kw_y = dict(rotation=-90,x=-0.3)
else:
kw_y = dict()
PlotUtilities.ylabel(ax=ax_energy,lab=units_energy,**kw_y)
# move the y label to the right slightly i we are using both axes
if plot_derivative:
ax_energy.yaxis.set_label_coords(1.2,0.5)
if (plot_derivative):
# plot the energy delta and its bounds, based on the bounds on the
# landscape
ax_delta.plot(extension_nm[idx],
delta_landscape_kcal_per_mol_per_amino_acid[idx],
color=difference_color,linestyle='-',linewidth=1.5)
PlotUtilities.color_axis_ticks(color=landscape_color,ax=ax_energy,
spine_name='right')
ax_delta.fill_between(x=extension_nm[idx],
y1=lower_delta_landscape[idx],
y2=upper_delta_landscape[idx],
alpha=0.15,color=difference_color)
return to_ret