一种选择是使用未记录的命令resetplotview。
来自doc resetplotview:
限内部使用。在将来的版本中可能会删除此功能。
在xlim命令之前调用此函数。
figure(1);
x = 0:0.1:6
plot( x, sin(x) ); % Example plot, x axis range [0, 6]
resetplotview( gca, 'InitializeCurrentView' ) % Ensure we can reset the zoom
xlim( [2, 4] ); % 'Zoom' into the x axis range [2, 4]
这具有所需的结果,其中单击“重置为原始视图”缩小到x范围[0, 6],但最初显示的x范围是[2, 4]。
因为此函数未记录,所以具有内部的上下文可能是有用的。您可以edit resetplotview查看'InitializeCurrentView'选项的实现位置。从本质上讲,它可以setappdata用来定义'matlab_graphics_resetplotview'属性,特别是XLim属性为'auto'。如果resetplotview函数已折旧,您可以手动执行此操作。
啊啊啊啊啊吖
2019-02-16
各种方式:
1)将总和计算为一对一Nmax:
Nmax = 30;
Vijn = @(i,j,n) R*((1-(-1)^n)/(n^4 *pi^4)*sin((n*pi*c*j)/L)*sin((n*pi*i)/L));
i = 1:31;
j = 1:50;
n = 1:Nmax;
[I,J,N] = ndgrid(i,j,n);
V = arrayfun(Vijn,I,J,N);
Vc = cumsum(V,3);
% now Vc(:,:,k) is sum_n=1^{k+1} V(i,j,n)
figure(1);clf;imagesc(Vc(:,:,end));
2)无限循环
n = 1;
V = 0;
i = 1:31;
j = 1:50;
[I,J] = meshgrid(i,j);
while true
V = V + R*((1-(-1)^n)/(n^4 *pi^4)*sin((n*pi*c*J)/L).*sin((n*pi*I)/L));
n = n + 1;
figure(1);clf;
imagesc(V);
title(sprintf('N = %d',n))
drawnow;
pause(0.25);
end
啊啊啊啊啊吖
2019-02-15
尝试寻找bar功能
示例代码段
g1 = [10,10,20];
g2 = [15,10,8];
algStr = sprintfc('Algorithm %d',1:3);
bar(categorical({'Group1','Group2'}),[g1;g2])
legend(algStr)
啊啊啊啊啊吖
2019-02-15
zxq997
2019-02-14
其实数学专业说法叫多元函数哈,R多元方程组求解可使用dfsane,nleqslv
包,用法是:
dfsane(par, fn, method=2, control=list(),
quiet=FALSE, alertConvergence=TRUE, ...)
yaffawang
2019-02-13
解决办法:
可以在一个中使用的逻辑 groupby
import pandas as pd
df = pd.DataFrame({"ID":['xyz', 'pqr', 'xyz', 'rst'],
"event_type":['a', 'b', 'b', 'a']})
df.groupby("ID")\
.apply(lambda x: not (len(x)==1 and
not "a" in x["event_type"].values))
可以通过打印检查。最后使用此过滤器即可运行
df = df.groupby("ID")\
.filter(lambda x: not (len(x)==1 and
not "a" in x["event_type"].values))\
.reset_index(drop=True)
啊啊啊啊啊吖
2019-02-13
csv标准模块就足够了。您只需要迭代策略以将描述提取为数据库值,然后在policyItems上提取用户:
with open("Ranger_Policies_20190204_195010.json") as file:
jsonDF = json.load(file)
with open("outputfile.csv", newline='') as fd:
wr = csv.writer(fd)
_ = wr.writerow(('Database name', 'Users', 'Description'))
for policy in js['policies']:
desc = policy['description']
db_values = policy['resources']['database']['values']
for item in policy['policyItems']:
users = item['users']
for user in users:
for db in db_values:
if db != '*':
_ = wr.writerow((db, user, desc))
啊啊啊啊啊吖
2019-02-13
小木虫02
2019-02-02
朝阳Tim
2019-01-31
X = x_test[i:i+1]
# Visualize weights
W = model.layers[1].get_weights()[0][:,:,0,:]
w1=W.reshape(16,3,3)
W = np.squeeze(w1)
print("W shape : ", W.shape)
for i in range(0,16):
plt.subplot(4,4,i+1)
plt.imshow(w1[i,:,:], interpolation='nearest',cmap='gray')
plt.show()
W = model.layers[2].get_weights()[0][:,:,0,:]
w2=W.reshape(8,3,3)
W = np.squeeze(w2)
print("W shape : ", W.shape)
for i in range(0,8):
plt.subplot(4,4,i+1)
plt.imshow(w2[i,:,:], interpolation='nearest',cmap='gray')
plt.show()
啊啊啊啊啊吖
2019-01-28
PGC123
2019-01-25
dict.get()调用的默认参数正好用于这种情况:
emp_name = dict_1.get('name_2', {}).get('emp', '')
奈良鹿
2019-01-24
可以分组'col2'并使用它'/'.join(sorted(x))来获取可能的颜色组合。在'/'.join(sorted(x))将一个组中的所有值,并且将它们连接在一起成一个字符串。因此,如果'black'并且'white'在一个组中,它将它们一起加入到字符串中'black/white'。此外,我对值进行排序,因此无法进入'black/white'一个组,而'white/black'在另一个组中。此lambda函数适用于每个组。然后用于Counter在字典中存储计数。
from collections import Counter
Counter(dftest.groupby('col2')['col1'].apply(lambda x: '/'.join(sorted(x))))
输出:
{'black/black': 2, 'black/brown': 1, 'green/red': 1}
或者,可以使用value_counts而不是使用Counter。它将输出一系列:
dftest.groupby('col2')['col1'].apply(lambda x: '/'.join(sorted(x))).value_counts()
输出:
black/black 2
green/red 1
black/brown 1
啊啊啊啊啊吖
2019-01-24