getdist: changing Matlab plot options

Use of Cobaya. camb, CLASS, cosmomc, compilers, etc.
Post Reply
Hiranya Peiris
Posts: 54
Joined: September 28 2004
Affiliation: University College London

getdist: changing Matlab plot options

Post by Hiranya Peiris » January 20 2006

Hi,

Being a MatLab newbie, does anyone know what to modify in getdist so that the character thickness, character size, line thickness and contour colour in the plots are different from the defaults?

I also get a problem when I ask for a specific set of 2D plots. The plots are not in the order I requested, but in some random order. Is there a way to control this behaviour?

Thanks!
Hiranya

Sarah Bridle
Posts: 144
Joined: September 24 2004
Affiliation: University College London (UCL)
Contact:

getdist: changing Matlab plot options

Post by Sarah Bridle » January 20 2006

Here is an answer that is not specific to getdist I'm afraid.
Supposing you have run getdist and made your matlab plots.
You should be able select each sub-plot and change the properties afterwards.
You could do this with the pointy clicky interface, but I expect you want something that you can run every single time.
Something that might work in matlab is:

fs=14;
lw=2;
cols=\{'r','b','g','c','m','y',[1 0.5 0.5]}; % define a different color for each subplot
kidsf=get(gcf,'children');
% should give you handles to each of the subplots
for i=1:length(kidsf)
kids=get(kidsf(i),'children'); % get handles to each bit of the subplot
set(kidsf(i),'fontsize',fs); % try changing most of the text to fs
h=get(kidsf(i),'xlabel'); % get handle to xaxis label
set(h,'fontsize',fs)
set(kids,'linewidth',lw); % set all plot components to be thicker lines
% the above line may fail because it is trying to make shading have
% thicker lines..
set(kids,'color',cols\{i}); % change the line color of all plot components
% again this may fail if there is shading, so you would have to delve
% into getdist and do e.g.
% [c h]=contour(x,y); % find this line in getdist
% set(h,'color',cols\{i},'linewidth',lw) % change the properties
end

I also find this line invaluable for making the nice changes I made on the screen appear in the postscript version:
set(gcf,'PaperPositionMode','auto')

So the above is just really some clues as to some ways to change things in matlab. Hope this is some help anyway,
Sarah

Antony Lewis
Posts: 1936
Joined: September 23 2004
Affiliation: University of Sussex
Contact:

Re: getdist: changing Matlab plot options

Post by Antony Lewis » January 22 2006

The GetDist-produced .m files have the font size etc in the top few lines, so you can easily edit an individual plot before running the .m file in MatLab. (Or search GetDist for the line where the fontsize etc are written out and edit that).

Changing colormaps (used by shading) is easy: after or before running the .m file in matlab, use the 'colormap' command in matlab (look in MatLab help file for names of the different available colormaps). Or run the blue.m (or other color) script supplied with CosmoMC if you like the single color gradients.

To generate plots in a different order I think you'd need to edit GetDist (or, easier, switch the order in the .m file).

Boud Roukema
Posts: 87
Joined: February 24 2005
Affiliation: Institute of Astronomy, Nicolaus Copernicus University
Contact:

getdist: changing Matlab plot options

Post by Boud Roukema » January 26 2006

hi, just reminding people that there's a GPL (free software - which you can debug, modify, redistribute) equivalent to matlab, it's called octave:

http://www.octave.org/

If you want to save a few euros/dollars from your departmental budget, or if you want to help modify things in matlab/octave that you don't like, then better use octave rather than matlab, or if you want to be able to (legally) request your computer staff to make a few improvements in the code, then again, better choose octave. I only use it for relatively simple "calculator" stuff, but it is very powerful, using standard, powerful backends like BLAS/LAPACK, GSL, ... and i recommend it to undergrad students.

Sarah Bridle
Posts: 144
Joined: September 24 2004
Affiliation: University College London (UCL)
Contact:

getdist: changing Matlab plot options

Post by Sarah Bridle » January 26 2006

Hi Boud,
I agree that octave is really nice. I tried once to convert myself to it, instead of matlab. I find the main limitation is in making 2d plots (e.g. probability as a fn of x and y, with different colors for different probabilities). I would be interested to know if this has improved since I last investigated things 5 years ago. python does now have a matlab-like module, but it is incredibly slow (e.g. a few mins to plot ~1000 points) - or am I missing something?
Sarah

Post Reply