matlab-figure

Image overlay with matrix

[亡魂溺海] 提交于 2019-11-28 00:43:35
问题 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? 回答1: Here is an example of overlaying a binary heatmap on top of a color image: %# some image I =

Hierarchically grouped boxplot

浪尽此生 提交于 2019-11-28 00:34:47
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 . Well, this is not precisely what you asked for, and does not use the function hierarchicalBoxplot , but it may be a workaround. I demonstrate it using MATLAB example data: load carsmall

Dynamic Legend (Updates in every recursion)

点点圈 提交于 2019-11-27 19:32:52
I got a for i=1:15 . Inside I generate a variable d=1:0.01:10 , which is the x'x axis and based on this, I create a continuous function F(d) which has 2 unique variables pitch and yaw. I then plot this using different colors in every recursion using cmap = hsv(15); . So then it is: d=1:0.01:10; cmap = hsv(15); for i=1:15 pitch = unidrnd(10); yaw = unidrnd(10); for j=1:length(d) F(j) = d(j)*3*pitch*yaw; %// some long calculation here end p1 = plot(d,F,'Linewidth', 1.0); title ('blah blah') set(p1, 'Color', cmap(i,:)); hold on; legend (['pitch,yaw:', num2str(pitch) num2str(yaw)]) end hold off;

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

断了今生、忘了曾经 提交于 2019-11-27 18:43:39
问题 I would like to know how to plot multiple, 2D contour plots spaced apart in the z-axis, in a 3D figure like this: 回答1: 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

Setting graph figure size

 ̄綄美尐妖づ 提交于 2019-11-27 10:42:53
All I want to do is make the width greater and the height smaller. I'm just doing raster plots but this question applies to any MATLAB figure . I can manually resize it using the figure directly when it's created but I want the program to spit it out in the right size to start with. This could possibly help you? hFig = figure(1); set(hFig, 'Position', [x y width height]) Write it as a one-liner : figure('position', [0, 0, 200, 500]) % create new figure with specified size figure (1) hFig = figure(1); set(gcf,'PaperPositionMode','auto') set(hFig, 'Position', [0 0 xwidth ywidth]) plot(x,y) print

How to set x and y values when using bar3 in Matlab?

女生的网名这么多〃 提交于 2019-11-27 09:41:18
Quick version How can I control the x- and y-values for a 3-d bar plot in Matlab? Details Say we have an 10 x 20 data matrix and we plot it using bar3 , and we want to set the x- and y-values. For instance: foodat = rand(10,20); xVals = [5:14]; yVals = [-3:16]; bar3(xVals, foodat); xlabel('x'); ylabel('y'); Is there a way to feed it the yVals as well? Otherwise the y axes always defaults to [1:N]. Note I don't just want to change the labels using XTickLabel and YTickLabel . I need to change the actual values on the axes, because I am plotting multiple things in the same figure. It isn't enough

Plot many horizontal Bar Plots in the same graph

限于喜欢 提交于 2019-11-27 07:18:16
问题 I need to plot a x-y function, that shows the histograms at x-values. Something similar to the bottom plot of the next figure: I tried to use matlab's "barh", but can't plot many in the same figure. Any ideas? Or, maybe displacing the origin (baseline, basevalue in barseries properties) of successive plots would work. How could I do that for barh? thanks. 回答1: Using 'Position' of axes property % generate "data" m = rand( 40,10 ); [n x] = hist( m, 50 ); % the actual plotting figure; ma = axes(

Multiple plots in one figure

荒凉一梦 提交于 2019-11-27 07:17:50
I have the following code and I want to combine phase space plots into one single figure. I have coded the functions, but I don't know how to make MATLAB put them into one figure. As you see, it is the variables r , a , b , and d that changes. How do I combine them? I also would like to plot the vector field of these phase space plots using the quiver command, but it just does not work. %function lotkavolterra % Plots time series and phase space diagrams. clear all; close all; t0 = 0; tf = 20; N0 = 20; P0 = 5; % Original plot r = 2; a = 1; b = 0.2; d = 1.5; % Time series plots lv = @(t,x)(lv

Semi-transparent markers in Matlab Figures

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-27 06:46:36
问题 I want to plot a scatter plot with filled markers and make them semi-transparent so when two or more markers overlap, the overlapping area will be more opaque. I naively thought sg = scatter(rand(1000,1),rand(1000,1), 'filled'); alpha(0.5) would work, but it doesn't. Also set(get(sg, 'Children'), 'FaceAlpha', 0.2) doesn't work. Any ideas? 回答1: AFAIK, you cannot change the alpha values of the plot markers in scatter . One solution would be to patch to draw markers yourself. Alpha values can be

Automatically maximize a figure

女生的网名这么多〃 提交于 2019-11-27 06:41:00
I am creating some figures in MATLAB and automatically save them to files. The problem that by definition the images are small. A good way to solve my problem by hand is to create an image (figure), maximize it, and save to a file. I am missing this step of automatically maximize a figure. Any suggestions? Up till now I only found this: http://answers.yahoo.com/question/index?qid=20071127135551AAR5JYh http://www.mathworks.com/matlabcentral/newsreader/view_thread/238699 but none are solving my problem. This worked for me: figure('units','normalized','outerposition',[0 0 1 1]) or for current