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