How to plot a figure like this
The data is like f(x_i,t_j), i=1,2,..,M, j=1,2,...,N. The horizontal axis is time t and vertical axis is space x
I know that mesh gives a 3-D plot and surf also gives 3-D surface, I wonder which command can give the above 2-D figure?
To make a 2D heatmap, display your array as an image using imshow, and add a colorbar.
Related
If there is an easier way to do this in general any suggestions would be appreciated.
I have imported a .nc file into Matlab and currently have a surface plot created from the interpolated matrix of data which corresponds to longitudes and latitudes. An alpha scale has been applied to add opacity and now I would like to place a map of said longs and lats beneath it so that it acts as an overlay.
here is the code used to plot where xq,yq is the mesh longitude and latitude grid and newMatrix is the interpolated version of the original matrix. Attached is the top view surf plot which I would like a map of long lat restricted x,y axis beneath (line style or topographic)
f = figure;
ax = axes('Parent',f);
h = surf(xq,yq,newMatrix,'Parent',ax);
set(h, 'edgecolor','none');
view(ax,[0,90]);
alpha color
alpha scaled
grid off
colorbar;
I'm aware of geomap but I'm not sure how it can be used in this way without causing the axis to misalign or just not be applied correctly. Before I was using a contour plot but found it easier to interpolate and plot with surf as per this post: Matlab how to make smooth contour plot?
I have a matrix it Matlab that results in a circular contour plot
Is there any way to change the axess from rectangular to polar without changing the shape of the graph?
I have plotted to vectors against each other, and they are already logarithmic and everything is fine with that. But now that I have my plot i want the grid to be logarithmic. I write "grid on" in my code, and I think there should be a way to do this in the plot, but I can't remember how. How do I make the grid logarithmic?
If you use loglog, semilogx or semilogy instead of plot, the grid will automatically be on a log scale for the corresponding axes when using grid on.
If you have already plotted the axes, you can execute the following on the command line:
set(gca,'yscale','log') %# to set the y-axis to logarithmic
set(gca,'xscale','log') %# to set the x-axis to logarithmic
Have a look at axes properties to find out what else you can modify.
I know this question has been asked before - but none of them deal with a 3D plot with 2 Y axis. My question is a continuation of - How do I add a 2D Plot along with a surface or mesh plot in MATLAB? or this.
I have now successfully managed to add a 2D plot along with a surface plot. See image below -
Now my problem is that the range of the 2D plot is so high that the 3D plot is shrunk to look like nothing more than a plane on the ceiling. It is supposed to have variations like the figure in the question I have lined above.
How do I provide a different Y axis for the 2D plot so that the 3D plot is not shrunk like it is here.
It's possible that you can use the DataAspectRatio property to accomplish this. Taking inspiration from the example from the previous post, if we have:
z=peaks(100);
x1=linspace(0,100);
plot3(x1,0*ones(1,numel(x1)),40*sin(x1))
surface(z+40, 'edgecolor', 'none');
and then you can use
set( gca, 'dataaspectratio', [1.25 1.25 .7] )
view( [-37.5 18] )
can work in some cases to help regain some of the range on the surface plot. This method won't work, however, in very extreme cases.
I have some vector (matrix 2*64) points that I draw in a standard way on a compass plot.
compass(data)
This plot looks like this:
Now I'm doing kmeans clustering on my data. After clustering I have a vector of 8 center points (x,y) that I want to draw on the same compass plot like a circle with some diameter R.
First thing I did was creating new compass layer on that plot using command:
compass(centers(:,1), centers(:,2), "o")
"markersize" property doesn't work here. The result of that plot is:
there are some small center circles visible (along with some points describing default arrow), but that is not what I need.
I need something like this:
Is it possible to do that? Does octave (matlab) alows us to draw new objects of different types (circles) on existing plots?
If you instead use an ordinary plot when you want to plot your circles it works fine.
% # Random data in [-1,1]
x = 2*rand(1,10)-1;
y = 2*rand(1,10)-1;
compass(x,y)
hold on
plot(x,y,'ok','MarkerSize',15,'LineWidth',3)