MATLAB Answers

Create a 4D graphic with the function plotmatrix

조회 수: 2(최근 30일)
Hello, I have the following information that has by columns the components X,Y,Z and the information to represent in the fourth column:
data = [26.2500000000000,10,20,0.000432113572874648;32.5000000000000,10,30,0.000113660965880058;38.7500000000000,10,30,0.00144840712375238;38.7500000000000,10,40,2.82213642366358e-06;45,10,30,0.00671528961126988;45,10,40,0.000460445802102694;45,20,30,0.000352579008291443];
What I want to achieve is to be able to represent it similarly to what is shown in the documentation of matlab but so that each component always has the same color and different from the rest, ie the position X = 26.25 with value = 0.0004 has for example blue and that Y = 10 with value = 0.0004 is also blue as well as Z = 20 and value 0.0004 exactly the same, but when representing the value of the second row go to another different color
I someone knows how to do it with another function is algo nice for me! Thank you so much :D

채택된 답변

Amanpreetsingh Arora
Amanpreetsingh Arora 17 Nov 2020
Unfortunately, "plotmatrix" does not support this "scatter" like functionality as it uses "plot" and "histogram" internally to generate plots. I work with MathWorks Technical Support and I have forwarded an enhancement request for this functionality to the developers.
As a workaround, you can modify "plotmatrix" for your workflow. You can open "plotmatrix" using the following command.
edit plotmatrix
Copy the contents of this file to a new M file in your working directory and let's call it "plotmatrix_custom". Line 153 of this function calls "plot" which generates off diagonal plots in the final figure. Modify this line to call "scatter" as follows.
hh(i,j,:) = scatter(reshape(x(:,j,:),[m k]), ...
reshape(y(:,i,:),[m k]),markersize*ones(m,1),1:m,'filled','parent',ax(i,j))';
This will generate plots with the desired functionality. Note that the fourth argument (1:m) provides individual colors to each datapoint. Also, comment out line 155 in order to avoid error as scatter plots do not have 'markersize' property. For more information on "scatter", refer to the following documentation.
Then use the custom function "plotmatrix_custom" instead of "plotmatrix" to generate the desired plots.

추가 답변(0개)




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by