3D Box Plotting

조회 수: 9 (최근 30일)
Devin
Devin 2011년 4월 23일
I'm trying to plot a few boxes in 3D, my axes are time, frequency, and power. So far I have this:
freqs = 50:10:500;
times = linspace(0,10, length(freqs));
[X,Y] = meshgrid(freqs, times);
Z = zeros(size(X));
Z(5:10, 5:10) = 1; % signal 1
Z(5:35, 30:35) = 1; % signal 2
surf(X,Y,Z);
So far signals are only colored red at the peak of each one. Everywhere else, including the ascent, is blue. How can I make the ascent red. Also is possible to make them a different color?

답변 (2개)

Andrew Newell
Andrew Newell 2011년 4월 24일
For red color, use
colormap([1 0 0])
If by making them a different color you mean the whole plot, you could substitute [0 1 0] for green, etc. (see Colorspec).

Matt Fig
Matt Fig 2011년 4월 24일
I don't know what you mean by "the ascent." But you could look around at the properties of the surface object and see if setting them to different colors gives what you want...
S = surf(X,Y,Z);
get(S) % List the properties, use SET to set the properties...
Also, you might consider using patch objects instead, depending on what you are trying to do with your boxes. See this file for example...
  댓글 수: 1
Devin
Devin 2011년 4월 24일
So Z only has values that are between 0 and 1, but when I plot it using surf that values in between 0 and 1 (where the values in Z change from 0 to 1) get colored blue.

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

카테고리

Help CenterFile Exchange에서 Color and Styling에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by