1D plot with exciting colours
Mostra commenti meno recenti
Hi there,
I have quite a simple question, simple because I'm sure Matlab can do this easily, I just don't know how.
I want to plot some 1D data - in this case my data is a change in voltage over time. But instead of a plain line plot I want a plot where the space below the line is filled with colour. I don't really care what the colours correspond to, whether it is on a spectrum so that high voltage is coloured red and low is blue, or whether whole sections under high voltage peaks are coloured red (like a spectrogram) I would just like a visually appealing plot that uses some colour map; like this one:

Although I understand that my data are no where near as detailed as this example.
Thanks for any help,
Rod.
EDIT:
As suggested, here are links to my data files...
2 Commenti
Doug Hull
il 6 Set 2013
This does not look like a 1-d plot to me, it looks like an image. What is the shape (vector, matrix, 3-d matrix) of the data you are trying to visualize?
Right Grievous
il 7 Set 2013
Risposta accettata
Più risposte (1)
A Jenkins
il 6 Set 2013
I am going to assume you have a 1d vector for time and a 1d vector for voltage. If not, then please answer Doug's comment above.
Otherwise, try this:
% provide 2 arrays for your time and voltage signals
xdata=1:0.1:10; %x axis data (array of time series)
zdata=1./xdata; %z axis data (array of voltage signals)
ydata=0:max(zdata)/100:max(zdata);
[xaxis,yaxis]=meshgrid(xdata,ydata);
zaxis=repmat(zdata,length(ydata),1);
x=reshape(xaxis,1,[]);
y=reshape(yaxis,1,[]);
z=reshape(zaxis,1,[]);
scatter3(x,y,(z>y),100,255*(z>y),'filled');
view(0,90);
14 Commenti
Image Analyst
il 6 Set 2013

Right Grievous
il 7 Set 2013
A Jenkins
il 7 Set 2013
If I understand your above statement correctly, you are using MATLAB's spectrogram() function. This function should create an 'exciting' plot for you - just call it without an output.
spectrogram(...,...)
instead of
s=spectrogram(...,...)
Right Grievous
il 7 Set 2013
Ok, I'm still not sure I understand what you want, but I had fun drawing this, so I will post it here anyway.
1) I changed the color axis to give your gradient
2) I'm using the surf() command as an alternative to scatter3().
% provide 2 arrays for your time and voltage signals
xdata=1:0.1:10; %x axis data (array of time series)
zdata=1./xdata; %z axis data (array of voltage signals)
ydata=0:max(zdata)/100:max(zdata);
[xaxis,yaxis]=meshgrid(xdata,ydata);
zaxis=repmat(zdata,length(ydata),1);
coloraxis=255*(zaxis>yaxis).*(zaxis-yaxis)./zaxis;
surf(xaxis,yaxis,coloraxis, 'EdgeColor', 'none');
view(0,90);

Right Grievous
il 8 Set 2013
Image Analyst
il 8 Set 2013
How can they fix it if you don't give your data?
A Jenkins
il 8 Set 2013
You can use the size() command on each of the matricies to see the dimensions to determine which ones don't agree. For example, your xdata and zdata should match, and your yaxis and zaxis should match.
size(xdata)
size(zdata)
Right Grievous
il 8 Set 2013
Modificato: Right Grievous
il 8 Set 2013
Image Analyst
il 8 Set 2013
Looks like a mess to me, but if you're happy with it, then whatever....
Right Grievous
il 8 Set 2013
Modificato: Right Grievous
il 8 Set 2013
Right Grievous
il 8 Set 2013
Image Analyst
il 8 Set 2013
That sounds like a good approach if you can get it working.
Right Grievous
il 8 Set 2013
Modificato: Right Grievous
il 8 Set 2013
Categorie
Scopri di più su Color and Styling in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!