本文整理汇总了Python中matplotlib.pyplot.get_current_fig_manager函数的典型用法代码示例。如果您正苦于以下问题:Python get_current_fig_manager函数的具体用法?Python get_current_fig_manager怎么用?Python get_current_fig_manager使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_current_fig_manager函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_data
def load_data(filename):
file = open(filename)
count =0
start_time = time.time()
s1 = start_time
time_slice = 5000
topics = np.array([topic4(600,400,15000)])
c_old = [0]*max_topics
v_old = [0]*max_topics
similarity = np.zeros(max_topics)
plt.ion()
fig = plt.figure()
ax1 = fig.add_subplot(1,1,1)
plt.get_current_fig_manager().window.wm_geometry("+0+0")
for line in file:
parsed_json = safe_parse(line)
if(not parsed_json):
continue
tweet = regex.sub('', parsed_json["text"].lower())
hashtags = [x["text"].lower() for x in parsed_json['entities']['hashtags']]
usernames = [x["screen_name"].lower() for x in parsed_json['entities']['user_mentions']]
words = getwords(tweet.split())
count+=1
if(len(words) < 2):
continue
for i in range(topics.size):
similarity[i] = topics[i].get_similarity(hashtags, usernames, words)
if(np.max(similarity) == 0):
if(topics.size < max_topics):
topics = np.append(topics, topic4(600,400,15000))
max_ind = topics.size -1
else:
max_ind = random.randrange(0,topics.size)
else:
max_ind = np.argmax(similarity)
topics[max_ind].set_cluster(hashtags, usernames, words)
if(count%time_slice ==0):
current = time.time()
print("--- %s seconds ---" % (current - start_time))
start_time=current
count=0
counts_vector = [i.topic_count for i in topics]
counts_vector += [0]*(max_topics-len(counts_vector))
delta = np.subtract(counts_vector,c_old)
acc = np.subtract(delta,v_old)
print(counts_vector)
# print(similarity)
ax1.plot(acc)
c_old = counts_vector
v_old = delta
plt.grid()
fig.canvas.draw()
ax1.clear()
# print_counts( counts_vector, topics)
print("\n")
print("---\n\n\nfinal time: %s seconds ---" % (time.time() - s1))
示例2: my_qunt_plot
def my_qunt_plot(qx):
fig = plt.figure(figsize=(10, 6))
mpl_agg = plt.get_backend().lower()
if 'tk' in mpl_agg:
# Option 2
# TkAgg backend
manager = plt.get_current_fig_manager()
manager.resize(*manager.window.maxsize())
elif 'qt' in mpl_agg:
# Option 1
# QT backend
manager = plt.get_current_fig_manager()
manager.window.showMaximized()
elif 'wx' in mpl_agg:
# Option 3
# WX backend
manager = plt.get_current_fig_manager()
manager.frame.Maximize(True)
df = pd.read_csv(qx.fn_qxLib, index_col=0, parse_dates=[0])
# ---top.plt
# fig = plt.figure(figsize=(20, 15))
ax1 = fig.add_subplot(111)
ax1.plot(df['dret'],color='green',label='dret',linewidth=0.5)
ax1.legend(loc='upper left')
ax2 = ax1.twinx()
ax2.plot(df['val'], color='red', label='val', linewidth=2)
ax2.legend(loc='upper right')
plt.tight_layout()
plt.show()
示例3: plot_su_mu_count_per_addr
def plot_su_mu_count_per_addr(self):
for i in self.MU_groups:
macs = i['addrs'].strip("[").replace("]", "").replace(" ", "").split(",")
if len(macs) > 1:
for m in macs:
self.mu_tx_counter[m] += 1
elif len(macs) == 1:
self.su_tx_counter[macs[0]] += 1
plt.style.use("ggplot")
plt.clf()
N = len(self.mu_tx_counter)
ind = np.array(range(0,N)) # the x locations for the groups
width = 4.0/N # the width of the bars: can also be len(x) sequence
space = 0.01
plt.xlim(0-2*width, N+2*width)
p1 = plt.bar(ind, [self.su_tx_counter[j] for j in self.mu_tx_counter], width, color='c')
p2 = plt.bar(ind+width+space, [self.mu_tx_counter[j] for j in self.mu_tx_counter], width, color='#ee7722')
plt.xticks(ind + space/2.0 + width, ([mac[len(mac)-6:len(mac)-1] for mac in self.mu_tx_counter]))
plt.legend((p1, p2), ("SU", "MU"))
plt.xlabel("Mac Address")
plt.ylabel("Number of NDPAs")
try:
plt.get_current_fig_manager().window.showMaximized()
except:
pass
plt.show()
示例4: plot_compare_states
def plot_compare_states(x_idx,data_dict,X_Time,X_Feature,X_STATE,X_names):
if X_STATE.shape!=X_Feature.shape:
raise NameError('the size of state and feature matrix must be same')
if (X_STATE.shape[0]!=X_Time.shape[0]):
raise NameError('the row length of state /feature matrix and time array must be same')
if (X_STATE.shape[1]!=len(X_names)):
raise NameError('the column length of state and name array must be same')
sensor_name=X_names[x_idx]
fig = plt.figure('Regualar Event Classification')
fig.suptitle('Regualar Event Classification');
plt.subplot(3,1,1);
plt.plot(unix_to_dtime(data_dict[sensor_name][2][0]),data_dict[sensor_name][2][1])
plt.ylabel('Power, KWatt')
plt.title(sensor_name+' - Measurements');
plt.subplot(3,1,2);
plt.plot(X_Time,X_Feature[:,x_idx]);
plt.title(X_names[x_idx]+' - Hourly Average');
plt.ylabel('Normalized Measurement')
plt.subplot(3,1,3);
low_peak_idx=np.nonzero(X_STATE[:,x_idx]==-1)[0]
no_peak_idx=np.nonzero(X_STATE[:,x_idx]==0)[0]
high_peak_idx=np.nonzero(X_STATE[:,x_idx]==1)[0]
plt.plot(X_Time[low_peak_idx],X_STATE[low_peak_idx,x_idx],'rv');
plt.plot(X_Time[high_peak_idx],X_STATE[high_peak_idx,x_idx],'b^');
plt.plot(X_Time[no_peak_idx],X_STATE[no_peak_idx,x_idx],'g.');
plt.plot(X_Time,X_STATE[:,x_idx]);
plt.title(sensor_name+' - Classified States ');
plt.ylabel('States'); plt.xlabel('Dates'); plt.ylim([-1.2,1.2])
plt.yticks([-1, 0, 1], ['Low Peak', 'No Peak', 'High Peak'])
plt.get_current_fig_manager().window.showMaximized()
示例5: iplot
def iplot(x, y):
"""
A simple no-fuss or features interctive plot for debugging.
Arguments:
- `x`: x value
- `y`: y value
"""
# interactive quick plot
plt.figure()
plt.ion()
plt.clf()
plt.plot(x, y,
color='black',
linestyle='-', # -/--/-./:
linewidth=1, # linewidth=1
marker='', # ./o/*/+/x/^/</>/v/s/p/h/H
markerfacecolor='black',
markersize=0, # markersize=6
label=r"data" # '__nolegend__'
)
plt.xscale("linear")
plt.yscale("linear")
plt.show()
plotPosition="+1100+0" # large_screen="+1100+0"; lap="+640+0"
plt.get_current_fig_manager().window.wm_geometry(plotPosition)
示例6: __init__
def __init__(self, port, baud, check = False):
"""
Initialize the main display: a single figure
:port: serial port index or name (eg.: COM4)
:paud: baud rate (eg.: 115200)
"""
self.frame = IM_Frame()
self.new_frame = False
self.lock = threading.Lock()
self.check = check
# disable figure toolbar, bind close event and open serial port
with mpl.rc_context({'toolbar':False}):
self.fig = plt.figure()
self.serial_port = serial.Serial(port, baud, timeout=0.25,bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, xonxoff=False)
self.serial_port.flush()
self.fig.canvas.mpl_connect('close_event', self.close_display)
self.fig.canvas.mpl_connect('resize_event', self.resize_display)
self.fig.canvas.set_window_title('pyIM')
# window position is set before state to maximized in update_graph
w,h=getVirtualScreenSize()
plt.get_current_fig_manager().window.wm_geometry(("+%d+%d"%(w-1,0)))
# create timer for updating display using a rs232 polling callback
timer = self.fig.canvas.new_timer(interval=250)
timer.add_callback(self.update_graphs) # then arg if needed
timer.start()
# launch figure
plt.show(block = True)
# close correctly serial port
self.close_display()
示例7: test_profile_dirac
def test_profile_dirac():
"""
Load and plot a 2D dirac
"""
imname = 'dirac-100.fits'
hdu = pyfits.open(imname)
im_dirac = hdu[0].data
hdr = hdu[0].header
xsize = im_dirac.shape[0]
ysize = im_dirac.shape[1]
xcen = xsize/2
ycen = ysize/2
(r, profile, geometric_area) = extract_profile_generic(im_dirac, xcen, ycen)
MAKE_PLOT=True
if MAKE_PLOT:
print "plotting dirac"
plt.figure()
plt.ion()
plt.clf()
plt.plot(r-0.5, profile/geometric_area)
plt.xscale("linear")
plt.yscale("linear")
plt.draw()
plt.show()
plt.get_current_fig_manager().window.wm_geometry("+1100+0")
plt.show()
示例8: splay_figures
def splay_figures():
"""Get all figures and spread them across my secondary monitor"""
fig_list = plt.get_fignums()
wx = 640
h = 500
x1, x2, x3 = 1367, 1367 + wx, 1367 + wx*2
y0 = 30
y1 = 570
points = np.array([[x1,y0,wx,h],
[x2,y0,wx,h],
[x3,y0,wx,h],
[x1,y1,wx,h],
[x2,y1,wx,h],
[x3,y1,wx,h]])
if len(fig_list) == 2:
points = points[[2, 5]]
if len(fig_list) == 3:
points = points[[2, 4, 5]]
if len(fig_list) == 4:
points = points[[1, 2, 4, 5]]
for i in range(len(fig_list)):
plt.figure(fig_list[i])
plt.get_current_fig_manager().window.setGeometry(
points[i,0],points[i,1], points[i,2], points[i,3])
示例9: plot_learning_curve
def plot_learning_curve(estimator, title, X, y, ylim=None, cv=None,
n_jobs=-1, train_sizes=np.linspace(.1, 1.0, 5)):
#to have a figure object, this can be done figure = plt.figure() then the figure object can be referenced subsequently
plt.figure()
plt.title(title)
if ylim is not None:
plt.ylim(*ylim)
plt.xlabel("Training examples")
plt.ylabel("Score")
train_sizes, train_scores, test_scores = learning_curve(estimator, X, y, cv=cv, n_jobs=n_jobs, train_sizes=train_sizes, scoring='f1_weighted')
train_scores_mean = np.mean(train_scores, axis=1)
train_scores_std = np.std(train_scores, axis=1)
test_scores_mean = np.mean(test_scores, axis=1)
test_scores_std = np.std(test_scores, axis=1)
plt.grid()
plt.fill_between(train_sizes, train_scores_mean - train_scores_std,
train_scores_mean + train_scores_std, alpha=0.1,
color="r")
plt.fill_between(train_sizes, test_scores_mean - test_scores_std,
test_scores_mean + test_scores_std, alpha=0.1, color="g")
plt.plot(train_sizes, train_scores_mean, 'o-', color="r",
label="Training score")
plt.plot(train_sizes, test_scores_mean, 'o-', color="g",
label="Cross-validation score")
plt.legend(loc="best")
plt.get_current_fig_manager().window.raise_()
plt.show()
return plt
示例10: main_test_global
def main_test_global():
"""Test of global methods only
"""
fig, axes, imsh = generate_test_image()
plt.get_current_fig_manager().window.geometry('+50+10') #move(50, 10)
plt.show()
示例11: _plot_histogram
def _plot_histogram(self, data, number_of_devices=1,
preamp_timeout=1253):
if number_of_devices == 0:
return
data = np.array(data)
plt.figure(3)
plt.ioff()
plt.get_current_fig_manager().window.wm_geometry("800x550+700+25")
plt.clf()
if number_of_devices == 1:
plt.hist(data[0,:], bins=preamp_timeout, range=(1, preamp_timeout-1),
color='b')
elif number_of_devices == 2:
plt.hist(data[0,:], bins=preamp_timeout, range=(1, preamp_timeout-1),
color='r', label='JPM A')
plt.hist(data[1,:], bins=preamp_timeout, range=(1, preamp_timeout-1),
color='b', label='JPM B')
plt.legend()
elif number_of_devices > 2:
raise Exception('Histogram plotting for more than two ' +
'devices is not implemented.')
plt.xlabel('Timing Information [Preamp Time Counts]')
plt.ylabel('Counts')
plt.xlim(0, preamp_timeout)
plt.draw()
plt.pause(0.05)
示例12: system_false_alarm_threshold_plot
def system_false_alarm_threshold_plot(
plotdata, operation_time, threshold, xmin_time, xmax_time, xmajortick_time, xminortick_time, grid_parameter
):
###
#
# set up for two y axis
fig, left_axis = plot.subplots()
# right_axis=left_axis.twinx()
###
# plot text
title = "System false alarm threshold tests"
xtitle = "Facility operation time (d)"
ytitle = "Threshold (kg)"
###
plot.title(title)
left_axis.set_xlabel(xtitle)
left_axis.set_ylabel(ytitle)
# right_axis.set_ylabel()
###
# axis
xmin = xmin_time
xmax = xmax_time
#
ymin = -0.03
ymax = threshold + 0.03
#
xmajortick = xmajortick_time
ymajortick = 0.05
#
xminortick = xminortick_time
yminortick = 0.025
###
plot.xlim(xmin, xmax)
left_axis.axis(ymin=ymin, ymax=ymax)
#
left_axis.xaxis.set_major_locator(MultipleLocator(xmajortick))
left_axis.xaxis.set_minor_locator(MultipleLocator(xminortick))
left_axis.yaxis.set_major_locator(MultipleLocator(ymajortick))
left_axis.yaxis.set_minor_locator(MultipleLocator(yminortick))
#
left_axis.tick_params(axis="both", which="major", direction="inout", length=7)
###
# grid
if grid_parameter == 1:
left_axis.grid(which="major", axis="both", linewidth="1.1")
# left_axis.grid(which='minor',axis='both')
###
# plot
left_axis.plot(plotdata[:, 0], plotdata[:, 1], plotdata[:, 0], plotdata[:, 2])
plot.get_current_fig_manager().resize(1024, 800)
plot.show()
###
#
### save
plot.savefig(title)
###
return ()
示例13: campaign_plot
def campaign_plot(
plotdata, operation_time, total_campaign, xmin_time, xmax_time, xmajortick_time, xminortick_time, grid_parameter
):
###
#
# set up for two y axis
fig, left_axis = plot.subplots()
# right_axis=left_axis.twinx()
###
# plot text
title = "Total campaigns processed"
xtitle = "Facility operation time (d)"
ytitle = "Campaigns processed"
###
plot.title(title)
left_axis.set_xlabel(xtitle)
left_axis.set_ylabel(ytitle)
# right_axis.set_ylabel()
###
# axis
xmin = xmin_time
xmax = xmax_time
#
ymin = 0.50
ymax = (total_campaign - 1) + 0.50
#
xmajortick = xmajortick_time
ymajortick = 2
#
xminortick = xminortick_time
yminortick = 1
###
plot.xlim(xmin, xmax)
left_axis.axis(ymin=ymin, ymax=ymax)
#
left_axis.xaxis.set_major_locator(MultipleLocator(xmajortick))
left_axis.xaxis.set_minor_locator(MultipleLocator(xminortick))
left_axis.yaxis.set_major_locator(MultipleLocator(ymajortick))
left_axis.yaxis.set_minor_locator(MultipleLocator(yminortick))
#
left_axis.tick_params(axis="both", which="major", direction="inout", length=7)
###
# grid
if grid_parameter == 1:
left_axis.grid(which="major", axis="both", linewidth="1.1")
# left_axis.grid(which='minor',axis='both')
###
# plot
left_axis.plot(plotdata[:, 0], plotdata[:, 1])
plot.get_current_fig_manager().resize(1024, 800)
plot.show()
###
#
### save
plot.savefig(title)
###
return ()
示例14: system_false_alarm_plot
def system_false_alarm_plot(plotdata, total_campaign, system_false_alarm_counter, grid_parameter):
###
#
### This is for the false alarms trigger due to system inspection, not at KMPs
# set up for two y axis
fig, left_axis = plot.subplots()
# right_axis=left_axis.twinx()
###
# plot text
title = "System false alarms due to inspection"
xtitle = "Campaigns processed"
ytitle = "False alarms"
###
plot.title(title)
left_axis.set_xlabel(xtitle)
left_axis.set_ylabel(ytitle)
# right_axis.set_ylabel()
###
# axis
xmin = 0.50
xmax = (total_campaign - 1) + 0.50
#
ymin = -0.50
ymax = system_false_alarm_counter + 0.50
#
xmajortick = 2
ymajortick = 2
#
xminortick = 1
yminortick = 1
###
plot.xlim(xmin, xmax)
left_axis.axis(ymin=ymin, ymax=ymax)
#
left_axis.xaxis.set_major_locator(MultipleLocator(xmajortick))
left_axis.xaxis.set_minor_locator(MultipleLocator(xminortick))
left_axis.yaxis.set_major_locator(MultipleLocator(ymajortick))
left_axis.yaxis.set_minor_locator(MultipleLocator(yminortick))
#
left_axis.tick_params(axis="both", which="major", direction="inout", length=7)
###
# grid
if grid_parameter == 1:
left_axis.grid(which="major", axis="both", linewidth="1.1")
# left_axis.grid(which='minor',axis='both')
###
# plot
left_axis.plot(plotdata[:, 0], plotdata[:, 1])
plot.get_current_fig_manager().resize(1024, 800)
plot.show()
###
#
### save
plot.savefig(title)
###
return ()
示例15: fg
def fg(fig=None):
"""Raise figure to foreground."""
plt.figure((fig or plt.gcf()).number)
if plt.get_backend()[0:2].lower() == 'qt':
plt.get_current_fig_manager().window.hide()
plt.get_current_fig_manager().window.show()
plt.get_current_fig_manager().window.activateWindow()
plt.get_current_fig_manager().window.raise_()
elif plt.get_backend()[0:2].lower() == 'wx':
plt.get_current_fig_manager().window.Raise()