matlab-figure

Plotting two categorical arrays in a histogram/bar chart?

半城伤御伤魂 提交于 2019-12-08 00:27:17
问题 I have a categorical array, race, and an array of yes/no, and I want to somehow create a stacked bar/histogram plot with each race having its own bar and each bar is broken up into two different colors - one for the respondents that said yes, and the others for the ones that said no. Is there any way to do this relatively simply in MATLAB? And is there a way at least create a table that shows for each race, how many said yes, how many said no? To clarify, there are 1250 rows in my data set,

Colorbar - axis ticks in Matlab

╄→尐↘猪︶ㄣ 提交于 2019-12-07 15:46:33
问题 I am using the code below d3 = vals; n = datesmonth; figure plot(n,d3); colormap(jet(12)); hold on plot(n, d3,'b-'); scatter(n, d3, [], RiskierInd, 'filled'); caxis([1 12]); colorbar('YTick',[1:12],... 'YTickLabels',{'Non-Durables','Durables','Manufacturing','Oil, Gas and Coal ','Chemicals','Technology','Telephone & TV','Utilities','Wholesale and Retail','Health','Finance','Other'}) datetick('x','mm-yyyy') to produce this figure I have two quick questions: Is it possible to center the color

How can I convert an RGB histogram into a color spectrum?

て烟熏妆下的殇ゞ 提交于 2019-12-07 15:02:30
问题 How can I convert an RGB histogram of an image to create a histogram showing the combined colors along with correct color wavelength range? Example code: pkg load image f=imread('/tmp/marbles.jpg'); f=uint8(f); %need to convert back to uint8 to show picture %Split into RGB Channels f_red = f(:,:,1); f_green = f(:,:,2); f_blue = f(:,:,3); %Get histValues for each channel [y_f_red, x] = imhist(f_red); [y_f_green, x] = imhist(f_green); [y_f_blue, x] = imhist(f_blue); subplot (2,1,1); imshow(f);

How to prevent the fill command in MATLAB from creating boxes without “corners”

瘦欲@ 提交于 2019-12-07 12:26:54
问题 I am currently using the fill command in MATLAB to create a graph of boxes that were created using the 'fill' command (the actual code is based off this StackOverflow Question. My issue is that the boxes that I create do not have "corners." I am attaching a PNG that illustrates the issue. Note that you have to look a little carefully since the image was heavily rendered, though in this example my arrows also look weird since they don't have edges either) I am wondering if anyone has an idea

When saving a figure as eps file, Matlab cuts off colormap labels

a 夏天 提交于 2019-12-07 08:02:33
问题 I have a figure generated using contourf with a colorbar. Most of my plots are fine, but when the values on the colorbar are of the order 10^{-3} , either the numbers 0.005 etc are written by the colorbar, or x10^{-3} is written at the top. In both cases, part of the label gets cut off - either the 3 in x10^{-3} or half of the 5 in 0.005 . I can fix this using set(gca, 'ActivePositionProperty', 'OuterPosition') for the figure onscreen, but I need to save it in eps format. When I do this, the

Data tip customization in matlab figure

*爱你&永不变心* 提交于 2019-12-07 07:25:40
问题 I have a graph with several plots, each of them comes from a different source file. I want the data tip to tell me (X,Y) plus the name of the source file. So long my best try (without success) is this: dcm = datacursormode(gcf); datacursormode on; set(dcm,'UpdateFcn',[@myfunction,{SourceFileName}]); Where myfunction is the default function used in this cases, as pasted at the end of this message and as explained here: http://blogs.mathworks.com/videos/2011/10/19/tutorial-how-to-make-a-custom

Saving .fig file from Octave

丶灬走出姿态 提交于 2019-12-07 01:34:28
问题 I need to make a .fig file that can be reopened in Matlab, but I am working in Octave. But apparently there is no saveas command in Octave. This is what I am trying: octave:3> plot([1,2,3],[45,23,10]) octave:4> saveas(gcf,'myfig.fig') error: `saveas' undefined near line 4 column 1 octave:4> 回答1: Currently the Matlab fig file format is a proprietary binary file format. Octave doesn't know how to export to this format and won't be able to until it is reverse engineered. The fig format that

How to get point of a figure (using callbacks in GUI) when the point is inside a region that previously has been “patched”?

☆樱花仙子☆ 提交于 2019-12-06 19:17:24
I am using patch in order to draw inside an ellipse into a figure I have created in gui environment. Normally, I get figures' points (coordinates) by clicking (using callback functions). It works properly when the point I want to grab is not inside an ellipse that I have previously plotted (applying patch ). What should I do after applying patch in order to be able to get a point that is inside some ellipse after I have drawn it? Thanks a lot! Here's a way to solve your problem: First we draw a point followed by a patch that "covers" it. In this example the patch is transparent, and still the

How to include Annotate extends … in this MATLAB findpeaks?

泄露秘密 提交于 2019-12-06 16:20:18
I have minimums and maximums in the output now (Fig.1) but I would like to get labels (Fig. 2) for sorted maximums (tallest get 1, ...) and similarly for minimums (lowest gets 1). I can do the output of Fig. 1 by the following but I cannot integrate those annotations to the function close all; clear all; clc; % https://se.mathworks.com/help/signal/ref/findpeaks.html % http://stackoverflow.com/a/26837689/54964 x = linspace(0,1,1000); Pos = [1 2 3 5 7 8]/10; Hgt = [4 4 2 2 2 3]; Wdt = [3 8 4 3 4 6]/100; for n = 1:length(Pos) Gauss(n,:) = Hgt(n)*exp(-((x - Pos(n))/Wdt(n)).^2); end PeakSig = sum

Error: Input grid is not a valid Meshgrid

梦想的初衷 提交于 2019-12-06 15:52:06
I have a question. So I have a 3D matrix of XxYxZ = 10x5x20. I want to plot this matrix with the help of isosurface. So first I need to create a mesh grid, but here comes the first problem when I say: [X,Y,Z] = meshgrid(1:10,1:5,1:20) I get a grid of 5x10x20, but I want 10x5x20. Why is this? My idea was to just change the X and Y [Y,X,Z] = meshgrid(1:10,1:5,1:20) When I try to plot the matrix with the help of this grid: isosurface(X,Y,Z,M) I get the error "Input grid is not a valid MESHGRID" What is the problem? Thank you You got screwed by matlab, the X-Dimension is the second and the Y