Applying a fourth variable to a stem3 plot
Mostrar comentarios más antiguos
I am trying to impose a fourth variable on a stem3 plot. I currently have two position variables, and the third variable is a binning of how many objects are in one 'square degree'. My fourth variable is supposed to link directly to the first and second variables (position variables) by corresponding a specific numerical value to each set of two position variables. The purpose of the fourth variable is to introduce colors (similar to the jet color scheme) that corresponds to each individual value of the fourth variable. For example, if the two position variables have a negative number as the fourth variable, the color displayed in the plot is more red than if the two variables had a positive number as the fourth variable (for then the color in the plot should be more blue).
Below is the code so far:
fid = fopen( 'GWGCCatalogrm.txt');
%trashLine = fgets(fid); %Skips the first line
data = textscan(fid, '%f%s%f%f%s%f%f%f%f%f%f%f%f%f%f%f%f%f', 'Delimiter', '|', 'TreatAsEmpty','~');
fclose(fid);
M1=data;
GalList.pgc = data{1};
GalList.name = data{2};
GalList.ra = data{3};
GalList.dec = data{4};
GalList.major = data{7};
GalList.abs_mag = data{14};
GalList.dist = data{15};
GalList.mass =(10.^( (-20.8 - GalList.abs_mag)./ 2.5 )) ; % Converts Absolute Magnitude into (blue luminosity) mass in units of Milky Way (luminosity) mass (how many potential forming stars in region using the blue luminosity which is rough estimate of mass).
GalList.ra = GalList.ra.*15;
GalList.dec = GalList.dec ;
GalaxyList = GalList;
C1 = GalList.ra;
S1 = GalList.dec;
C12 = round(C1);
S12 = round(S1);
A = accumarray([C12+1, S12+90], 1);
A = A(1:360, :);
A(A==0)=NaN;
cm = flipud(colormap(jet(17)));
c = cell2mat(cellfun(@str2num, data{5}, 'Uni',0))+7; % Define Colour References
[S12M,C12M] = meshgrid([-89:89], [-0:359]);
figure(1)
mesh(S12M, C12M, A)
axis tight
veclens = [size(C12M(:)); size(S12M(:)); size(A(:))]; % Check Vector Lengths
figure(2)
stem3(C12M(:), S12M(:), A(:), '.')
axis tight
Attached is the text file I am working off of.
Respuesta aceptada
Más respuestas (1)
Gareth Thomas
el 5 de Jul. de 2015
0 votos
Hi,
I am not sure if you have seen on MATLAB Examples the following entry:
This could be a good starting point to solve your question.
Gareth
Categorías
Más información sobre 2-D and 3-D Plots en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!