Reduce font size for TMVA Gui correlation matrices?

Hi all,

Is there a simple way to reduce the axis label and bin text size on the correlation matrices created by the TMVA Gui? If I train a BDT with a large number of variables, when I plot the variable correlation matrices, the labels overlap on the x-axis, and the bin labels overlap adjacent bins.

I’ve tried writing my own script to produce the correlation matrices but in my TMVA.root file, the TH2F CorrelationMatrixB looks to be empty by default - I presume it is filled with correlation coefficients by a script separate to correlation.cxx, but I’m not sure which one. If you could point me to that, that would also help :slight_smile:



As you deduced, the data of the matrix is not stored with the ROOT file, but is dynamically filled by correlation.cxx.

To change the look of the plot you can do this (in a script or interactive session):

TString datasetname = "<name>";
TString filepath = "/path/to/TMVA.root";
TString isRegression = false; // If classification
TMVA::correlations(datasetname, filepath, isRegression, true, true);
TCanvas & c = *dynamic_cast<TCanvas *>(gROOT->FindObject("CorrelationMatrixS"));
TH2F & h2 = *(TH2F *)c.GetPrimitive("CorrelationMatrixS")

// TODO: Change size of labels


Note that the canvas and the contained histogram has the same name CorrelationMatrixS and CorrelationMatrixB for classification and CorrelationMatrix for regression.

Using this it should be fairly straight forward to change what you want. Please let me know if you need some more help.


That’s worked perfectly, thank you very much!

Hi, please mark the post as solved to help other wondering about similar things :slight_smile: