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.

 Accepted Answer

(This is a continuation of a discussion going back several weeks.)
You can use the stem3 (or scatter3) plot to plot the histogram output, and you can colour the markers individually. (The plot doesn’t care a whit where the data came from.) However in the histogram, you are binning and counting several galaxies that have nothing more in common than sharing similar declinations and right-ascensions, and want to depict the morphology as the ‘fourth dimension’ (marker shape and colour).
I know virtually nothing about astronomy, but if apples, oranges, and bananas all shared the same declination and right-ascension, how would you depict the colour of the marker (the ‘fourth dimension’)? Red? Orange? Yellow?

6 Comments

Because every declination and right ascension are a pair of 'coordinates' that all individually have a morphology (type) linked to them. For example, (from GWGCCatalogrm.txt)
10001|UGC02130|2.64010|7.99292|2.7|14.00|0.830|0.267|0.257|~|0.31|0.036|~|-20.80|89.375|13.406|0.37|0.38|
This is the first line of the text file, and it represents one galaxy. This galaxy has a corresponding right ascension, declination, and morphology type. This would be considered one 'point'.
Now, the scale for the coloring would correspond to values from '-6' to '+10' with a jet color scheme. What I mean is that I would like the same stem3 plot produced, except it should take into account the morphology by recognizing the morphological type linked to a set of coordinates and categorizing each point with a color associated to the morphological scale.
I had drafted a very rough 2D plot of this (attached), but it was very messy and not very useful in terms of visual aid.
I hope I was clear. If you have any idea of where to start, that would be great.
We seem to be talking about two different things.
I understand about colouring the galaxy markers (each galaxy defined by its unique RA and DEC, and not binned) according to some variable with 17 levels (although I don’t know what that variable is, so I can’t put it in the plot).
That is different from binning galaxies who may not share the colouring characteristics parameters, but happen to have similar enough RA and DEC to be binned together. How would you colour them? Or would that even be a valid plot? I understand if you wanted to plot densities that would be appropriate, since I doubt they’re uniformly distributed in the sky, but by binning them they would lose their individual identities.
I need to know what you want to do. The point is that you can’t bin them and have them retain their individual identities, but if you want them to retain their individual identities, you can colour them according to your other parameter. That parameter can define both their height and colour.
jgillis16
jgillis16 on 5 Jul 2015
Edited: jgillis16 on 5 Jul 2015
The variable will be column 5 in GWGCCatalogrm.txt. So, perhaps M1(:,5)...?
Ok. I understand where you are coming from.
The general picture in my mind is the distribution of these galaxies according to their respective provided positions with the galaxy color markers imposed onto them. So, we would see all the galaxies with differing colors that depend on the morphology number provided. What I need to see is where the clustering of the same morphology types are, and overall, where the basic spread of the types of galaxies are . That is why I am trying to impose the color parameter on the stem3 (or even scatter3) plot.
So, perhaps it is best to go along the lines of demonstrating galactic densities within the plot instead of 'binning' them since we want them individualized and retain their individual identities .
Append this to the end of the code you posted:
cm = flipud(colormap(jet(26)));
Z3stem = cell2mat(cellfun(@str2num, M1{5}, 'Uni',0))+6;
X3stem = GalList.ra(1:length(Z3stem));
Y3stem = GalList.dec(1:length(Z3stem));
sct3ms = ones(size(Z3stem))*4.0;
RangeM15 = [min(Z3stem); max(Z3stem)];
figure(3)
hst3 = stem3(X3stem, Y3stem, Z3stem);
set(hst3, 'MarkerSize', 4.0)
hold on
hsc3 = scatter3(X3stem, Y3stem, Z3stem, sct3ms, cm(fix(Z3stem),:), 'Filled');
hold off
grid on
The number of data you have are simply not compatible with depicting them clearly with the stem3 or scatter3 plots. Usually, it’s possible to change the stem and marker colours using a for loop, but with 25673 data, that takes an impossibly long time. (I tried it and gave up.) So I decided to hybridise stem3 and scatter3 with some success.
Also, M1{5} turns out to have 26 levels, not 17, so I changed ‘cm’ to reflect that. (That’s the purpose of ‘RangeM15’ that is not otherwise necessary for the code.)
You might want to experiment with this to get the result you want. It works, but not as well as I’d like, largely because of the number of data you want to plot.
OK. I am going to play around with this today to see if I can get it to represent what I want. But, yes. This is roughly what I was looking for! Now, the problem is to get it to visually represent the data in correct astronomical terms. But, I will work on it and update you once I have the correct format (if you want).
Thank you again!
I would appreciate the update, not only because I’m still doing my best to understand what analysis you’re doing, but because I want to see what you actually want.
Also, it it’s not too sensitive (I understand you wouldn’t want to discuss your research in detail), what hypothesis are you testing?

Sign in to comment.

More Answers (1)

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

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!