Hi everyone! I need to create a 2D plot where the elements that are at z = 1 must be at the same level of the elements at x and y but these elements along z must be highlighted against the background on x and y in order to be distinguished. How can I do it?

댓글 수: 1

Where are the data?
Uz = unzip('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1009395/Prova_test.zip');
Uz2 = [num2cell((1:numel(Uz))') Uz']
Uz2 = 120×2 cell array
{[ 1]} {'Prova_test/codice_opcode.asv' } {[ 2]} {'Prova_test/codice_opcode.m' } {[ 3]} {'Prova_test/Scenari/' } {[ 4]} {'Prova_test/Scenari/Nuovascena.stl' } {[ 5]} {'Prova_test/Subfunctions/' } {[ 6]} {'Prova_test/Subfunctions/matlab/' } {[ 7]} {'Prova_test/Subfunctions/matlab/deer.ply' } {[ 8]} {'Prova_test/Subfunctions/matlab/opcodemesh.m' } {[ 9]} {'Prova_test/Subfunctions/matlab/opcodemeshdemo.m' } {[10]} {'Prova_test/Subfunctions/matlab/opcodemeshmex.mexw64'} {[11]} {'Prova_test/Subfunctions/matlab/read_ply2.m' } {[12]} {'Prova_test/Subfunctions/opcode/' } {[13]} {'Prova_test/Subfunctions/opcode/CMakeLists.txt' } {[14]} {'Prova_test/Subfunctions/opcode/Ice/' } {[15]} {'Prova_test/Subfunctions/opcode/Ice/IceAABB.cpp' } {[16]} {'Prova_test/Subfunctions/opcode/Ice/IceAABB.h' }
.

댓글을 달려면 로그인하십시오.

 채택된 답변

Cris LaPierre
Cris LaPierre 2022년 5월 24일

1 개 추천

The solution likely varies depending on your data, but I would probably first look into using imagesc:
This way, the difference in Z is captured in the color displayed in the figure.
imagesc(new_x,new_y,hit);

댓글 수: 6

Loren99
Loren99 2022년 5월 24일
@Cris LaPierre I've just tried as you can see from the following figure but it is not okay because I want the shapes at z=1 to be reproduced on the x, y plane. Maybe is there a command that in scatter3 allows me to highlight the elements at z=1 with a different color with respect to x and y elements at z=0? Then I can apply view (0,90) to see the resulting map from the top
Cris LaPierre
Cris LaPierre 2022년 5월 24일
편집: Cris LaPierre 2022년 5월 24일
It's hard to give anything specific without having your data. Consider saving your variables to a mat file and attaching that file to your post using the paperclip icon.
Loren99
Loren99 2022년 5월 24일
편집: Loren99 2022년 5월 24일
@Cris LaPierre I cannot save the variables to a mat file because of their huge dimension. However I have attached a zip file with the main called 'codice_opcode'
Cris LaPierre
Cris LaPierre 2022년 5월 24일
편집: Cris LaPierre 2022년 5월 24일
Ok, I see. I'll have to look more into imagesc, but the simplest approach for now might be to use gscatter, assuming hit is just 0 or 1
gscatter(new_x,new_y,hit);
Edit: Looked more
For an image, your data should be an array, not a vector. Use reshape to convert hit into a 12001x14001 array, and then use imagesc to view it. This is quicker than using scatter, both in creating and saving.
Ihit = reshape(hit,size(Z));
imagesc(Ihit);
axis xy
Loren99
Loren99 2022년 5월 24일
@Cris LaPierre thank you very much for both the methods! Just a curiosity. In gscatter, is there a way to not plot the legend as well? because I need the clean image
Cris LaPierre
Cris LaPierre 2022년 5월 24일
편집: Cris LaPierre 2022년 5월 24일
Yes. Use this syntax, where doleg is either 'on' or 'off'.
gscatter(x,y,g,clr,sym,siz,doleg)
You can't skip an input, so your code might look like this (empty brackets uses the default value)
gscatter(new_x,new_y,hit,[],[],[],'off');
You can explore these and other optional inputs in the linked documentation page.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

제품

릴리스

R2021b

질문:

2022년 5월 24일

편집:

2022년 5월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by