0

I can do a simple pcolor or imagesc plot where

 dec=-90:1:90;
 ra=180:-1:-180;
 mydata=rand(181,361);
 imagesc(ra,dec,mydata)

how do I plot this with a mollweide projection using matlab?

I can do it in python quite easily, but the mapping functions in Matlab are not clear to me what I'm supposed to do.

My real data is not random, but the random data was easiest to generate here.

2
  • 1
    I always use m_map for mapping. it is quite straightforward
    – shamalaia
    Jul 20, 2018 at 23:07
  • Everything is straightforward once you know how to do it. I am now reading up on m_map. Jul 21, 2018 at 23:40

2 Answers 2

0

OK, thanks to shamalaia for pointing me to m_map, which contains m_pcolor.

 figure(1);clf(1);
 dec=-90:1:90;
 ra=180:-1:-180;
 mydata=rand(181,361);
 m_proj('mollweide','clongitude',0);
 obj=m_pcolor(ra,dec,mydata); 
 shading interp; 
 m_grid('xaxislocation','middle','xtick',8,'ytick',7,'fontsize',7,'color','white');

 mymap=colormap('jet');
 colormap(mymap);
 h=colorbar('h');
 caxis([0 1]);

enter image description here

0

Using Matlab's mapping commands - This does seem less intuitive than m_map.

Note: to use this code on the above example, set moonalbrefvec(1)=1;enter image description here

I didn't like the labels produced, so I made my own.

clear;
figure(2); clf(2);
load moonalb % a 540x1080 matrix of values is loaded along with moonalbrefvec=[3;90;0]
moonalbrefvec(1)=3; % this is the subdivisions per degree - thus 180*3=540 & 3*360=1080
moonalbrefvec(2)=90; % NW lat value
moonalbrefvec(3)=180; % NW long value
mymap=colormap('jet'); mymap(1,1:3)=1;colormap(mymap);
axesm('MapProjection','mollweid','MapLatLimit',[-90 90],'Gcolor','white','GLineWidth',2.0,'MLineLocation',[-135 -90 -45 0 45 90 135],'PLineLocation',30) ; 
axis off;caxis([0 500]); 
grid on;
plabel('LabelFormat','none');
mlabel('on');
parallel='equator';
mlabel(parallel);
mlabel('FontColor','white');
mlabel('off');
gridm('on');
geoshow(moonalb, moonalbrefvec, 'DisplayType', 'texturemap');
plabel('off')
c=colorbar('location','southoutside','box','on','color',[0 0 0]);
c.Label.String='T_{sky} (K)';
c.Limits=[0 500];
c.Ticks=0:50:500;
c.FontSize=12;
textm(-5,-135,'3 h','color','white','fontsize',25);
textm(-5,-90,'6 h','color','white','fontsize',25);
textm(-5,-45,'9 h','color','white','fontsize',25);
textm(-5,0,'12 h','color','white','fontsize',25);
textm(-5,45,'15 h','color','white','fontsize',25);
textm(-5,90,'18 h','color','white','fontsize',25);
textm(-5,90,'18 h','color','white','fontsize',25);
textm(-5,135,'21 h','color','white','fontsize',25);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.