matlab-figure

How do I get the handles of all open figures in MATLAB

こ雲淡風輕ζ 提交于 2019-11-27 06:31:53
I have nine open figures in matlab (generated by another function) and I want to print them all to file. Does anyone know how to grab the handles of all open figures in MATLAB? I know about gcf but it doesn't seem to do what I want. There are a few ways to do this. One way to do this is to get all the children of the root object (represented in prior versions by the handle 0 ): figHandles = get(groot, 'Children'); % Since version R2014b figHandles = get(0, 'Children'); % Earlier versions Or you could use the function findobj : figHandles = findobj('Type', 'figure'); If any of the figures have

How to generate a non-linear colormap/colorbar?

断了今生、忘了曾经 提交于 2019-11-27 05:22:10
I would like to show a non-uniform colorbar as in the first picture. I have tried the code below. 'mycamp4' is a colormap manually saved. The result is shown as the second figure. The number 0.1 and 1.5 will be too closed too see. How can I make the colorbar like in the first picture? v = [0.1 1 1.5 5 7.5 10 30]; v_2 = [0.1 1.5 5 7.5 10 30]; contourf(X,Y,pdf_normal',v); h = colorbar; load('MyColormaps','mycmap4'); set(gcf,'Colormap',mycmap4); set(h, 'YTick', v_2) Picture 1: Picture 2: Here a step by step explanation. First consider the following example: [X,Y,Z1] = peaks; figure(1) [~,h1] =

Change color of 2D plot line depending on 3rd value

故事扮演 提交于 2019-11-27 04:54:43
I have a data set that looks like this 140400 70.7850 1 140401 70.7923 2 140402 70.7993 3 140403 70.8067 4 140404 70.8139 5 140405 70.8212 3 Where the first column corresponds to time (one second intervals between data points) and will be on the x axis, the second column corresponds with distance and will be on the y axis. The third column is a number (one through five) that is a qualification of the movement. I want to make a plot that changes the color of the line between two points depending on what the number of the previous data point was. For example, I want the line to be red between

Control colorbar scale in MATLAB

点点圈 提交于 2019-11-27 04:54:19
问题 Question: How do I specify color transitions in a custom MATLAB colorbar? Specifically, I'd like to make the yellow (see below) cover more area of the colorbar (perhaps [19.5–21.5] or something close to that). Using this answer, I was able to create a custom colorbar in MATLAB. I'm trying to understand this answer as it might be relevant. I have attempted approaches from this answer and reviewed this answer & this one and was unable to accomplish my goal. Full representative example below %

Hierarchically grouped boxplot

丶灬走出姿态 提交于 2019-11-27 04:44:15
问题 I would like to draw a boxplot with two sets of data to compare. I am willing to use Hierarchically grouped boxplot. I could just plot one set of my data using this function. I was wondering how I can use this function to plot two sets of data together. I drew the second set of data in red one by hand to show what I am trying to plot! My problem is that I can't put two sets of data on one graph with hold on . 回答1: Well, this is not precisely what you asked for, and does not use the function

quiver3 arrow color corresponding to magnitude

感情迁移 提交于 2019-11-27 04:39:45
I want the color of each arrow in a quiver3 plot from MATLAB to correspond to the magnitude of each arrow. Is there any way to do that? I saw a few examples online that are able to do this for the 2D quiver , however none of them work for the 3D variant, quiver3 . I have the following plot and want to replace the blue arrows with a color corresponding to their magnitude. In the old graphics system (R2014a and earlier) this is not possible using the built-in quiver object. You can easily get all of the plot objects that are used to compose the quiver plot q = quiver(1:5, 1:5, 1:5, 1:5); handles

Matlab: How to assign different colormaps/colorbars to different surfaces in the same Figure

巧了我就是萌 提交于 2019-11-27 04:26:28
I am fairly new to Matlab and have a few questions. I got two surfaces and a plane in the same figure. I want to use different colormap and colorbar for b and another colormap and colorbar for c. s is fixed color so it's not a problem. Let me try to explain what I am trying to achieve: cmap1=colormap(topobathy) -->cmap1 is 64x3 double as expected cmap2=colormap(redwhitegreen) create cdata1 using cmap1 (this is the first part I cannot figure out, how to scale z data using cmap1, by default CData contains the z values) b=surf(x,y,z,cdata1) colorbar for b using z values c=pcolor(x,y,(z-z0)) - I

Add custom legend without any relation to the graph

依然范特西╮ 提交于 2019-11-27 02:32:22
问题 I wish to insert a legend that is not related to the graph whatsoever: figure; hold on; plot(0,0,'or'); plot(0,0,'ob'); plot(0,0,'ok'); leg = legend('red','blue','black'); Now I wish to add it to another figure: figure; t=linspace(0,10,100); plot(t,sin(t)); %% ADD THE LEGEND OF PLOT ABOVE 回答1: This is how I have solved this problem in the past: figure t=linspace(0,10,100); plot(t,sin(t)); hold on; h = zeros(3, 1); h(1) = plot(NaN,NaN,'or'); h(2) = plot(NaN,NaN,'ob'); h(3) = plot(NaN,NaN,'ok')

Changing Fonts Size in Matlab Plots

丶灬走出姿态 提交于 2019-11-26 23:59:47
问题 I want to change Font Size for xlabel , ylabel , axis size, legend font size a.k.a everything at once, is this possible? By default, font is Helvetica 10. Is there way to change this? I want to use 'FontSize',14, for x or y labels. 回答1: Jonas's answer is good, but I had to modify it slightly to get every piece of text on the screen to change: set(gca,'FontSize',30,'fontWeight','bold') set(findall(gcf,'type','text'),'FontSize',30,'fontWeight','bold') 回答2: If you want to change font size for

3D scatter plot with 4D data

偶尔善良 提交于 2019-11-26 22:12:34
问题 I need to plot a 3D figure with each data point colored with the value of a 4th variable using a colormap. Lets say I have 4 variables X,Y,Z and W where W = f(X,Y,Z). I want a 3D plot with X, Y, and Z as the three axis. The statement scatter3(X,Y,Z,'filled','b') gives me a scatter plot in 3D but I want to incorporate the value of Z in the graph by representing the points as an extra parameter (either with different areas :bigger circles for data points with high value of Z and small circles