首页/文章/ 详情

Matlab三元相图彩色相图绘制

5月前浏览9168

本文摘要(由AI生成):

本文介绍了如何使用MATLAB绘制三元相图,包括线性图和彩色图。通过给定的绘图数据和坐标系,使用`trisurf`函数可以绘制出三维图像。文章详细解释了绘制过程中的各个步骤和参数设置,帮助读者理解和掌握三元相图的绘制方法。通过学习和实践这两个示例,读者可以全面掌握三元相图的绘制技巧。同时,文章也鼓励读者在细节上提出问题,以便进行深入的讨论和学习。


过冷水在往期文章中有和大家分享三元相图的绘制,给出的图像比较简单,只是在三元系中简单的绘制了几条线。本期过冷数详细和大家分享一下三元相图的进阶使用。

image.png 

等活度曲线

在材料和化工应用中,研究人员会需要绘制等活度曲线图

image.png 

这图是不是就比上图之前的演示图看上去要美观很多,其程序为;

clear
A=[0.023  0.9769  0.0001
0.0245  0.9394  0.0361
0.025   0.9265  0.0485
0.027   0.8729  0.1001
0.0275  0.8589  0.1136
0.0285  0.8299  0.1416
0.029   0.8149  0.1561
0.03    0.7837  0.1863
0.0305  0.7675  0.202
0.031   0.7506  0.2184
0.0315  0.7332  0.2353
0.032   0.715   0.253
0.0325  0.696   0.2715
0.033   0.676   0.291
0.0335  0.6547  0.3118
0.034   0.632   0.334
0.0345  0.6072  0.3583
0.035   0.5798  0.3852
0.0355  0.5483  0.4162
0.036   0.5098  0.4542
0.0365  0.4534  0.5101
0.036   0.2636  0.7004
0.0355  0.2267  0.7378
0.035   0.1969  0.7681
0.0345  0.171   0.7945
0.034   0.1478  0.8182
0.0335  0.1266  0.8399
0.033   0.1068  0.8602
0.0325  0.0883  0.8792
0.032   0.0706  0.8974
0.0315  0.0538  0.9147
0.031   0.0376  0.9314
0.0305  0.0219  0.9476
0.03    0.0068  0.9632
]; 
ternplot(A(:,1),A(:,2),A(:,3))
hold on
 
A=[0.05 0.9355  0.0145
0.051   0.9244  0.0246
0.054   0.8908  0.0552
0.055   0.8795  0.0655
0.0565  0.8624  0.0811
0.057   0.8567  0.0863
0.0585  0.8394  0.1021
0.059   0.8336  0.1074
0.061   0.8102  0.1288
0.0615  0.8043  0.1342
0.0645  0.7684  0.1671
0.065   0.7623  0.1727
0.0655  0.7562  0.1783
0.066   0.7501  0.1839
0.0665  0.7439  0.1896
0.0675  0.7315  0.201
0.069   0.7126  0.2184
0.0705  0.6934  0.2361
0.071   0.6869  0.2421
0.0715  0.6804  0.2481
0.072   0.6738  0.2542
0.073   0.6605  0.2665
0.0745  0.6401  0.2854
0.075   0.6332  0.2918
0.076   0.6192  0.3048
0.0765  0.6121  0.3114
0.077   0.6049  0.3181
0.0775  0.5976  0.3249
0.078   0.5903  0.3317
0.0785  0.5828  0.3387
0.079   0.5753  0.3457
0.08    0.5599  0.3601
0.0805  0.552   0.3675
0.081   0.544   0.375
0.0815  0.5359  0.3826
0.082   0.5276  0.3904
0.0825  0.5191  0.3984
0.083   0.5105  0.4065
0.0835  0.5017  0.4148
0.084   0.4926  0.4234
0.0845  0.4834  0.4321
0.085   0.4738  0.4412
0.0855  0.464   0.4505
0.086   0.4538  0.4602
0.0865  0.4432  0.4703
0.087   0.4321  0.4809
0.0875  0.4205  0.492
0.088   0.4082  0.5038
0.0885  0.395   0.5165
0.089   0.3808  0.5302
0.0895  0.365   0.5455
0.09    0.347   0.563
0.0905  0.3251  0.5844
0.091   0.293   0.616
0.0905  0.1905  0.719
0.09    0.1708  0.7392
0.0895  0.1551  0.7554
0.089   0.1416  0.7694
0.0885  0.1297  0.7818
0.088   0.1188  0.7932
0.0875  0.1088  0.8037
0.087   0.0995  0.8135
0.0865  0.0907  0.8228
0.086   0.0824  0.8316
0.0855  0.0745  0.84
0.085   0.0669  0.8481
0.0845  0.0597  0.8558
0.084   0.0527  0.8633
0.0835  0.0459  0.8706
0.083   0.0393  0.8777
0.0815  0.0207  0.8978
0.081   0.0148  0.9042
0.0805  0.009   0.9105
0.08    0.0034  0.9166
]; 
ternplot(A(:,1),A(:,2),A(:,3))
 
A=[0.081    0.899   0.02
0.082   0.8925  0.0255
0.083   0.886   0.031
0.086   0.8666  0.0474
0.093   0.8218  0.0852
0.0945  0.8123  0.0932
0.0985  0.7871  0.1144
0.1005  0.7746  0.1249
0.1055  0.7436  0.1509
0.1085  0.7252  0.1663
0.1095  0.7191  0.1714
0.1105  0.713   0.1765
0.112   0.7039  0.1841
0.1125  0.7009  0.1866
0.1175  0.6709  0.2116
0.122   0.6443  0.2337
0.1235  0.6355  0.241
0.128   0.6094  0.2626
0.1295  0.6008  0.2697
0.1325  0.5837  0.2838
0.1345  0.5724  0.2931
0.135   0.5696  0.2954
0.1355  0.5668  0.2977
0.136   0.564   0.3
0.1365  0.5612  0.3023
0.137   0.5584  0.3046
0.139   0.5473  0.3137
0.14    0.5418  0.3182
0.141   0.5363  0.3227
0.1425  0.5281  0.3294
0.147   0.5038  0.3492
0.1475  0.5011  0.3514
0.1485  0.4958  0.3557
0.1505  0.4852  0.3643
0.152   0.4773  0.3707
0.1525  0.4747  0.3728
0.153   0.4721  0.3749
0.1535  0.4695  0.377
0.154   0.4669  0.3791
0.1545  0.4643  0.3812
0.1565  0.454   0.3895
0.1575  0.4489  0.3936
0.1585  0.4438  0.3977
0.159   0.4413  0.3997
0.1605  0.4337  0.4058
0.161   0.4312  0.4078
0.1615  0.4287  0.4098
0.162   0.4262  0.4118
0.164   0.4163  0.4197
0.165   0.4114  0.4236
0.166   0.4065  0.4275
0.1675  0.3992  0.4333
0.168   0.3968  0.4352
0.1685  0.3944  0.4371
0.169   0.392   0.439
0.1695  0.3896  0.4409
0.17    0.3872  0.4428
0.1705  0.3848  0.4447
0.1715  0.3801  0.4484
0.172   0.3777  0.4503
0.173   0.373   0.454
0.1735  0.3707  0.4558
0.175   0.3637  0.4613
0.1755  0.3614  0.4631
0.176   0.3591  0.4649
0.1765  0.3568  0.4667
0.177   0.3545  0.4685
0.1785  0.3477  0.4738
0.1795  0.3432  0.4773
0.1805  0.3387  0.4808
0.181   0.3365  0.4825
0.184   0.3233  0.4927
0.1845  0.3211  0.4944
0.1855  0.3168  0.4977
0.186   0.3146  0.4994
0.1865  0.3125  0.501
0.1875  0.3082  0.5043
0.188   0.3061  0.5059
0.1885  0.304   0.5075
0.189   0.3019  0.5091
0.1895  0.2998  0.5107
0.19    0.2977  0.5123
0.1905  0.2956  0.5139
0.1915  0.2915  0.517
0.1925  0.2874  0.5201
0.1935  0.2833  0.5232
0.194   0.2813  0.5247
0.1945  0.2793  0.5262
0.195   0.2773  0.5277
0.1955  0.2753  0.5292
0.196   0.2733  0.5307
0.1965  0.2713  0.5322
0.1975  0.2674  0.5351
0.1985  0.2635  0.538
0.1995  0.2596  0.5409
0.2 0.2577  0.5423
0.2005  0.2558  0.5437
0.201   0.2539  0.5451
0.2015  0.252   0.5465
0.202   0.2501  0.5479
0.203   0.2464  0.5506
0.2035  0.2445  0.552
0.204   0.2427  0.5533
0.205   0.239   0.556
0.2055  0.2372  0.5573
0.206   0.2354  0.5586
0.2065  0.2336  0.5599
0.207   0.2318  0.5612
0.2075  0.23    0.5625
0.208   0.2282  0.5638
0.209   0.2247  0.5663
0.21    0.2212  0.5688
0.2105  0.2195  0.57
0.213   0.211   0.576
0.2135  0.2093  0.5772
0.2145  0.206   0.5795
0.2155  0.2027  0.5818
0.216   0.2011  0.5829
0.2185  0.1931  0.5884
0.219   0.1915  0.5895
0.22    0.1884  0.5916
0.221   0.1853  0.5937
0.2215  0.1838  0.5947
0.222   0.1823  0.5957
0.2225  0.1808  0.5967
0.223   0.1793  0.5977
0.2235  0.1778  0.5987
0.2245  0.1749  0.6006
0.225   0.1734  0.6016
0.2255  0.172   0.6025
0.2265  0.1691  0.6044
0.227   0.1677  0.6053
0.2275  0.1663  0.6062
0.228   0.1649  0.6071
0.2285  0.1635  0.608
0.229   0.1621  0.6089
0.2295  0.1608  0.6097
0.23    0.1594  0.6106
0.231   0.1567  0.6123
0.2315  0.1554  0.6131
0.232   0.1541  0.6139
0.2335  0.1502  0.6163
0.234   0.1489  0.6171
0.2345  0.1476  0.6179
0.2355  0.1451  0.6194
0.2365  0.1426  0.6209
0.237   0.1414  0.6216
0.2375  0.1402  0.6223
0.238   0.139   0.623
0.2385  0.1378  0.6237
0.239   0.1366  0.6244
0.2395  0.1354  0.6251
0.2405  0.1331  0.6264
0.241   0.1319  0.6271
0.2415  0.1308  0.6277
0.242   0.1297  0.6283
0.243   0.1274  0.6296
0.2435  0.1263  0.6302
0.244   0.1252  0.6308
0.245   0.1231  0.6319
0.2455  0.122   0.6325
0.2465  0.1199  0.6336
0.2475  0.1178  0.6347
0.248   0.1168  0.6352
0.2485  0.1158  0.6357
0.249   0.1148  0.6362
0.2495  0.1138  0.6367
0.25    0.1128  0.6372
0.2505  0.1118  0.6377
0.2515  0.1099  0.6386
0.252   0.1089  0.6391
0.2525  0.108   0.6395
0.2535  0.1061  0.6404
0.254   0.1052  0.6408
0.2545  0.1043  0.6412
0.255   0.1034  0.6416
0.2555  0.1025  0.642
0.256   0.1016  0.6424
0.2565  0.1007  0.6428
0.2575  0.099   0.6435
0.2585  0.0973  0.6442
0.2595  0.0956  0.6449
0.26    0.0948  0.6452
0.2605  0.094   0.6455
0.261   0.0932  0.6458
0.2615  0.0924  0.6461
0.262   0.0916  0.6464
0.2625  0.0908  0.6467
0.263   0.09    0.647
0.264   0.0885  0.6475
0.2645  0.0877  0.6478
0.265   0.087   0.648
0.2655  0.0862  0.6483
0.266   0.0855  0.6485
0.2665  0.0848  0.6487
0.268   0.0826  0.6494
0.2685  0.0819  0.6496
0.27    0.0799  0.6501
0.2705  0.0792  0.6503
0.271   0.0785  0.6505
0.2715  0.0779  0.6506
0.272   0.0772  0.6508
0.2725  0.0766  0.6509
0.273   0.0759  0.6511
0.2735  0.0753  0.6512
0.274   0.0747  0.6513
0.275   0.0734  0.6516
0.2755  0.0728  0.6517
0.276   0.0722  0.6518
0.2765  0.0716  0.6519
0.277   0.071   0.652
0.2775  0.0704  0.6521
0.2785  0.0693  0.6522
0.279   0.0687  0.6523
0.28    0.0676  0.6524
0.2805  0.067   0.6525
0.281   0.0665  0.6525
0.282   0.0654  0.6526
0.2825  0.0649  0.6526
0.2835  0.0638  0.6527
0.284   0.0633  0.6527
0.2845  0.0628  0.6527
0.285   0.0623  0.6527
0.2855  0.0618  0.6527
0.286   0.0613  0.6527
0.2865  0.0608  0.6527
0.287   0.0603  0.6527
0.2875  0.0598  0.6527
0.2885  0.0589  0.6526
0.289   0.0584  0.6526
0.29    0.0575  0.6525
0.2905  0.057   0.6525
0.291   0.0566  0.6524
0.2915  0.0561  0.6524
0.292   0.0557  0.6523
0.293   0.0548  0.6522
0.2935  0.0544  0.6521
0.2945  0.0535  0.652
0.295   0.0531  0.6519
0.2955  0.0527  0.6518
0.296   0.0523  0.6517
0.2965  0.0519  0.6516
0.297   0.0515  0.6515
0.2975  0.0511  0.6514
0.298   0.0507  0.6513
0.2985  0.0503  0.6512
0.299   0.0499  0.6511
0.2995  0.0495  0.651
0.3 0.0491  0.6509
0.301   0.0484  0.6506
0.3015  0.048   0.6505
0.3025  0.0473  0.6502
0.303   0.0469  0.6501
0.304   0.0462  0.6498
0.305   0.0455  0.6495
0.306   0.0448  0.6492
0.307   0.0441  0.6489
0.3075  0.0438  0.6487
0.309   0.0428  0.6482
0.3095  0.0425  0.648
0.311   0.0415  0.6475
0.3115  0.0412  0.6473
0.312   0.0409  0.6471
0.3125  0.0406  0.6469
0.313   0.0403  0.6467
0.3135  0.04    0.6465
0.314   0.0397  0.6463
0.3145  0.0394  0.6461
0.315   0.0391  0.6459
0.3155  0.0388  0.6457
0.316   0.0385  0.6455
0.3165  0.0382  0.6453
0.318   0.0374  0.6446
0.3185  0.0371  0.6444
0.319   0.0368  0.6442
0.32    0.0363  0.6437
0.3205  0.036   0.6435
0.321   0.0357  0.6433
0.322   0.0352  0.6428
0.3225  0.0349  0.6426
0.3235  0.0344  0.6421
0.3245  0.0339  0.6416
0.3255  0.0334  0.6411
0.3265  0.0329  0.6406
0.3275  0.0324  0.6401
0.3285  0.0319  0.6396
0.3295  0.0314  0.6391
0.33    0.0312  0.6388
0.331   0.0307  0.6383
0.3315  0.0305  0.638
0.3325  0.03    0.6375
0.333   0.0298  0.6372
0.334   0.0293  0.6367
0.3345  0.0291  0.6364
0.335   0.0289  0.6361
0.3365  0.0282  0.6353
0.337   0.028   0.635
0.3375  0.0278  0.6347
0.339   0.0271  0.6339
0.3395  0.0269  0.6336
0.34    0.0267  0.6333
0.3405  0.0265  0.633
0.341   0.0263  0.6327
0.351   0.0223  0.6267
0.3515  0.0221  0.6264
0.352   0.0219  0.6261
0.3525  0.0217  0.6258
0.353   0.0215  0.6255
0.3535  0.0213  0.6252
0.3555  0.0206  0.6239
0.356   0.0204  0.6236
0.3565  0.0202  0.6233
0.357   0.02    0.623
0.359   0.0193  0.6217
0.3595  0.0191  0.6214
0.36    0.0189  0.6211
0.3615  0.0184  0.6201
0.362   0.0182  0.6198
0.3625  0.018   0.6195
0.364   0.0175  0.6185
0.3645  0.0173  0.6182
0.366   0.0168  0.6172
0.3665  0.0166  0.6169
0.368   0.0161  0.6159
0.3685  0.0159  0.6156
0.37    0.0154  0.6146
0.3705  0.0152  0.6143
0.372   0.0147  0.6133
0.3735  0.0142  0.6123
0.374   0.014   0.612
0.375   0.0137  0.6113
0.3755  0.0135  0.611
0.377   0.013   0.61
0.3785  0.0125  0.609
0.379   0.0123  0.6087
0.38    0.012   0.608
0.3805  0.0118  0.6077
0.3815  0.0115  0.607
0.382   0.0113  0.6067
0.3835  0.0108  0.6057
0.385   0.0103  0.6047
0.3865  0.0098  0.6037
0.388   0.0093  0.6027
0.3895  0.0088  0.6017
0.391   0.0083  0.6007
0.3925  0.0078  0.5997
0.394   0.0073  0.5987
0.3955  0.0068  0.5977
0.397   0.0063  0.5967
0.3975  0.0061  0.5964
0.3985  0.0058  0.5957
0.399   0.0056  0.5954
0.4 0.0053  0.5947
0.4005  0.0051  0.5944
0.402   0.0046  0.5934
0.4035  0.0041  0.5924
0.405   0.0036  0.5914
0.4065  0.0031  0.5904
0.407   0.0029  0.5901
0.4085  0.0024  0.5891
0.41    0.0019  0.5881
0.4115  0.0014  0.5871
0.412   0.0012  0.5868
0.4135  0.0007  0.5858
0.4155  0   0.5845
]; 
ternplot(A(:,1),A(:,2),A(:,3))
 
A=[0.1115   0.8853  0.0032
0.1145  0.8723  0.0132
0.1155  0.868   0.0165
0.119   0.8531  0.0279
0.122   0.8405  0.0375
0.128   0.8158  0.0562
0.1305  0.8057  0.0638
0.131   0.8037  0.0653
0.1315  0.8017  0.0668
0.132   0.7997  0.0683
0.1325  0.7977  0.0698
0.136   0.7839  0.0801
0.137   0.78    0.083
0.14    0.7684  0.0916
0.15    0.731   0.119
0.1545  0.7148  0.1307
0.1605  0.6938  0.1457
0.165   0.6785  0.1565
0.1665  0.6735  0.16
0.1695  0.6636  0.1669
0.172   0.6555  0.1725
0.174   0.6491  0.1769
0.1745  0.6475  0.178
0.1765  0.6412  0.1823
0.1865  0.6108  0.2027
0.188   0.6064  0.2056
0.189   0.6035  0.2075
0.19    0.6006  0.2094
0.1915  0.5963  0.2122
0.1975  0.5795  0.223
0.199   0.5754  0.2256
0.201   0.57    0.229
0.2025  0.566   0.2315
0.205   0.5594  0.2356
0.2055  0.5581  0.2364
0.206   0.5568  0.2372
0.2065  0.5555  0.238
0.207   0.5542  0.2388
0.2135  0.5378  0.2487
0.2155  0.5329  0.2516
0.22    0.5221  0.2579
0.222   0.5174  0.2606
0.228   0.5037  0.2683
0.2325  0.4938  0.2737
0.233   0.4927  0.2743
0.239   0.48    0.281
0.2405  0.4769  0.2826
0.2435  0.4708  0.2857
0.244   0.4698  0.2862
0.2445  0.4688  0.2867
0.245   0.4678  0.2872
0.248   0.4619  0.2901
0.251   0.4561  0.2929
0.252   0.4542  0.2938
0.253   0.4523  0.2947
0.2545  0.4495  0.296
0.2635  0.4332  0.3033
0.2705  0.4212  0.3083
0.272   0.4187  0.3093
0.274   0.4154  0.3106
0.2815  0.4034  0.3151
0.2835  0.4003  0.3162
0.285   0.398   0.317
0.293   0.3861  0.3209
0.295   0.3832  0.3218
0.303   0.372   0.325
0.307   0.3666  0.3264
0.3085  0.3646  0.3269
0.3145  0.3568  0.3287
0.319   0.3511  0.3299
0.3215  0.348   0.3305
0.322   0.3474  0.3306
0.331   0.3366  0.3324
0.334   0.3331  0.3329
0.336   0.3308  0.3332
0.3375  0.3291  0.3334
0.339   0.3274  0.3336
0.3415  0.3246  0.3339
0.3465  0.3191  0.3344
0.349   0.3164  0.3346
0.3535  0.3116  0.3349
0.3555  0.3095  0.335
0.358   0.3069  0.3351
0.3615  0.3033  0.3352
0.3715  0.2933  0.3352
0.372   0.2928  0.3352
0.3755  0.2894  0.3351
0.3785  0.2865  0.335
0.3805  0.2846  0.3349
0.3825  0.2827  0.3348
0.39    0.2757  0.3343
0.3925  0.2734  0.3341
0.3935  0.2725  0.334
0.4035  0.2635  0.333
0.4045  0.2626  0.3329
0.407   0.2604  0.3326
0.411   0.2569  0.3321
0.4125  0.2556  0.3319
0.414   0.2543  0.3317
0.4155  0.253   0.3315
0.419   0.25    0.331
0.425   0.2449  0.3301
0.427   0.2432  0.3298
0.4295  0.2411  0.3294
0.4325  0.2386  0.3289
0.4355  0.2361  0.3284
0.4395  0.2328  0.3277
0.444   0.2291  0.3269
0.4445  0.2287  0.3268
0.451   0.2234  0.3256
0.4515  0.223   0.3255
0.452   0.2226  0.3254
0.4755  0.2038  0.3207
0.476   0.2034  0.3206
0.4765  0.203   0.3205
0.477   0.2026  0.3204
0.4855  0.1959  0.3186
0.486   0.1955  0.3185
0.493   0.19    0.317
0.4935  0.1896  0.3169
0.4995  0.1849  0.3156
0.5 0.1845  0.3155
0.506   0.1798  0.3142
0.512   0.1751  0.3129
0.5125  0.1747  0.3128
0.518   0.1704  0.3116
0.5185  0.17    0.3115
0.5245  0.1653  0.3102
0.525   0.1649  0.3101
0.5315  0.1598  0.3087
0.532   0.1594  0.3086
0.54    0.1531  0.3069
0.5405  0.1527  0.3068
0.541   0.1523  0.3067
0.5535  0.1424  0.3041
0.554   0.142   0.304
0.5545  0.1416  0.3039
0.555   0.1412  0.3038
0.5555  0.1408  0.3037
0.556   0.1404  0.3036
0.5565  0.14    0.3035
0.557   0.1396  0.3034
0.5575  0.1392  0.3033
0.563   0.1348  0.3022
0.5635  0.1344  0.3021
0.564   0.134   0.302
0.5645  0.1336  0.3019
0.565   0.1332  0.3018
0.5655  0.1328  0.3017
0.566   0.1324  0.3016
0.5665  0.132   0.3015
0.567   0.1316  0.3014
0.578   0.1227  0.2993
0.5785  0.1223  0.2992
0.5845  0.1174  0.2981
0.585   0.117   0.298
0.5895  0.1133  0.2972
0.5935  0.11    0.2965
0.6005  0.1042  0.2953
0.606   0.0996  0.2944
0.6085  0.0975  0.294
0.615   0.092   0.293
0.617   0.0903  0.2927
0.6205  0.0873  0.2922
0.624   0.0843  0.2917
0.6255  0.083   0.2915
0.63    0.0791  0.2909
0.6315  0.0778  0.2907
0.6355  0.0743  0.2902
0.638   0.0721  0.2899
0.6405  0.0699  0.2896
0.645   0.0659  0.2891
0.655   0.0569  0.2881
0.6595  0.0528  0.2877
0.662   0.0505  0.2875
0.6645  0.0482  0.2873
0.666   0.0468  0.2872
0.672   0.0412  0.2868
0.6755  0.0379  0.2866
0.6775  0.036   0.2865
0.682   0.0317  0.2863
0.685   0.0288  0.2862
0.688   0.0259  0.2861
0.6885  0.0254  0.2861
0.6935  0.0205  0.286
0.694   0.02    0.286
0.7035  0.0105  0.286
0.704   0.01    0.286
0.7085  0.0054  0.2861
0.712   0.0018  0.2862
]; 
ternplot(A(:,1),A(:,2),A(:,3))
 
 
A=[0.1505   0.848   0.0015
0.1565  0.8297  0.0138
0.157   0.8282  0.0148
0.1575  0.8267  0.0158
0.1745  0.7778  0.0477
0.1835  0.7535  0.063
0.1895  0.7379  0.0726
0.1915  0.7328  0.0757
0.194   0.7265  0.0795
0.195   0.724   0.081
0.2045  0.7009  0.0946
0.2125  0.6823  0.1052
0.214   0.6789  0.1071
0.216   0.6744  0.1096
0.2225  0.6601  0.1174
0.2245  0.6558  0.1197
0.226   0.6526  0.1214
0.2355  0.6329  0.1316
0.24    0.6239  0.1361
0.2445  0.6151  0.1404
0.247   0.6103  0.1427
0.248   0.6084  0.1436
0.249   0.6065  0.1445
0.256   0.5935  0.1505
0.2615  0.5836  0.1549
0.266   0.5757  0.1583
0.275   0.5604  0.1646
0.2795  0.553   0.1675
0.287   0.541   0.172
0.2945  0.5294  0.1761
0.3005  0.5204  0.1791
0.305   0.5138  0.1812
0.311   0.5052  0.1838
0.316   0.4982  0.1858
0.3165  0.4975  0.186
0.3225  0.4893  0.1882
0.326   0.4846  0.1894
0.331   0.478   0.191
0.332   0.4767  0.1913
0.333   0.4754  0.1916
0.339   0.4677  0.1933
0.3405  0.4658  0.1937
0.347   0.4577  0.1953
0.351   0.4528  0.1962
0.3595  0.4426  0.1979
0.3635  0.4379  0.1986
0.3685  0.4321  0.1994
0.372   0.4281  0.1999
0.3735  0.4264  0.2001
0.375   0.4247  0.2003
0.38    0.4191  0.2009
0.388   0.4103  0.2017
0.3915  0.4065  0.202
0.4005  0.3969  0.2026
0.4045  0.3927  0.2028
0.4095  0.3875  0.203
0.413   0.3839  0.2031
0.4175  0.3793  0.2032
0.4345  0.3623  0.2032
0.435   0.3618  0.2032
0.4435  0.3535  0.203
0.4465  0.3506  0.2029
0.4495  0.3477  0.2028
0.4585  0.3391  0.2024
0.464   0.3339  0.2021
0.4675  0.3306  0.2019
0.469   0.3292  0.2018
0.478   0.3208  0.2012
0.4835  0.3157  0.2008
0.486   0.3134  0.2006
0.491   0.3088  0.2002
0.4935  0.3065  0.2
0.497   0.3033  0.1997
0.506   0.2951  0.1989
0.5135  0.2883  0.1982
0.5145  0.2874  0.1981
0.5395  0.2649  0.1956
0.5405  0.264   0.1955
0.5415  0.2631  0.1954
0.553   0.2528  0.1942
0.554   0.2519  0.1941
0.5635  0.2434  0.1931
0.5645  0.2425  0.193
0.578   0.2304  0.1916
0.579   0.2295  0.1915
0.58    0.2286  0.1914
0.581   0.2277  0.1913
0.595   0.2151  0.1899
0.596   0.2142  0.1898
0.597   0.2133  0.1897
0.6065  0.2047  0.1888
0.6075  0.2038  0.1887
0.613   0.1988  0.1882
0.6175  0.1947  0.1878
0.6305  0.1828  0.1867
0.633   0.1805  0.1865
0.6465  0.168   0.1855
0.648   0.1666  0.1854
0.6495  0.1652  0.1853
0.651   0.1638  0.1852
0.6525  0.1624  0.1851
0.659   0.1563  0.1847
0.6625  0.153   0.1845
0.6745  0.1416  0.1839
0.682   0.1344  0.1836
0.685   0.1315  0.1835
0.692   0.1247  0.1833
0.6965  0.1203  0.1832
0.7035  0.1134  0.1831
0.7175  0.0994  0.1831
0.724   0.0928  0.1832
0.7315  0.0851  0.1834
0.7345  0.082   0.1835
0.737   0.0794  0.1836
0.745   0.071   0.184
0.754   0.0614  0.1846
0.7735  0.04    0.1865
0.7865  0.0252  0.1883
0.789   0.0223  0.1887
0.792   0.0188  0.1892
0.7975  0.0123  0.1902
0.798   0.0117  0.1903
0.803   0.0057  0.1913
]; 
ternplot(A(:,1),A(:,2),A(:,3))
 
A=[0.209    0.7778  0.0132
0.2135  0.7681  0.0184
0.2215  0.7513  0.0272
0.2405  0.7136  0.0459
0.2415  0.7117  0.0468
0.257   0.6832  0.0598
0.282   0.6408  0.0772
0.2825  0.64    0.0775
0.2865  0.6336  0.0799
0.293   0.6234  0.0836
0.299   0.6142  0.0868
0.3075  0.6015  0.091
0.309   0.5993  0.0917
0.3125  0.5942  0.0933
0.315   0.5906  0.0944
0.319   0.5849  0.0961
0.326   0.5751  0.0989
0.33    0.5696  0.1004
0.3325  0.5662  0.1013
0.3345  0.5635  0.102
0.368   0.5205  0.1115
0.374   0.5132  0.1128
0.3745  0.5126  0.1129
0.375   0.512   0.113
0.378   0.5084  0.1136
0.3785  0.5078  0.1137
0.385   0.5001  0.1149
0.3885  0.496   0.1155
0.3955  0.4879  0.1166
0.399   0.4839  0.1171
0.41    0.4715  0.1185
0.4165  0.4643  0.1192
0.4175  0.4632  0.1193
0.424   0.4561  0.1199
0.433   0.4464  0.1206
0.4345  0.4448  0.1207
0.436   0.4432  0.1208
0.4565  0.4217  0.1218
0.4635  0.4145  0.122
0.468   0.4099  0.1221
0.4745  0.4033  0.1222
0.4975  0.3803  0.1222
0.505   0.3729  0.1221
0.5105  0.3675  0.122
0.515   0.3631  0.1219
0.523   0.3553  0.1217
0.5415  0.3374  0.1211
0.552   0.3273  0.1207
0.5545  0.3249  0.1206
0.564   0.3158  0.1202
0.571   0.3091  0.1199
0.5755  0.3048  0.1197
0.58    0.3005  0.1195
0.5845  0.2962  0.1193
0.6115  0.2704  0.1181
0.6235  0.2589  0.1176
0.626   0.2565  0.1175
0.6365  0.2464  0.1171
0.662   0.2217  0.1163
0.666   0.2178  0.1162
0.6705  0.2134  0.1161
0.682   0.2021  0.1159
0.6915  0.1927  0.1158
0.692   0.1922  0.1158
0.709   0.1752  0.1158
0.7095  0.1747  0.1158
0.718   0.1661  0.1159
0.728   0.1559  0.1161
0.755   0.1278  0.1172
0.779   0.102   0.119
0.794   0.0854  0.1206
0.798   0.0809  0.1211
0.812   0.0649  0.1231
0.839   0.0327  0.1283
0.8495  0.0196  0.1309
0.851   0.0177  0.1313
]; 
ternplot(A(:,1),A(:,2),A(:,3))
 
A=[0.277    0.7135  0.0095
0.283   0.7038  0.0132
0.2835  0.703   0.0135
0.2985  0.6796  0.0219
0.306   0.6683  0.0257
0.319   0.6493  0.0317
0.3225  0.6443  0.0332
0.3365  0.6248  0.0387
0.3505  0.606   0.0435
0.355   0.6001  0.0449
0.358   0.5962  0.0458
0.3665  0.5853  0.0482
0.368   0.5834  0.0486
0.3805  0.5678  0.0517
0.393   0.5526  0.0544
0.3935  0.552   0.0545
0.4025  0.5413  0.0562
0.4095  0.5331  0.0574
0.412   0.5302  0.0578
0.4165  0.525   0.0585
0.4235  0.517   0.0595
0.428   0.5119  0.0601
0.4435  0.4946  0.0619
0.4445  0.4935  0.062
0.4455  0.4924  0.0621
0.4465  0.4913  0.0622
0.4475  0.4902  0.0623
0.4665  0.4696  0.0639
0.4755  0.46    0.0645
0.4825  0.4526  0.0649
0.4905  0.4442  0.0653
0.513   0.4209  0.0661
0.517   0.4168  0.0662
0.5215  0.4122  0.0663
0.5425  0.3909  0.0666
0.5885  0.3449  0.0666
0.603   0.3305  0.0665
0.6155  0.3181  0.0664
0.6285  0.3052  0.0663
0.644   0.2898  0.0662
0.6445  0.2893  0.0662
0.683   0.2508  0.0662
0.6835  0.2503  0.0662
0.7075  0.226   0.0665
0.7125  0.2209  0.0666
0.7335  0.1993  0.0672
0.7435  0.1889  0.0676
0.7625  0.1689  0.0686
0.794   0.1349  0.0711
0.795   0.1338  0.0712
0.796   0.1327  0.0713
0.815   0.1115  0.0735
0.818   0.1081  0.0739
0.823   0.1024  0.0746
0.829   0.0955  0.0755
0.8575  0.0617  0.0808
0.8645  0.0531  0.0824
0.869   0.0475  0.0835
0.8725  0.0431  0.0844
0.8925  0.0172  0.0903
0.894   0.0152  0.0908
0.9 0.0071  0.0929
]; 
ternplot(A(:,1),A(:,2),A(:,3))
 
A=[0.3735   0.6242  0.0023
0.3795  0.6166  0.0039
0.3975  0.5943  0.0082
0.432   0.5534  0.0146
0.438   0.5465  0.0155
0.4415  0.5425  0.016
0.4505  0.5323  0.0172
0.4605  0.5211  0.0184
0.478   0.5018  0.0202
0.496   0.4823  0.0217
0.5045  0.4732  0.0223
0.506   0.4716  0.0224
0.5175  0.4594  0.0231
0.523   0.4536  0.0234
0.525   0.4515  0.0235
0.529   0.4473  0.0237
0.5355  0.4405  0.024
0.5505  0.4249  0.0246
0.566   0.4089  0.0251
0.5815  0.393   0.0255
0.5905  0.3838  0.0257
0.5955  0.3787  0.0258
0.6185  0.3553  0.0262
0.6315  0.3421  0.0264
0.645   0.3284  0.0266
0.6515  0.3218  0.0267
0.664   0.3091  0.0269
0.6755  0.2974  0.0271
0.72    0.2518  0.0282
0.723   0.2487  0.0283
0.734   0.2373  0.0287
0.7365  0.2347  0.0288
0.7435  0.2274  0.0291
0.752   0.2185  0.0295
0.754   0.2164  0.0296
0.783   0.1856  0.0314
0.787   0.1813  0.0317
0.7895  0.1786  0.0319
0.792   0.1759  0.0321
0.8205  0.1446  0.0349
0.837   0.126   0.037
0.8465  0.1151  0.0384
0.8515  0.1093  0.0392
0.8585  0.1011  0.0404
0.8655  0.0928  0.0417
0.872   0.085   0.043
0.882   0.0728  0.0452
0.891   0.0616  0.0474
0.897   0.054   0.049
0.8995  0.0508  0.0497
0.9095  0.0378  0.0527
0.9335  0.005   0.0615
]; 
ternplot(A(:,1),A(:,2),A(:,3))
 
A=[0.8055   0.1944  0.0001
0.811   0.1885  0.0005
0.8175  0.1815  0.001
0.8235  0.175   0.0015
0.851   0.1447  0.0043
0.8655  0.1283  0.0062
0.8795  0.1121  0.0084
0.913   0.0714  0.0156
0.9245  0.0566  0.0189
0.9345  0.0433  0.0222
0.961   0.0057  0.0333
]; 
ternplot(A(:,1),A(:,2),A(:,3))

    函数ternplot是一个自编函数程序包,看似用上去很方便,如果要求不高,当然可以用该函数,有于函数很多都采用默认设置,绘制出来的图像并不是很好看,所以过冷水在往期文章给大家详细讲了三元相图绘制原理,也根据原理绘制了图像。过冷水建议大家多尝试自编函数绘制三元相图,而不是用一些列子函数来绘制,子函数图像灵活性较差。在实际应用中我们希望三元相图表现能够更加丰富一点,最好能够完美绘制出入下图右侧所示彩色图,

image.png 

其实彩色图也可以用封装函数进行一步绘制

load date.mat
ternsurf(row,rank,ss')

image.png 

    如果就这么简单,过冷水也没有什么好说的了,过冷水就是嫌绘制图过程中每次都是使用程序包函数ternsurf这不是Matlab自带函数,如果没有这个程序包,是绘制不出来图像的。过冷水查看了ternsurf函数后,觉得程序没有那么复杂完全可以实现自己编程,所以过冷水就和大家分享一下我是怎么绘制出这幅图的。

Load data.mat%导入绘图数据
Rank:横坐标网格
Row:纵坐标
ss:Z值

%通常绘图

[ROW,RANK]=meshgrid(row,rank);
figure 
hold on
pcolor(ROW,RANK,ss);
ylabel('$x$','FontSize',30,'Interpreter','latex');
xlabel('$y$','FontSize',30,'Interpreter','latex');
colorbar
shading interp

image.png 

我们要绘制的三元图,首先的生成三个变量

A=row;B=rank;
C = 1 - (A B);
Z=ss';

进行坐标转换

Total = (A B C);
fA = A./Total;fB = B./Total;fC = 1-(fA fB);
y = fC*sin(deg2rad(60))
x = 1 - fA - y*cot(deg2rad(60))
[x, i] = sort(x);
y = y(i);

对转化后的数据进行重新由小到大进行排序

[x, i] = sort(x);
y = y(i);
Z = Z(i);

生成对应的网格化,

N = majors 1;
Ar = linspace(min(fA), max(fA), N);
Br = linspace(min(fB), max(fB), N);
[Ag, Bg] = meshgrid(Ar, Br)


这样的一个网格化数据并不符合Ag Bg Cg=1,需要对网格化数据转化到三角坐标系中

Cg = 1 - (Ag   Bg);
yg = Cg*sin(deg2rad(60));
xg = 1 - Ag - yg*cot(deg2rad(60));

在新生成的一个网格数据中映射(row;rank;ss'数据zg就相当于转化的ss

zg = griddata(x, y, Z, xg, yg,'v4');

对Zg网格化数据不符合要去的进行重新赋值,因为在生成的表格中存在Ar Br>1的情况,我们可知,实际网格化数据不存在Ar Br这样的情况的。如果不进行处理得到是这么一副图,四边形,这是因为网格化自然是一个四边形

zg(Ag   Bg > 1) = nan;


image.png 

        设置三角坐标系完成了图形绘制数据处理工作,现在就需要绘制对应的三元坐标系,三元坐标系的绘制,由于比较复杂,就不进行详细讲解,只在这里给出详细程序,

image.png 

direction = 'clockwise';
percentage = false;
xoffset = 0.25;
yoffset = 0.01;
 
cax = newplot;
next = lower(get(cax,'NextPlot'));
hold_state = ishold;
tc = get(cax,'xcolor');
ls = get(cax,'gridlinestyle');
fAngle  = get(cax, 'DefaultTextFontAngle');
fName   = get(cax, 'DefaultTextFontName');
fSize   = get(cax, 'DefaultTextFontSize');
fWeight = get(cax, 'DefaultTextFontWeight');
fUnits  = get(cax, 'DefaultTextUnits');
 
set(cax, 'DefaultTextFontAngle',  get(cax, 'FontAngle'), ...
         'DefaultTextFontName',   get(cax, 'FontName'), ...
         'DefaultTextFontSize',   get(cax, 'FontSize'), ...
         'DefaultTextFontWeight', get(cax, 'FontWeight'), ...
         'DefaultTextUnits','data')
hold on;
plot ([0 1 0.5 0],[0 0 sin(1/3*pi) 0], 'color', tc, 'linewidth',1,'handlevisibility','off');
set(gca, 'visible', 'off');
patch('xdata', [0 1 0.5 0], 'ydata', [0 0 sin(1/3*pi) 0],'edgecolor',tc,'facecolor',get(gca,'color'),'handlevisibility','off');
majorticks = linspace(0, 1, 10   1); 
majorticks = majorticks(1:end-1);
multiplier = 1;
labels = num2str(majorticks(end:-1:1)'*multiplier);
zerocomp = zeros(size(majorticks)); % represents zero composition
[lxc, lyc] = terncoords(1-majorticks, majorticks, zerocomp);
text(lxc 0.05, lyc-0.025, [repmat('  ', length(labels), 1) labels]);
[lxb, lyb] = terncoords(majorticks, zerocomp, 1-majorticks); % fB = 1-fA
text(lxb-0.115, lyb-0.065, labels, 'VerticalAlignment', 'Top');
[lxa, lya] = terncoords(zerocomp, 1-majorticks, majorticks);
text(lxa-0.035, lya 0.09, labels);
nlabels = length(labels)-1;
for i = 1:nlabels
        plot([lxa(i 1) lxb(nlabels - i   2)], [lya(i 1) lyb(nlabels - i   2)], ls, 'color', tc, 'linewidth',0.25,...
           'handlevisibility','off');
        plot([lxb(i 1) lxc(nlabels - i   2)], [lyb(i 1) lyc(nlabels - i   2)], ls, 'color', tc, 'linewidth',0.25,...
           'handlevisibility','off');
        plot([lxc(i 1) lxa(nlabels - i   2)], [lyc(i 1) lya(nlabels - i   2)], ls, 'color', tc, 'linewidth',0.25,...
           'handlevisibility','off');
end;
 
% Reset defaults
set(cax, 'DefaultTextFontAngle', fAngle , ...
    'DefaultTextFontName',   fName , ...
    'DefaultTextFontSize',   fSize, ...
    'DefaultTextFontWeight', fWeight, ...
    'DefaultTextUnits', fUnits );

绘图数据我们已经有了,对应的坐标系也有了使用trisurf函数(程序自带)绘制三维图像就可以了

[row1, col] = meshgrid(1:N-1);
bl = sub2ind([N, N], row1, col);
bl = bl(:);
br = bl   1;
tl = bl   N;
tr = tl   1;
tri = [tl bl br; tl tr br];
handle = trisurf(tri, xg, yg, zg);
view([-37.5, 30]);

image.png 

过冷水完整给出了相图绘制命令,往期过冷水给出了三元相图线性图,本期三元彩色图,学会这两个,三元相图的绘制就完全学会了。大家在细节如果有什么不懂,欢迎大家留言讨论。

附件

20积分data.zip
网格处理代码&命令MATLAB
著作权归作者所有,欢迎分享,未经许可,不得转载
首次发布时间:2021-12-19
最近编辑:5月前
过冷水
博士 | 讲师 讨论号:927550334
获赞 361粉丝 184文章 107课程 11
点赞
收藏
作者推荐
未登录
1条评论
卡皮巴拉爱睡觉
签名征集中
5月前
大神能求一下具体代码嘛
回复
课程
培训
服务
行家
VIP会员 学习 福利任务 兑换礼品
下载APP
联系我们
帮助与反馈