简体   繁体   English

用 Matlab 绘制 3D 条形图

[英]Plotting 3D bar chart with Matlab

I have a CSV file which has the following structure:我有一个 CSV 文件,其结构如下:

epochs,learningrate, rmse
10,0.002,1
15,0.002,1
20,0.002,1
25,0.002,0.9799
30,0.002,0.9669
35,0.002,0.9561
40,0.002,0.9491
45,0.002,0.9428
10,0.003,1
15,0.003,0.9902
20,0.003,0.9667
25,0.003,0.9542
30,0.003,0.943
35,0.003,0.9357
40,0.003,0.9318
45,0.003,0.9267
10,0.004,1.0001
15,0.004,0.9668
20,0.004,0.9512
25,0.004,0.9393
30,0.004,0.932
35,0.004,0.9271
40,0.004,0.924
45,0.004,0.923
10,0.005,0.9813
15,0.005,0.9552
20,0.005,0.9429
25,0.005,0.9328
30,0.005,0.9285
35,0.005,0.9245
40,0.005,0.924
45,0.005,0.9213
10,0.006,0.9678
15,0.006,0.9465
20,0.006,0.9353
25,0.006,0.9284
30,0.006,0.9256
35,0.006,0.9235
40,0.006,0.9258
45,0.006,0.9245
10,0.007,0.9633
15,0.007,0.9424
20,0.007,0.9319
25,0.007,0.9281
30,0.007,0.9246
35,0.007,0.9249
40,0.007,0.9273
45,0.007,0.9263
10,0.008,0.957
15,0.008,0.9391
20,0.008,0.9301
25,0.008,0.928
30,0.008,0.9256
35,0.008,0.9264
40,0.008,0.9275
45,0.008,0.9291
10,0.009,0.9519
15,0.009,0.9335
20,0.009,0.9271
25,0.009,0.9254
30,0.009,0.9299
35,0.009,0.9287
40,0.009,0.9308
45,0.009,0.9334
10,0.01,0.9476
15,0.01,0.9332
20,0.01,0.9286
25,0.01,0.9283
30,0.01,0.9292
35,0.01,0.9311
40,0.01,0.9341
45,0.01,0.9362
,,
10,0.011,0.9459
15,0.011,0.9344
20,0.011,0.9271
25,0.011,0.9293
30,0.011,0.9309
35,0.011,0.9343
40,0.011,0.9348
45,0.011,0.9375
,,
10,0.012,0.9438
15,0.012,0.9322
20,0.012,0.9305
25,0.012,0.9323
30,0.012,0.9323
35,0.012,0.9359
40,0.012,0.9363
45,0.012,0.9398
,,
10,0.013,0.9402
15,0.013,0.9318
20,0.013,0.9313
25,0.013,0.9327
30,0.013,0.9365
35,0.013,0.9369
40,0.013,0.9385
45,0.013,0.9398
,,
10,0.014,0.9389
15,0.014,0.9342
20,0.014,0.9321
25,0.014,0.9329
30,0.014,0.9387
35,0.014,0.9404
40,0.014,0.9404
45,0.014,0.9405
,,
10,0.015,0.9393
15,0.015,0.9345
20,0.015,0.9346
25,0.015,0.9372
30,0.015,0.9369
35,0.015,0.9404
40,0.015,0.9429
45,0.015,0.9416
,,
10,0.016,0.9394
15,0.016,0.9359
20,0.016,0.9353
25,0.016,0.9375
30,0.016,0.9416
35,0.016,0.9421
40,0.016,0.9449
45,0.016,0.9449
,,
10,0.017,0.9389
15,0.017,0.9356
20,0.017,0.9383
25,0.017,0.9399
30,0.017,0.9427
35,0.017,0.9456
40,0.017,0.9451
45,0.017,0.9449
,,
10,0.018,0.9397
15,0.018,0.9392
20,0.018,0.94
25,0.018,0.9411
30,0.018,0.9446
35,0.018,0.9478
40,0.018,0.9474
45,0.018,0.9489
10,0.019,0.9372
15,0.019,0.938
20,0.019,0.9409
25,0.019,0.9433
30,0.019,0.9462
35,0.019,0.9452
40,0.019,0.9464
45,0.019,0.9477

MWE: MWE:

lambda1 = [1e-3 1e-3 1e-3 1e-3 1e-3 1e-3 1e-3 1e-3 1e-3 1e-3 1e-3     5e-3 5e-3 5e-3 5e-3 5e-3 5e-3 5e-3 5e-3 5e-3 5e-3 5e-3    1e-2 1e-2 1e-2 1e-2 1e-2 1e-2 1e-2 1e-2 1e-2 1e-2  1e-2 5e-2 5e-2 5e-2 5e-2 5e-2 5e-2 5e-2 5e-2 5e-2 5e-2 5e-2    1e-1 1e-1 1e-1 1e-1 1e-1 1e-1 1e-1 1e-1 1e-1 1e-1  1e-1    5e-1 5e-1 5e-1 5e-1 5e-1 5e-1 5e-1 5e-1 5e-1 5e-1 5e-1     1  1  1  1  1  1  1  1  1  1  1  5 5 5 5 5 5 5 5 5 5 5   10 10 10 10 10 10 10 10 10 10 10 50 50 50 50 50 50 50 50 50 50 50   100 100 100 100 100 100 100 100 100 100 100 ] ;
L1=reshape(lambda1,[11,11]);
lambda2=[1e-1  5e-1 1   5   10  50  100 500 1000    5000    10000    1e-1  5e-1 1   5   10  50  100 500 1000    5000    10000   1e-1  5e-1  1   5   10  50  100 500 1000    5000    10000  1e-1  5e-1   1   5   10  50  100 500 1000    5000    10000  1e-1  5e-1   1   5   10  50  100 500 1000    5000    10000  1e-1  5e-1   1   5   10  50  100 500 1000    5000    10000  1e-1  5e-1   1   5   10  50  100 500 1000    5000    10000  1e-1  5e-1   1   5   10  50  100 500 1000    5000    10000  1e-1  5e-1   1   5   10  50  100 500 1000    5000    10000  1e-1  5e-1   1   5   10  50  100 500 1000    5000    10000  1e-1  5e-1   1   5   10  50  100 500 1000    5000    10000 ];            
L2=reshape(lambda2,[11,11]);
rmse_abundance = [1 2 3 4 5 6 7 8 9 10 11  12 13 14 15 16 17 18 19 20 21 22 1 2 3 4 5 6 7 8 9 10 11  12 13 14 15 16 17 18 19 20 21 22 1 2 3 4 5 6 7 8 9 10 11  12 13 14 15 16 17 18 19 20 21 22 1 2 3 4 5 6 7 8 9 10 11  12 13 14 15 16 17 18 19 20 21 22 1 2 3 4 5 6 7 8 9 10 11  12 13 14 15 16 17 18 19 20 21 22    23 24 25 26 27 28 29 90 91 92 93];       
figure ;
rmse_abu = reshape(rmse_abundance,[11,11]);
bar3(rmse_abu) ;
set(gca(gcf), 'xticklabel',{'1e-3', '5e-3' ,'1e-2', '5e-2', '1e-1', '5e-1' ,'1' ,'5' ,'10', '50' ,'100'},'yticklabel',{'1e-1', '5e-1', '1', '5' ,'10','50','100' ,'500' ,'1e3', '5e3' ,'1e4'});
ylabel('gamma') ; xlabel ('learning rate'); zlabel('rmse ') ;
title('SGD');

在此处输入图片说明

I want to plot for all rows consisting of the epochs, learning rate(gamma), and rmse.我想绘制由纪元、学习率(伽马)和 rmse 组成的所有行。

I want, as an example, the rmse on the z-axis, the gamma on the x-axis and the epochs on the y-axis.例如,我想要 z 轴上的 rmse、x 轴上的伽玛和 y 轴上的历元。 I need to use my data, the one posted above, instead of the data that's actually making the plot (lambda1,lambda2,rmse_abu).我需要使用我的数据,即上面发布的数据,而不是实际制作绘图的数据(lambda1、lambda2、rmse_abu)。 How do I do that?我怎么做?

Your posted data does not resemble the plot you are looking for.您发布的数据与您要查找的图不相似。 Nevertheless, I think you should try this to achieve what you are looking for:尽管如此,我认为您应该尝试这样做来实现您的目标:

https://www.mathworks.com/matlabcentral/fileexchange/1420-scatterbar3 https://www.mathworks.com/matlabcentral/fileexchange/1420-scatterbar3

I also found this which might be actually more closer to what you are looking for:我还发现这实际上可能更接近您正在寻找的内容:

How to set x and y values when using bar3 in Matlab? 在 Matlab 中使用 bar3 时如何设置 x 和 y 值?

There's love if you want it.只要你愿意,就有爱。 Don't sound like no sonnet!不要听起来像没有十四行诗!

I hope this works!我希望这有效!

epochs = [10 15 20 25 30 35 40 45     10 15 20 25 30 35 40 45    10 15 20 25 30 35 40 45      10 15 20 25 30 35 40 45      10 15 20 25 30 35 40 45      10 15 20 25 30 35 40 45] ;
L1=reshape(epochs,[8,6]);
learning_rate=[0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002     0.003 0.003 0.003 0.003 0.003 0.003 0.003 0.003     0.004 0.004 0.004 0.004 0.004 0.004 0.004 0.004     0.005 0.005 0.005 0.005 0.005 0.005 0.005 0.005      0.006 0.006 0.006 0.006 0.006 0.006 0.006 0.006     0.007 0.007 0.007 0.007 0.007 0.007 0.007 0.007];            
L2=reshape(learning_rate,[8,6]);
rmse_abundance = [ 0.9904 0.9901 0.9799 0.9669 0.9561 0.9491 0.9428 0.9428     0.9900 0.9902 0.9667 0.9542 0.943 0.9357 0.9318 0.9267     1.0001 0.9668 0.9512 0.9393 0.932 0.9271 0.924 0.923     0.9813 0.9552 0.9429 0.9328 0.9285 0.9245 0.924 0.9213    0.9678 0.9465 0.9353 0.9284 0.9256 0.9235 0.9258 0.9245    0.9633 0.9424 0.9319 0.9281 0.9246 0.9249 0.9273 0.9263];       
figure ;
rmse_abu = reshape(rmse_abundance,[8,6]);
bar3(rmse_abu) ;
set(gca(gcf), 'yticklabel',{'10', '15' ,'20', '25', '30', '35' ,'40' ,'45'},'xticklabel',{'0.002', '0.003', '0.004', '0.005' ,'0.006','0.007','100' ,'500' ,'1e3', '5e3' ,'1e4'});
ylabel('epochs') ; xlabel ('gamma'); zlabel('rmse ') ;
title('SGD');

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM