how to use hold on for two different imagesc plots
조회 수: 23 (최근 30일)
이전 댓글 표시
I have a matrix like below and want to find imagesc(); hold on; imagesc();
t1 = [1 2 3 6 7];
E1 = [-0.00660786358639598 0.0777130350470543 0.126017674803734 0.189686760306358 0.262237429618835]
fx1 = [5.6157475 5.5697780 5.5289726 5.4838061 5.4012895
5.5453439 5.4993744 5.5572557 5.5120893 5.5418348
5.6823254 5.6363554 5.5536976 5.5085306 5.4978499
5.3619905 5.3160210 5.6277847 5.5826178 5.5214615
5.5157361 5.4697666 5.4811044 5.4359379 5.4907508]
t2 = [4 5 8 9 10];
E2 = [1.39749240875244 1.44495928287506 1.49170267581940 1.53834557533264 1.58445668220520];
fx2 = [5.5889688 5.5429993 5.5185990 5.4734325 5.4242330
5.4456487 5.3996792 5.7355318 5.6903653 5.4353333
5.7974424 5.7514729 5.3296890 5.2845225 5.5169930
5.6018438 5.5558739 5.2609043 5.2157373 5.5721898
5.5223360 5.4763665 5.6631050 5.6179385 5.3880172]
imagesc(E1,t1,fx1); % shading flat
hold on;
imagesc(E2,t2,fx2); % shading flat
view([270 90]);
however, the o/p to this imagesc plot is very vague with misoverlaps.
Can anyone please help.
댓글 수: 0
답변 (1개)
Walter Roberson
2021년 2월 16일
편집: Walter Roberson
2021년 2월 16일
t1 = [1 2 3 6 7];
E1 = [-0.00660786358639598 0.0777130350470543 0.126017674803734 0.189686760306358 0.262237429618835];
fx1 = [5.6157475 5.5697780 5.5289726 5.4838061 5.4012895
5.5453439 5.4993744 5.5572557 5.5120893 5.5418348
5.6823254 5.6363554 5.5536976 5.5085306 5.4978499
5.3619905 5.3160210 5.6277847 5.5826178 5.5214615
5.5157361 5.4697666 5.4811044 5.4359379 5.4907508];
t2 = [4 5 8 9 10];
E2 = [1.39749240875244 1.44495928287506 1.49170267581940 1.53834557533264 1.58445668220520];
fx2 = [5.5889688 5.5429993 5.5185990 5.4734325 5.4242330
5.4456487 5.3996792 5.7355318 5.6903653 5.4353333
5.7974424 5.7514729 5.3296890 5.2845225 5.5169930
5.6018438 5.5558739 5.2609043 5.2157373 5.5721898
5.5223360 5.4763665 5.6631050 5.6179385 5.3880172];
imagesc(E1,t1,fx1); % shading flat
hold on;
imagesc(E2,t2,fx2); % shading flat
xlim([-.1 1.7]); ylim([0 11])
view([270 90]);
Remember, when you use hold on, you "hold" the automatic determination of the axes limits according to the plotted data.
댓글 수: 2
Walter Roberson
2021년 2월 16일
The current documentation for the x and y coordinates only defines passing a scalar or a two-element vector for position.
Historically there is documentation somewhere that if you pass in a vector of values with more than one element, then it uses the first and last elements of the vectors and ignores the rest.
You do not pass in coordinates for the center of each pixel, only information about the centers of the lower left and upper right corners. MATLAB has never permitted you to pass in a vector of values for the centers of each column individually.
What MATLAB does offer is pcolor(), which permits you to pass in positions about the vertices of each face of a surface, with the color of the face being taken by interpolation from the data associated with its four corners. pcolor() however does not put in gaps: it fills the color in for the entire face rectangular face.
참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!