3D Box Plotting

9 visualizaciones (últimos 30 días)
Devin
Devin el 23 de Abr. de 2011
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?

Respuestas (2)

Andrew Newell
Andrew Newell el 24 de Abr. de 2011
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 el 24 de Abr. de 2011
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 comentario
Devin
Devin el 24 de Abr. de 2011
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.

Iniciar sesión para comentar.

Categorías

Más información sobre Color and Styling en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by