本文整理汇总了Python中GeneralUtil.python.PlotUtilities.no_x_anything方法的典型用法代码示例。如果您正苦于以下问题:Python PlotUtilities.no_x_anything方法的具体用法?Python PlotUtilities.no_x_anything怎么用?Python PlotUtilities.no_x_anything使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeneralUtil.python.PlotUtilities
的用法示例。
在下文中一共展示了PlotUtilities.no_x_anything方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: zoomed_axis
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import no_x_anything [as 别名]
def zoomed_axis(ax=plt.gca(),xlim=[None,None],ylim=[None,None],
remove_ticks=True,zoom=1,borderpad=1,loc=4,**kw):
"""
Creates a (pretty) zoomed axis
Args:
ax: which axis to zoom on
<x/y>_lim: the axes limits
remove_ticks: if true, removes the x and y ticks, to reduce clutter
remaining args: passed to zoomed_inset_axes
Returns:
the inset axis
"""
axins = zoomed_inset_axes(ax, zoom=zoom, loc=loc,borderpad=borderpad)
axins.set_xlim(*xlim) # apply the x-limits
axins.set_ylim(*ylim) # apply the y-limits
if (remove_ticks):
PlotUtilities.no_x_anything(axins)
PlotUtilities.no_y_anything(axins)
return axins
示例2: plot
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import no_x_anything [as 别名]
def plot(interp,split_fec,f,xlim_rel_start,xlim_rel_delta,
when_to_break=_dont_break):
# calculate all the things we will neeed
time_sep_force = f(split_fec)
x_plot,y_plot = Plotting.plot_format(time_sep_force)
n_filter_points = 1000
x_raw = time_sep_force.Time
y_raw = time_sep_force.Force
interp_raw = interp(x_raw)
diff_raw = y_raw - interp_raw
stdev = Analysis.local_stdev(diff_raw,n=split_fec.tau_num_points)
xlims_rel = [ [i,i+xlim_rel_delta] for i in xlim_rel_start]
# convert to plotting units
n = x_plot.size
slices_abs = [ slice(int(i*n),int(f*n),1) for i,f in xlims_rel ]
x_plot_slices = [ x_plot[s] for s in slices_abs ]
diff_raw_slices = [diff_raw[s] for s in slices_abs]
max_raw_diff_slices = [max(d) for d in diff_raw_slices]
min_raw_diff_slices = [min(d) for d in diff_raw_slices]
range_raw_diff_slices = np.array([min(min_raw_diff_slices),
max(max_raw_diff_slices)])
range_raw_diff = np.array([min(diff_raw),max(diff_raw)])
range_plot_diff = f_plot_y(range_raw_diff*1.1)
xlim_abs = [ [min(x),max(x)] for x in x_plot_slices]
n_plots = len(x_plot_slices)
# set up the plot styling
style_approach = dict(color='b')
style_raw = dict(alpha=0.3,**style_approach)
style_interp = dict(linewidth=3,**style_approach)
colors = ['r','m','k']
style_regions = []
for c in colors:
style_tmp = dict(**style_raw)
style_tmp['color'] = c
style_regions.append(style_tmp)
gs = gridspec.GridSpec(3,2*n_plots)
plt.subplot(gs[0,:])
plot_force(x_plot,y_plot,interp_raw,style_raw,style_interp)
# highlight all the residual regions in their colors
for style_tmp,slice_tmp in zip(style_regions,slices_abs):
if (when_to_break == _break_after_interp):
break
style_interp_tmp = dict(**style_tmp)
style_interp_tmp['alpha'] = 1
plt.plot(x_plot[slice_tmp],y_plot[slice_tmp],**style_tmp)
plt.plot(x_plot[slice_tmp],f_plot_y(interp_raw[slice_tmp]),linewidth=3,
**style_interp_tmp)
if (when_to_break == _break_after_first_zoom):
break
ax_diff = plt.subplot(gs[1,:])
plot_residual(x_plot,diff_raw,style_raw)
# highlight all the residual regions in their colors
for style_tmp,slice_tmp in zip(style_regions,slices_abs):
if (when_to_break == _break_after_interp):
break
plt.plot(x_plot[slice_tmp],f_plot_y(diff_raw)[slice_tmp],**style_tmp)
if (when_to_break == _break_after_first_zoom):
break
plt.ylim(range_plot_diff)
tick_kwargs = dict(right=False)
# plot all the subregions
for i in range(n_plots):
xlim_tmp = xlim_abs[i]
ylim_tmp = range_plot_diff
"""
plot the raw data
"""
offset_idx = 2*i
ax_tmp = plt.subplot(gs[-1,offset_idx])
diff_tmp = diff_raw_slices[i]
# convert everything to plotting units
diff_plot_tmp =f_plot_y(diff_tmp)
x_plot_tmp = x_plot_slices[i]
style_tmp = style_regions[i]
if (when_to_break != _break_after_interp):
plt.plot(x_plot_tmp,diff_plot_tmp,**style_tmp)
PlotUtilities.no_x_anything()
if (i != 0):
PlotUtilities.no_y_label()
PlotUtilities.tickAxisFont(**tick_kwargs)
else:
PlotUtilities.lazyLabel("","Force (pN)","",tick_kwargs=tick_kwargs)
plt.xlim(xlim_tmp)
plt.ylim(ylim_tmp)
if (when_to_break != _break_after_interp):
PlotUtilities.zoom_effect01(ax_diff, ax_tmp, *xlim_tmp)
if (i == 0 and (when_to_break != _break_after_interp)):
# make a scale bar for this plot
time = 20e-3
string = "{:d} ms".format(int(time*1000))
PlotUtilities.scale_bar_x(np.mean(xlim_tmp),0.8*max(ylim_tmp),
s=string,width=time,fontsize=15)
"""
plot the histogram
"""
ax_hist = plt.subplot(gs[-1,offset_idx+1])
if (i == 0):
PlotUtilities.xlabel("Count")
else:
PlotUtilities.no_x_label()
#.........这里部分代码省略.........
示例3: run
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import no_x_anything [as 别名]
#.........这里部分代码省略.........
ax_final_prob = plt.subplot(gs[3,:])
plt.plot(time_plot,to_prob_plot(info_final.cdf),
**probability_kwargs)
title_consistent = (arrow + "Supress small force change events")
PlotUtilities.lazyLabel("",probability_label_post,title_consistent,**kw)
PlotUtilities.no_x_label(ax_final_prob)
plt.ylim(ylim_prob)
plt.xlim(xlim_time)
Scalebar.x_scale_bar_and_ticks_relative(ax=ax_final_prob,**prob_scale_dict)
tick_style()
# # plot the final event locations
ax_final = plt.subplot(gs[4,:])
plt.plot(time_plot,force_plot,**raw_force_kwargs)
plt.plot(time_plot,force_interp_plot,**interp_force_kwargs)
PlotUtilities.no_x_label(ax_final)
title_final = (arrow + " Extract significant events")
event_starts = [e.start for e in info_final.event_slices_raw]
Plotting.plot_arrows_above_events(event_starts,plot_x=time_plot,
plot_y=force_plot,fudge_y=40,
label=None)
PlotUtilities.lazyLabel("",force_label,title_final,
loc = "upper center",**kw)
plt.ylim(ylim_force_pN)
plt.xlim(xlim_time)
Scalebar.x_scale_bar_and_ticks_relative(ax=ax_final,**fec_scale_dict)
tick_style()
ylim_first_event = [-5,30]
first_event_window_large = 0.045
fraction_increase= 5
color_first = 'm'
# get the event index, window pct to use, where to show a 'zoom', and the
# y limits (if none, just all of it)
event_idx_fudge_and_kw = \
[ [0 ,first_event_window_large ,True,ylim_first_event,color_first],
[0 ,first_event_window_large/fraction_increase,False,
ylim_first_event,color_first],
[-1,4e-3,True,[-50,None],'r']]
widths_seconds = 1e-3 * np.array([50,10,5])
for i,(event_id,fudge,zoom_bool,ylim,c) in \
enumerate(event_idx_fudge_and_kw):
# get how the interpolated plot should be
interp_force_kwargs_tmp = dict(**interp_force_kwargs)
interp_force_kwargs_tmp['color'] = c
interp_force_kwargs_tmp['linewidth'] = 1.25
# determine the slice we want to use
event_location = info_final.event_idx[event_id]
event_bounding_slice = slice_window_around(event_location,
time_plot,fraction=fudge)
time_first_event_plot = time_plot[event_bounding_slice]
time_slice = time_first_event_plot
# # plot the interpolated on the *full plot* before we zoom in (so the
# # colors match)
plt.subplot(gs[-2,:])
plt.plot(time_slice,force_interp_plot[event_bounding_slice],
**interp_force_kwargs_tmp)
plt.ylim(ylim_force_pN)
# # next, plot the zoomed version
in_ax = plt.subplot(gs[-1,i])
in_ax.plot(time_slice,force_plot[event_bounding_slice],
**raw_force_kwargs)
in_ax.plot(time_slice,force_interp_plot[event_bounding_slice],
**interp_force_kwargs_tmp)
PlotUtilities.no_x_anything(ax=in_ax)
# removing y label on all of them..
if (i == 0):
ylabel = force_label
else:
ylabel = ""
# determine if we need to add in 'guidelines' for zooming
if (zoom_bool):
PlotUtilities.zoom_effect01(ax_final,in_ax,*in_ax.get_xlim(),
color=c)
PlotUtilities.lazyLabel("Time (s)",ylabel,"",**kw)
else:
# this is a 'second' zoom in...'
PlotUtilities.no_y_label(in_ax)
ylabel = ("{:d}x\n".format(fraction_increase)) + \
r"$\rightarrow$"
PlotUtilities.lazyLabel("Time (s)",ylabel,"",**kw)
PlotUtilities.ylabel(ylabel,rotation=0,labelpad=5)
# plot an arrow over the (single) event
Plotting.plot_arrows_above_events([event_location],plot_x=time_plot,
plot_y=force_plot,fudge_y=7,
label=None,markersize=150)
plt.ylim(ylim)
common = dict(unit="ms",
unit_kwargs=dict(value_function = lambda x: x*1e3))
width = widths_seconds[i]
Scalebar.x_scale_bar_and_ticks_relative(offset_y=0.1,offset_x=0.5,
width=width,ax=in_ax,
**common)
PlotUtilities.tom_ticks(ax=in_ax,num_major=2,change_x=False)
loc_major = [-0.15,1.2]
loc_minor = [-0.15,1.15]
locs = [loc_major for _ in range(5)] + \
[loc_minor for _ in range(3)]
PlotUtilities.label_tom(fig,loc=locs)
subplots_adjust=dict(hspace=0.48,wspace=0.35)
PlotUtilities.save_png_and_svg(fig,"flowchart",
subplots_adjust=subplots_adjust)
示例4: make_pedagogical_plot
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import no_x_anything [as 别名]
def make_pedagogical_plot(data_to_plot,kw,out_name="./iwt_diagram"):
heatmap_data = data_to_plot.heatmap_data
data = landscape_data(data_to_plot.landscape)
fig = PlotUtilities.figure((3.25,5))
# # ploy the heat map
ax_heat = plt.subplot(3,1,1)
heatmap_plot(heatmap_data,data.amino_acids_per_nm(),
kw_heatmap=kw['kw_heatmap'])
xlim_fec = plt.xlim()
PlotUtilities.no_x_label(ax_heat)
ax_heat.set_ylim([0,150])
PlotUtilities.no_x_label(ax_heat)
PlotUtilities.no_y_label(ax_heat)
fontsize_scalebar = 6
common_kw = dict(color='w',fontsize=fontsize_scalebar)
x_font,y_font = Scalebar.\
font_kwargs_modified(x_kwargs=common_kw,
y_kwargs=common_kw)
heat_kw_common = dict(line_kwargs=dict(color='w',linewidth=1.5))
x_heat_kw = dict(width=15,unit="nm",font_kwargs=x_font,**heat_kw_common)
y_heat_kw = dict(height=30,unit='pN ',font_kwargs=y_font,**heat_kw_common)
# add a scale bar for the heatmap...
scale_bar_x = 0.83
Scalebar.crossed_x_and_y_relative(scale_bar_x,0.55,ax=ax_heat,
x_kwargs=x_heat_kw,
y_kwargs=y_heat_kw)
jcp_fig_util.add_helical_boxes(ax=ax_heat,ymax_box=0.9,alpha=1.0,
font_color='w',offset_bool=True)
# # plot the energy landscape...
ax_correction = plt.subplot(3,1,2)
plot_with_corrections(data)
PlotUtilities.no_x_label(ax_correction)
PlotUtilities.lazyLabel("","Energy (kcal/mol)","")
ax_correction.set_xlim(xlim_fec)
offset_y_pedagogy = 0.42
setup_pedagogy_ticks(ax_correction,scale_bar_x,x_heat_kw,y_heat_kw,
offset_y=offset_y_pedagogy)
legend_font_size = 9
legend = PlotUtilities.legend(handlelength=1.5,loc=(0.15,0.07),ncol=3,
fontsize=legend_font_size,handletextpad=0.4)
for i,text in enumerate(legend.get_texts()):
plt.setp(text, color = kwargs_correction()[i]['color'])
# make the inset plot
axins = zoomed_inset_axes(ax_correction, zoom=3, loc=2,
borderpad=0.8)
plot_with_corrections(data)
xlim_box = [1,5]
ylim_box = [-3,28]
plt.xlim(xlim_box)
plt.ylim(ylim_box)
PlotUtilities.no_x_anything(axins)
PlotUtilities.no_y_anything(axins)
# add in scale bars
kw_common = dict(line_kwargs=dict(linewidth=0.75,color='k'))
common_font_inset = dict(fontsize=fontsize_scalebar)
x_kwargs = dict(verticalalignment='top',**common_font_inset)
x_font,y_font = Scalebar.\
font_kwargs_modified(x_kwargs=x_kwargs,
y_kwargs=dict(horizontalalignment='right',
**common_font_inset))
# set up the font, offset ('fudge') the text from the lines
fudge_x = dict(x=0,y=-0.5)
fudge_y = dict(x=0,y=0.1)
Scalebar.crossed_x_and_y_relative(0.55,0.66,ax=axins,
x_kwargs=dict(width=2,unit="nm",
font_kwargs=x_font,
fudge_text_pct=fudge_x,
**kw_common),
y_kwargs=dict(height=8,unit='kcal/\nmol',
font_kwargs=y_font,
fudge_text_pct=fudge_y,
**kw_common))
# draw a bbox of the region of the inset axes in the parent axes and
# connecting lines between the bbox and the inset axes area
color_box = 'rebeccapurple'
PlotUtilities.color_frame('rebeccapurple',ax=axins)
Annotations.add_rectangle(ax_correction,xlim_box,ylim_box,edgecolor=color_box)
ax_correction.set_xlim(xlim_fec)
ax_energy = plt.subplot(3,1,3)
plot_landscape(data,xlim_fec,kw_landscape=kw['kw_landscape'],
plot_derivative=False,label_deltaG=" ")
ax_energy.set_xlim(xlim_fec)
setup_pedagogy_ticks(ax_energy,scale_bar_x,x_heat_kw,y_heat_kw,
offset_y=offset_y_pedagogy)
# add in the equation notation
strings,colors = [],[]
labels = kwargs_labels()
# add in the appropriate symbols
strings = ["$\Delta G$ = ",labels[0]," + ",labels[1]," - ",labels[2]]
colors_labels = [c['color'] for c in kwargs_correction()]
colors = ["k"] + [item for list in [[c,"k"] for c in colors_labels]
for item in list]
x,y = Scalebar.x_and_y_to_abs(x_rel=0.08,y_rel=0.85,ax=ax_energy)
Annotations.rainbow_text(x,y,strings=strings,colors=colors,
ax=ax_energy,size=legend_font_size)
PlotUtilities.legend(handlelength=0.5,loc=(0.03,0.8))
PlotUtilities.no_x_label(ax_energy)
PlotUtilities.save_png_and_svg(fig,out_name)
示例5: run
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import no_x_anything [as 别名]
def run():
"""
"""
landscape = CheckpointUtilities.lazy_load("./example_landscape.pkl")
# make the landscape relative
landscape.offset_energy(min(landscape.G_0))
landscape.offset_extension(min(landscape.q))
# get the landscape, A_z in kT. Note that we convert z->q, so it is
# really A(q=z-A'/k)
A_q = landscape.A_z
A_q_kT = (A_q * landscape.beta)
# numerically differentiate
to_y = lambda x: x * 1e12
landscape_deriv_plot = to_y(np.gradient(A_q)/np.gradient(landscape.q))
# compare with the A' term. XXX should just save it...
weighted_deriv_plot = to_y(landscape.A_z_dot)
x_plot = landscape.q * 1e9
label_A_q_dot = r"$\dot{A}$"
label_finite = label_A_q_dot + r" from finite difference"
label_work = r"{:s}$ =<<F>>$".format(label_A_q_dot)
kw_weighted = dict(color='m',label=label_work)
fig = PlotUtilities.figure((3.5,5))
# # plot just A(q)
ax_A_q = plt.subplot(3,1,1)
plt.plot(x_plot,A_q_kT,color='c',label="$A$")
PlotUtilities.lazyLabel("","Helmholtz A ($k_\mathrm{b}T$)","",
loc=(0.5,0.8),frameon=True)
PlotUtilities.set_legend_kwargs(ax=ax_A_q,background_color='w',linewidth=0)
PlotUtilities.no_x_label(ax_A_q)
x0 = 14.5
dx = 0.05
xlim = [x0,x0+dx]
# plot the data red where we will zoom in
where_region = np.where( (x_plot >= xlim[0]) &
(x_plot <= xlim[1]))
zoom_x = x_plot[where_region]
zoom_y = A_q_kT[where_region]
ylim = [min(zoom_y),max(zoom_y)]
dy = ylim[1]-ylim[0]
# add in some extra space for the scalebar
ylim_fudge = 0.7
ylim = [ylim[0],ylim[1] + (ylim_fudge * dy)]
lazy_common = dict(title_kwargs=dict(loc='left'))
plt.axvspan(*xlim,color='r',alpha=0.3,edgecolor="None")
plt.plot(zoom_x,zoom_y,color='r')
# plot a zoomed in axis, to clarify why it probably goes wrong
axins = zoomed_inset_axes(ax_A_q, zoom=250, loc=4,borderpad=1)
axins.plot(x_plot, A_q_kT,linewidth=0.1,color='r')
axins.set_xlim(*xlim) # apply the x-limits
axins.set_ylim(*ylim) # apply the y-limits
PlotUtilities.no_x_anything(axins)
PlotUtilities.no_y_anything(axins)
# add in a scale bar for the inset
unit_kw_x = dict(fmt="{:.0f}",value_function=lambda x: x*1000)
common = dict(line_kwargs=dict(linewidth=1.0,color='k'))
# round to ~10s of pm
x_width = np.around(dx/3,2)
y_width = np.around(dy/3,1)
x_kw = dict(width=x_width,unit="pm",unit_kwargs=unit_kw_x,
fudge_text_pct=dict(x=0.2,y=-0.2),**common)
y_kw = dict(height=y_width,unit=r"$k_\mathrm{b}T$",
unit_kwargs=dict(fmt="{:.1f}"),**common)
Scalebar.crossed_x_and_y_relative(ax=axins,
offset_x=0.45,
offset_y=0.7,
x_kwargs=x_kw,
y_kwargs=y_kw)
# # plot A_z_dot
ax_deriv_both = plt.subplot(3,1,2)
# divide by 1000 to get uN
plt.plot(x_plot,landscape_deriv_plot/1e6,color='k',
label=label_finite)
plt.plot(x_plot,weighted_deriv_plot/1e6,**kw_weighted)
PlotUtilities.lazyLabel("",
"$\dot{A}(q)$ ($\mathrm{\mu}$N)",
"$\Downarrow$ Determine derivative (both methods)",
**lazy_common)
PlotUtilities.no_x_label(ax_deriv_both)
# # plot A_z_dot, but just the weighted method (ie: not super wacky)
ax_deriv_weighted = plt.subplot(3,1,3)
plt.plot(x_plot,weighted_deriv_plot,linewidth=1,**kw_weighted)
title_last = "$\Downarrow$ Work-weighted method is reasonable "
PlotUtilities.lazyLabel("Extension (nm)","$\dot{A}(q)$ (pN)",
title_last,**lazy_common)
PlotUtilities.savefig(fig,"./finite_differences.png",
subplots_adjust=dict(hspace=0.2))