我终于找到了解决方案。可以在代码中手动定位颜色条,但我想保留原始间距的所有内容。我的最终解决方案概述如下。
步骤1.在底部子图上使用单个颜色条创建绘图。
figure('color', 'white', 'DefaultAxesFontSize', fontSize, 'pos', posVec)
ax(1) = subplot2(2,1,1);
pcolor(x2d, t2d, dataMat1)
shading interp
ylim([0 10])
xlim([-0.3 0.3])
xticklabels({})
set(gca, 'clim', [-20 0])
colormap(flipud(gray))
set(gca,'layer','top')
axis ij
ax(2) = subplot2(2,1,2);
pcolor(x2d, t2d, dataMat2);
xlabel('x')
ylabel('y')
shading interp
ylim([0 10])
xlim([-0.3 0.3])
set(gca, 'clim', [-20 0])
yticklabels({})
cbar = colorbar;
cbar.Label.String = 'Normalized Unit';
colormap(flipud(gray))
set(gca,'layer','top')
axis ij步骤2.保存两个子图和颜色条的位置矢量。
pos1 = ax(1).Position; % Position vector = [x y width height]
pos2 = ax(2).Position;
pos3 = cbar.Position;步骤3.更新颜色条的位置以延伸到顶部子图的顶部。
cbar.Position = [pos3(1:3) (pos1(2)-pos3(2))+pos1(4)];步骤4.更新顶部子图的宽度以容纳颜色条。
ax(1).Position = [pos1(1) pos1(2) pos2(3) pos1(4)];步骤5.更新底部子图的宽度以容纳颜色条。
ax(2).Position = pos2;
啊啊啊啊啊吖
2019-02-19
解决办法:
可以尝试使用的是pd.Series.value_counts():
# Mock df
df = pd.DataFrame({key:np.random.randint(1, 6, 5) for key in "abcde"})
a b c d e
0 5 5 2 4 5
1 1 1 2 3 4
2 1 1 1 4 4
3 2 1 1 1 4
4 5 2 4 5 3
cols = ["a", "b", "c"]
new_df = pd.concat([df[c].value_counts() for c in cols], 1).fillna(0).astype(int)
print(new_df)
a b c
1 2 3 2
2 1 1 2
4 0 0 1
5 2 1 0
啊啊啊啊啊吖
2019-02-18
一种选择是使用未记录的命令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