Applying a fourth variable to a stem3 plot
이전 댓글 표시
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.
채택된 답변
추가 답변 (1개)
Gareth Thomas
2015년 7월 5일
0 개 추천
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
카테고리
도움말 센터 및 File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!