matlab-figure

MATLAB scatter with tooltip showing other kinds of data and connecting points with arrowhead

时光毁灭记忆、已成空白 提交于 2019-11-29 12:37:37
I want to ask two questions here. In short they are, In a scatter plot in MATLAB how can I click a point using the tooltip and get not the x,y data but some other sort of data associated with the x,y point? Right now I have a workaround using gscatter and a file from file-exchange (see below). But it will get messy for large data sets. How do I connect two points with an arrowhead on the line between them? For example in the rlocus plots MATLAB makes, there is a nifty little arrowhead. Is there a native way to do this in MATLAB for arbitrary plots? Consider the data set in MATLAB clearvars

Running a GUI requires opening the .fig file in GUIDE

旧巷老猫 提交于 2019-11-29 11:56:25
I am trying to run a MATLAB GUI I have created. If I open the .fig file using GUIDE and press the run button there, it runs perfectly. However, when I double-click the .fig file in the 'Current Folder' section of MATLAB, it seems to be unable to find the handles variable. This causes it to give an error whenever handles is used. Why does this happen? Is there a fix/workaround? I'm using MATLAB R2011, but I've tried it on R2012 as well. The code runs fine, and displays the GUI fine, but the moment it encounters the handles variable, it gives the following error: Attempt to reference field of

Matlab update plot with multiple data lines/curves

戏子无情 提交于 2019-11-29 11:42:14
I want to update a plot with multiple data lines/curves as fast as possible. I have seen some method for updating the plot like using: h = plot(x,y); set(h,'YDataSource','y') set(h,'XDataSource','x') refreshdata(h,'caller'); or set(h,'XData',x,'YData',y); For a single curve it works great, however I want to update not only one but multiple data curves. How can I do this? If you create multiple plot objects with a single plot command, the handle returned by plot is actually an array of plot objects (one for each plot). plots = plot(rand(2)); size(plots) 1 2 Because of this, you cannot simply

Putting certain tick labels in boldface (but not all of them)?

南笙酒味 提交于 2019-11-29 11:02:05
In MATLAB I have a graph with some tick labels. I'd like to visually emphasize a few of these labels, but not all of them. Is there a way to only put SOME tick labels in boldface? You could also overlay your "original" axis with a second one. On the second you configure the ticks bold. Together with linkaxes you maintain proper zoom behavior. Though I can't tell if it wasn't possible in the past, but nowadays (at least from R2014b) one could just use tex markup: plot(0:10,0:10); h = gca; h.XTickLabel = {'\bf \color{red} 0','2','\bf 4','6','\bf \color{red} 8','10',} Tick labels are not

Save exact image output from imagesc in matlab

我与影子孤独终老i 提交于 2019-11-29 09:34:42
问题 Hi , I want to save this image produced from imagesc(magic(3)) , the exact rainbow representation, is it possible? Thanks. This question might look like a duplicate , but it is not . I looked at the solution to the similar question at this site , but it did not satisfy me . I have looked into the Matlab help center and the close answer that I got was this one , at the bottom of http://goo.gl/p907wR 回答1: To save the figure as a file (don't matter how it was created), one should do: saveas

How to hold a plot when using plot3 in matlab?

我的未来我决定 提交于 2019-11-29 07:51:41
This works as I expected: for i=1:100 hold on; plot(i,i^2); drawnow; end Ploting the points as they come in the same figure. This on the other hand, doesn't: for i=1:100 hold on; plot3(i,i^2,sqrt(i)); drawnow; end; Since it does not show a 3d plot of the points, it only shows the projection of them in the xy plane. Somehow the hold on statement messes up with plot3. How can I obtain results that are analogous to the 2d case when using plot , in the 3d case, when I have points in several 3d locations? I've tried to make this question concise, if you believe I haven't explained it well enough

How to adjust the distance between the y-label and the y-axis in Matlab?

为君一笑 提交于 2019-11-29 07:21:59
In Matlab, if we do not rotate the y-label that contains several letters, the label may overlap with the tick numbers or even the y-axis. We can increase the distance between the y-label and the y-axis in the following way: plot(A, B); y=ylabel('xxx', 'rot', 0); % do not rotate the y label set(y, 'position', get(y,'position')-[0.1,0,0]); % shift the y label to the left by 0.1 However, a problem is that if we change axis([0 1 0 25]) to axis([0 10 0 25]) , the distance between the y-label and the y-axis will also change. Is there a convenient way to shift the y-label slightly to the left, but

Image overlay with matrix

百般思念 提交于 2019-11-29 07:15:39
I have an image (png) that I want to put underneath a heatmap(so to speak) made from a and a 2D matrix of values 0-1. So the intensity of the spot would be decided by how large the value in the matrix is. I can use imshow(matrix) but that completely draws over the image underneath. Is it possible to perhaps, not draw any pixels with matrix values <.05 or some other way to make this work? Here is an example of overlaying a binary heatmap on top of a color image: %# some image I = im2double( imread('peppers.png') ); %# I create here a random mask (gaussian centered in middle of image) [r,c,~] =

How I obtain bars with function bar3 and different widths for each bar?

主宰稳场 提交于 2019-11-29 06:15:05
I have the code: values = [1.0 0.6 0.1; 0.0 1.0 0.3; 0.9 0.4 1.0]; h = bar3(values); shading interp for i = 1:length(h) % Get the ZData matrix of the current group zdata = get(h(i),'Zdata'); set(h(i),'Cdata',zdata) end set(h,'EdgeColor','k') view(-61, 68); colormap cool colorbar And this is what the figure looks like: I want to obtain different widths for each bar dependent on the height of the bar. What I want looks like a picture in http://www.sdtools.com/help/ii_mac.html . blah http://www.sdtools.com/help/mac.gif This was a little hard to figure out, but it's easy once you get the pattern.

plot multiple 2d contour plots in one 3d figure [Matlab]

孤街浪徒 提交于 2019-11-29 04:52:15
I would like to know how to plot multiple, 2D contour plots spaced apart in the z-axis, in a 3D figure like this: NOTE : The first part of this answer was meant for HG1 graphics. See the second part if you're working with MATLAB R2014b and up ( HG2 ). HG1: The contour function internally creates a number of patch objects, and returns them as a combined hggroup object . So we could set the ZData of all patches by shifting in the Z-dimensions to the desired level (by default contour is shown at z=0). Here is an example: [X,Y,Z] = peaks; surf(X, Y, Z), hold on % plot surface [~,h] = contour(X,Y,Z