Reputation: 1144
I am trying to do a figure similar to the one attached.
I have exactly a (224x1) vector with dates (x-axis), a (10x1) vector with maturities (y-axis) and a (224x10) matrix with the values (z-axis).
I tried surf(X, Y, Z) but I got an error ("data dimensions must agree").
How can I combine this to make a plot like the one attached?
Thanks, V!
Edit: The second plot is the one I am getting using Luis Mendo's suggestion:
Upvotes: 2
Views: 927
Reputation: 112769
Use
surf(Y,X,Z)
From the documentation (emphasis added):
surf(x,y,Z)
andsurf(x,y,Z,C)
, with two vector arguments replacing the first two matrix arguments, must havelength(x) = n
andlength(y) = m
where[m,n] = size(Z)
. In this case, the vertices of the surface patches are the triples (x(j), y(i), Z(i,j)). Note thatx
corresponds to the columns ofZ
andy
corresponds to the rows.
Upvotes: 2
Reputation: 35525
Do
[X,Y]=meshgrid(x,y);
surf(X,Y,Z);
You need to create a meshgrid to be able to plot a surf. X ,Y and Z need to be the same size!
Upvotes: 1