# How to plot matix and let matrix(0,0) on the upper left corner

Hi:

I use the following code to do matrix plot

``````#include<root/TCanvas.h>
#include<root/TStyle.h>
#include<root/TMatrix.h>

int main()
{
TCanvas canvas;
gStyle->SetOptStat(0);
TMatrixT<double> matrix(4,4);
matrix(0,0)=1;
matrix(0,1)=2;
matrix(0,2)=3;
matrix(0,3)=5;
matrix(1,1)=4;
matrix(1,2)=1;
matrix(1,3)=6;
matrix(2,2)=7;
matrix(2,3)=8;
matrix(3,3)=9;
matrix.DrawClone("colz");
canvas.Print("haha.pdf");
matrix.Print();
}``````

Obvious such matrix is a upper triangular matrix. However the haha.pdf shows that the element of matrix(0,0) is on the bottom left corner so that the graph does not look like upper triangular. Is there a way to make matrix(0,0) on the upper left corner just like mathmatica matplotlib.org/examples/pylab_ex … tshow.html

Actually matrix.DrawClone(“colz”); fills a 2D histogram and draw it.
Histogram’s axis go from left to right on the x axis and bottom to top on the Y.
That’s what you see. There is no simple way to have the Y axis going from top to bottom.

Thank you, but is there any way to extract the 2D histogram? Maybe I want to manipulate the axis and label. TH1 and TH2 can use its member function GetXAxis() to access the axis. But there is no member function GetXAxis() of TMatrixT.

I guess a better idea would be to create this histogram “manually”: ``` canvas.SetRightMargin(0.125); // 12.5% right margin TH2D *h = new TH2D(matrix); h->SetNameTitle("h", "my matrix;my x axis;my y axis;my z axis"); h->Draw("colz");```