Hello I would like to display an axis centered on [0,0,0] of a scatter 3 plot.
Is there a way to do this using the line function?
http://au.mathworks.com/help/matlab/ref/line.html
Not quite sure how to interpret it. Would greatly appreciate a hand.
If you just need the axes try adding:
hold on;
line(xlim,[0,0],[0,0]);
line([0,0],ylim,[0,0]);
line([0,0],[0,0],zlim);
After your scatter plot.
EDIT:
If you want to place the axes with origin at another point, you can do as follows:
hold on;
line(xlim,[origin(2),origin(2)],[origin(3),origin(3)]);
line([origin(1),origin(1)],ylim,[origin(3),origin(3)]);
line([origin(1),origin(1)],[origin(2),origin(2)],zlim);
Where origin is the point where you want the axes to meet.
Related
I am a bit struggling with my polar plot. I am playing with strikes and dips, and for each pair of those, an "intensity". I'd like to plot this surface/contourf/whatever function on my polarplot. I cannot find the handle to do so. Dpp2 contains the intensity value for a given theta and rho/ strike and dip.
xTmp = (0:4:360);
yTmp = (0:22.5:90);
[strike,dip]= meshgrid(deg2rad(xTmp),deg2rad(yTmp));
dip2 = rad2deg(dip);
strike2 =rad2deg(strike);
figure('name', 'COLD');
polarplot([0 360],[0 90]);
s = surf(strike2, dip2, DPp2);
polarplot(s);
colormap
I've tried something like that, which obviously doesn't work.
cheers,
Flo
As far as I know there is no way of creating a surface plot directly in a polarplot.
One workaround is to manually create your polar axis plot. You can find an example here.
Another workaround would be to use
polarscatter to create a scatter plot (which looks simmilar in case you have a tight grid) Have a look at this.
Because you mentioned the handle: In case you want a handle to the axes have a look at polaraxes from here.
The polar scatter wasn't working, so I tried another function, which seems to work according to this page: https://fr.mathworks.com/matlabcentral/answers/95796-how-do-i-create-a-contour-plot-in-polar-coordinates
I am note quite there yet, the contour map isn't "wrapped" around my polar plot, but so far it's compiling. If anyone has an idea on how to superimpose the contour map onto the polar plot ?
dip2 = rad2deg(dip);
strike2 =rad2deg(strike);
h = polar([0 360],[0 90]);
hold on;
contourf(strike2,dip2,DPp2);
% Hide the POLAR function data and leave annotations
set(h,'Visible','off')
% Turn off axes and set square aspect ratio
axis off
axis image
There must be a simple answer to this. I cannot really find a suitable response after a lot of searching.
This is what I want to make using the GUIDE tool.
This is what I get. (Note: the plot is made using the subplot function)
What am I doing wrong? Shouldn't the plot simply fit into the predefined 'axes1' rectangle from the GUIDE interface?
The way I solved this is by putting the axes in a separate panel, thus restraining them to the size of the panel. Hope it helps!
PS: I am using subplot too.
If you use the subplot function within the GUI it will override the axes defined using GUIDE. Instead it is best to plot two separate axes.
%this will plot axes 1
axes(handles.axes1)
plot(x,y)
title('Title of Axes 1'
ylabel('y Label of Axes 1')
xlabel('x Label of Axes 1')
%this will plot axes 2
axes(handles.axes2)
plot(x,y)
title('Title of Axes 2'
ylabel('y Label of Axes 2')
xlabel('x Label of Axes 2')
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 got this question that how to add dots on a 2D graph, like the following picture.
https://www.dropbox.com/s/rs501qkwqqk8qgk/abc.jpg
(the white dots and text on the above graph are needed to be added.)
I have plotted the graph, just do not know the command in matlab of adding the dots on that.
Thanks
(Since there are not many details, I'll go with a generic answer)
If you have the dots coordinates in, say, vectors X and Y, you can plot them with:
hold on; % Keep your plot while updating
plot(X, Y, 'ok'); % Black circles with white background
hold off; % Allow your plots to refresh after that
Also, if you know where the text 'Tower' should be drawn in the current axes (i.e. taking in account the axes limits), say, x_text and y_text, then:
hold on;
text(x_text, y_text, 'Tower');
hold off;
should do the job.
i am trying to plot "scatter" on top of "imagesc" which dosen't work. However, i can plot "scatter" figure separately. I even tried "hold all" instead of "hold on". Can someone help me out? Thank you.
figure(2)
imagesc(lat1,height,scatter0')
hold on;
scatter(lat1,top2,'k')
title('2012_12_4')
colormap(colors)
axis xy
It is probably x-y limits that are not matched, or that the z-values that are not properly normalized to plot side by side. The normalization is important because imagesc and scatter will share the same colormap. Other than that, your code works nicely for me. For example, I'm normalizing in the range [0,1] the "z" values of both plots:
load seamount
m=peaks(200);
m=(m-min(m(:)))./(max(m(:))-min(m(:)));
imagesc([0.996 1.0005],[1,1.012],m);
hold on ;
z=(z-min(z(:)))./(max(z(:))-min(z(:)));
scatter(x./max(x(:)),y./max(y(:)),5,z);